Reputation: 1
/usr/local/lib/python3.10/dist-packages/keras/layers/core/lambda_layer.py in_serialize_function_to_config(self, inputs, allow_raw)
306 module = inputs.__module__
307 elif callable(inputs):
--> 308 output = inputs.__name__
309 output_type = "function"
310 module = inputs.__module__
AttributeError: 'Sequential' object has no attribute 'name'
This is the error message I am looking at. I am doing transfer learning for a CNN (Xception) with some layers added before and after. Yesterday it trained without any issue, now the error above. I am training on google colab. I am using loss=keras.losses.BinaryCrossentropy(). For the 'lambda_layer' I used tf.keras.layers.Lambda(...).
Every idea is very welcome!
I used the 'Sequential' method at two places in my code, for both I already tried keras.models.Sequential(...) and tf.keras.Sequential(...), and ultmately pip installing tensorflow and keras again.
Upvotes: -1
Views: 283
Reputation: 1
The error came from the following change of mine:
model_save = keras.callbacks.ModelCheckpoint('./Xception_model.h5',
save_best_only = True,
save_weights_only = True,
monitor = 'val_loss',
mode = 'min', verbose = 1)
If in this callback save_weights_only is left out or changed to False, then the 'name' error occurs. This should not be the case at least according to the documentation.
Upvotes: 0