Error loading the model: Layer 'conv2d' expected 2 variables, but received 0 variables during loading. Expected: ['conv2d/kernel:0', 'conv2d/bias:0']

Hi,
I am using tensorflow version 1.15.0.
When I load the model I encounter below error :
Error loading the model: Layer ‘conv2d’ expected 2 variables, but received 0 variables during loading. Expected: [‘conv2d/kernel:0’, ‘conv2d/bias:0’]

Below is my code to load the model :
try:
MODEL = tf.keras.models.load_model(“./save_at_20.keras”)
except ValueError as e:
print(“Error loading the model:”, e)

I was able to load the same model 2 weeks back

Hi @praveer_kumar ,

The error indicates the model expects kernel and bias variables for a conv2d layer, but they’re absent in the saved file,but it is not finding them. This issue could arise due to various reasons, such as changes in the model architecture, changes in the TensorFlow version, or issues with the saved model file.

May be the saved model might be corrupted. if possible consider recreating the model, training it again, and saving it with a new file name. Then, attempt to load the new model.

I highly recommend updating to the latest version of TensorFlow because significant changes, including the deprecation of several libraries, have occurred between the version you are currently using and the most recent release.

I hope it helps.

Thanks.

1 Like