You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ValueError: Only instances of keras.Layer can be added to a Sequential model. Received: <tensorflow_hub.keras_layer.KerasLayer object at 0x7a9a39daf130> (of type <class 'tensorflow_hub.keras_layer.KerasLayer'>)
#668
Open
moatednorth opened this issue
Aug 14, 2024
Discussed in
#662
· 2 comments
Hi, moatednorth. This is an issue that is occurring in the latest version of tensorflow 2.17. This won't be an issue if you try with tf 2.15.0. Below is a screenshot of my notebook where I was able to use hub.KerasLayers as part of Sequential API.
I just stuck in this for an hour, for anyone out there that stuck on this too... just run this: pip install tensorflow==2.15.0 tensorflow-hub keras==2.15.0
Discussed in #662
Originally posted by moatednorth July 31, 2024
Sequential api can't handle
hub.KerasLayer
`
Create a Keras Layer using the USE pretrained layer from Kaggle
sentence_encoder_layer = hub.KerasLayer("https://www.kaggle.com/models/google/universal-sentence-encoder/TensorFlow2/universal-sentence-encoder/2",
input_shape=[],
dtype=tf.string,
trainable=False,
name="USE")
Create model using the Sequential API
model_6 = tf.keras.Sequential([
sentence_encoder_layer,
layers.Dense(64, activation="relu"),
layers.Dense(1, activation="sigmoid", name="ouput_layer")
], name="model_6_USE")
`
The text was updated successfully, but these errors were encountered: