Explore Courses Blog Tutorials Interview Questions
0 votes
in Machine Learning by (4.2k points)

To save a model in Keras, what are the differences between the output files of:

  2. model.save_weights()
  3. ModelCheckpoint() in the callback

The saved file from is larger than the model from model.save_weights(), but significantly larger than a JSON or Yaml model architecture file. Why is this?

Restating this: Why is size( + size(something) = size(model.save_weights()) + size(model.to_json()), what is that "something"?

Would it be more efficient to just model.save_weights() and model.to_json(), and load from these than to just do and load_model()?

What are the differences?

1 Answer

0 votes
by (6.8k points)

save() saves the weights and the model structure to a single HDF5 file. I believe it also includes things like the optimizer state. Then you can use that HDF5 file with load() to reconstruct the whole model, including weights.

save_weights() only saves the weights to HDF5 and nothing else. You need extra code to reconstruct the model from a JSON file.

Browse Categories