docs icon indicating copy to clipboard operation
docs copied to clipboard

Update tf2_image_retraining.ipynb

Open guidoiaquinti opened this issue 1 year ago • 2 comments

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! 😊

guidoiaquinti avatar Nov 10 '24 10:11 guidoiaquinti

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

github-actions[bot] avatar Nov 10 '24 10:11 github-actions[bot]

@MarkDaoust @markmcd PTAL

8bitmp3 avatar Nov 11 '24 21:11 8bitmp3