Skip to content
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

Update tf2_image_retraining.ipynb #2339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guidoiaquinti
Copy link

Hi 👋

While working through the tutorials, I ran into an hiccup with tf2_image_retraining.ipynb:

/usr/local/lib/python3.10/dist-packages/keras/src/layers/core/input_layer.py:26: UserWarning: Argument `input_shape` is deprecated. Use `shape` instead.
  warnings.warn(
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-3-4ec403fe43da>](https://localhost:8080/#) in <cell line: 170>()
    168 
    169 print("Building model with", model_handle)
--> 170 model = tf.keras.Sequential([
    171     # Explicitly define the input shape so the model can be properly
    172     # loaded by the TFLiteConverter

1 frames
[/usr/local/lib/python3.10/dist-packages/keras/src/models/sequential.py](https://localhost:8080/#) in __init__(self, layers, trainable, name)
     71         if layers:
     72             for layer in layers:
---> 73                 self.add(layer, rebuild=False)
     74             self._maybe_rebuild()
     75 

[/usr/local/lib/python3.10/dist-packages/keras/src/models/sequential.py](https://localhost:8080/#) in add(self, layer, rebuild)
     93                 layer = origin_layer
     94         if not isinstance(layer, Layer):
---> 95             raise ValueError(
     96                 "Only instances of `keras.Layer` can be "
     97                 f"added to a Sequential model. Received: {layer} "

ValueError: Only instances of `keras.Layer` can be added to a Sequential model. Received: <tensorflow_hub.keras_layer.KerasLayer object at 0x7823dd59b7f0> (of type <class 'tensorflow_hub.keras_layer.KerasLayer'>)

The code change fixes the ValueError, as well as the deprecation warning.

Thanks for all the amazing work on these tutorials! 😊

Copy link

Preview

Preview and run these notebook edits with Google Colab: Rendered notebook diffs available on ReviewNB.com.

Format and style

Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:
$ python3 -m pip install -U --user git+https://github.com/tensorflow/docs

$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
If commits are added to the pull request, synchronize your local branch: git pull origin master

@8bitmp3
Copy link
Contributor

8bitmp3 commented Nov 11, 2024

@MarkDaoust @markmcd PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants