Skip to content

Fix model.predict input type in l02c01_celsius_to_fahrenheit.ipynb #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AhVir
Copy link

@AhVir AhVir commented Jul 17, 2025

Fixed incorrect usage of model.predict([100.0]) in the Celsius-to-Fahrenheit example.

The original code used a plain Python list, which raises a ValueError because TensorFlow expects a NumPy array or tensor with explicit shape. Replaced it with:

model.predict(np.array([100.0]))

This helps prevent confusion for beginners following the tutorial and ensures the example runs without error.

Fixed incorrect usage of model.predict([100.0]) in the Celsius-to-Fahrenheit example.

The original code used a plain Python list, which raises a ValueError because TensorFlow expects a NumPy array or tensor with explicit shape. Replaced it with:

    model.predict(np.array([100.0]))

This helps prevent confusion for beginners following the tutorial and ensures the example runs without error.
@AhVir AhVir requested a review from MarkDaoust as a code owner July 17, 2025 18:28
@google-ml-butler google-ml-butler bot added awaiting review size:XS CL Change Size: Extra Small labels Jul 17, 2025
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

In addition to the original fix, I found other lines in the same notebook where model.predict([100.0]) was incorrectly used. Passing a plain Python list causes a ValueError because TensorFlow expects inputs with explicit shape.

Changes made:
- Replaced all instances of model.predict([100.0]) with model.predict(np.array([100.0]))

Ensured the formatted print example also uses the correct input format. These changes help prevent runtime errors and confusion for beginners following the tutorial.
@google-ml-butler google-ml-butler bot added the kokoro:force-run Tests on submitted change label Jul 31, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants