Exception while saving model weights

I’ve received the below exception when trying to save my model and have not been able to debug it.

I attempt to save my model weights with:


The first time I do this it works fine. After this I change my learning rate with:

model.optimizer.lr = 0.1

After I’ve changed the learning rate, any time I attempt to save the model weights I get the below exception.

Exception: 'get_value() can only be called on a variable. If you have an expression instead, use eval().

Has anyone else seen this or able to understand what is causing this error. This is on a fine-tuned version of the VGG16 model running in Jupyter Notebook on a t2 instance.

Thanks for your help.

LOL, this just came up in another thread. The proposed solution is to write K.set_value(model.optimizer.lr, 0.1) instead (but you can’t do that if you’ve already written model.optimizer.lr = ...).

Another workaround is to write model.save('...', include_optimizer=False).

1 Like