Error #697
Replies: 2 comments
-
Hey, I ran into a similar issue before, it happens when trying to add a fix: Try wrapping the Hub layer using
This worked for me when I had the same error. It seems like some version mismatches between TensorFlow and TensorFlow Hub can cause this issue; wrapping with Lambda helps bypass it safely. |
Beta Was this translation helpful? Give feedback.
-
Using lambda layer to solve Hub.KerasLayer issue is fine, but if you try save/load the model you face another error. In my case I use the option to create a class, then a new object (to create the layer): CUT HEREimport tensorflow as tf batch_size = 32 @tf.keras.utils.register_keras_serializable() # Add this decorator def call(self, inputs, **kwargs): # Add **kwargs to the call signature def get_config(self): IMAGE_SIZE = (224, 224) Create the layerfeature_extractor_url = "https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4" feature_extractor_layer = MyModelClass(feature_extractor_url, trainable=False) feature_extractor_layer.trainable = False Create the train (train_ds) and validation (val_ds) Datesets and extract the Class NamesCreate the modelnum_classes = len(class_names) model = tf.keras.Sequential([ model.summary() model.compile( NUM_EPOCHS = 3 history = model.fit(train_ds, Save the modelt = time.time() export_path = "./saved_models/{}.keras".format(int(t)) print(export_path) Reload the modelreloaded = tf.keras.models.load_model(export_path) Verifyreloaded.summary() CUT HERE |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Can some buddy help me with this error when i am building transfer learning model
Beta Was this translation helpful? Give feedback.
All reactions