mrdbourke / zero-to-mastery-ml

All course materials for the Zero to Mastery Machine Learning and Data Science course.
https://dbourke.link/ZTMmlcourse
2.85k stars 3.39k forks source link

value error in keras layer #100

Open soffiyahabass1 opened 1 month ago

soffiyahabass1 commented 1 month ago

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

It showing this error for this code

Setup the model layers

model = tf.keras.Sequential([ hub.KerasLayer(MODEL_URL),

Wrap hub.KerasLayer in a Lambda layer

tf.keras.layers.Dense(units=OUTPUT_SHAPE, 
                      activation="softmax")  # Layer 2 (output layer)

])

ceodaniyal commented 2 weeks ago

downgrade TensorFlow to version 2.15.

You can easily do this by running: 𝘱𝘺𝘡𝘩𝘰𝘯 !𝐩𝐒𝐩 𝐒𝐧𝐬𝐭𝐚π₯π₯ 𝐭𝐞𝐧𝐬𝐨𝐫𝐟π₯𝐨𝐰==𝟐.πŸπŸ“

Here is the detail post