I have a saved model in 'h5' format. I am trying to resume training and trying to load the weights of the optimizer after compiling the model using
model.optimizer.set_weights(weights_list)
where weights_list
is a list of numpy arrays containing the optimizer weights that I manually extracted from the h5 file.
But I am getting the above error.
When I try model.optimizer.get_weights()
I am getting an empty list.
I want to know how to initialize the optimizer weights without any error.
However, if I do
model = tf.keras.model.load_model('~/modelname.h5',custom_objects={},compile=True)
It works, that is I can resume training with the previously saved weights.
However, tf.keras.models.load_model
doesn't always work and sometimes it requires one to build the model and use load_weights
to initialize the model.