Gradient icon indicating copy to clipboard operation
Gradient copied to clipboard

Saving and Loading a model

Open Cliff-Foreman opened this issue 5 years ago • 3 comments

Hi everyone, I had a quick question about how I can save and load a model. When I try using

 model.save_weights("model.h5");

the model is not saved anywhere.

Cliff-Foreman avatar Mar 20 '20 21:03 Cliff-Foreman

The model should be saved to the current directory, e.g. Environment.CurrentDirectory

lostmsu avatar Mar 20 '20 22:03 lostmsu

Ah, I found it. Thanks. Now, when I'm trying to load the model, I'm doing:

var model = new Sequential();
model.load_weights("model.h5");

Is this the right way to do it?

Cliff-Foreman avatar Mar 20 '20 23:03 Cliff-Foreman

@Cliff-Foreman you need to reproduce model structure first. E.g. pass all layers as you did for training.

If you want layers to be restored too, you need to refer to official TensorFlow documentation. https://www.tensorflow.org/tutorials/keras/save_and_load

lostmsu avatar Mar 20 '20 23:03 lostmsu