pythontensorflowkerasloading

Layer 'conv2d_11' expected 2 variables, but received 0 variables during loading. Expected: ['conv2d_11/kernel:0', 'conv2d_11/bias:0']


I wanted to load a model using tf.keras.models.load_model('ACM1_9035P.keras') as I usually do but all of a sudden this time it wouldn't load. I got the error message seen in the title. This method has worked many times before but this time it didn't. What's the problem and how can I fix it?

I can provide more information about the model and system if needed.

I used google colab to train, save and load the model. The model was saved using model.save() The model is saved as a .keras file


Solution

  • I found the answer:

    The model was created and saved using TensorFlow version 2.13.0

    I was trying to load it using TensorFlow version 2.14.0

    Downgrading the version in Google Collab to 2.13.0 allowed me to load the model as I have done before.

    To see how you can change the TensorFlow version in Collab, check out this page:

    https://gist.github.com/mervess/5efbec9f62a55a4cd47c900999db7927

    Edit: After deploying many models over different tensorflow versions and OSs, I have found it is much less of a headache to use the .h5 file.