Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keras ConvLSTM2D: ValueError when saving model

I am trying to create several LSTM models for time series prediction (e.g. Vanilla, Stacked, Bidirectional). After creating a model I want to save it using tf.keras.models.save_model

This works fine for the LSTM architectures I describe above, but when trying to save a ConvLSTM model I get the following error: ValueError: Object dictionary contained a non-trackable object: (None, None) (for key states)

I am using Keras with backend TensorFlow (2.X) on a Colab notebook. I've created a notebook where the problem can be reproduced.

Any help would be appreciated!

Edit: the model should be saved in the Tensorflow SavedModel format (save_format='tf')

like image 872
Timon Avatar asked Apr 22 '20 10:04

Timon


1 Answers

There are two ways you can save your model.

  1. model.save('model.h5')

  2. Your method but you're missing model name and extension.

Go to gdrive directory using cd.

% cd /content/gdrive

Save with the file name and extension.

# save model to drive
tf.keras.models.save_model(
    model = model,
    filepath = 'model2.h5',
    overwrite=True,
    include_optimizer=True,
    save_format=None,
    signatures=None
)
like image 123
Zabir Al Nazi Avatar answered Nov 14 '22 10:11

Zabir Al Nazi