Skip to Content
Deep Learning with Keras
book

Deep Learning with Keras

by Antonio Gulli, Sujit Pal
April 2017
Intermediate to advanced
318 pages
7h 40m
English
Packt Publishing
Content preview from Deep Learning with Keras

Saving and loading the weights and the architecture of a model

Model architectures can be easily saved and loaded as follows:

# save as JSON json_string = model.to_json()# save as YAML yaml_string = model.to_yaml() # model reconstruction from JSON: from keras.models import model_from_json model = model_from_json(json_string) # model reconstruction from YAML model = model_from_yaml(yaml_string)

Model parameters (weights) can be easily saved and loaded as follows:

from keras.models import load_model model.save('my_model.h5')# creates a HDF5 file 'my_model.h5' del model# deletes the existing model# returns a compiled model# identical to the previous one model = load_model('my_model.h5')
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Deep Learning with Keras

Advanced Deep Learning with Keras

Rowel Atienza, Neeraj Verma, Valerio Maggio
Deep Learning with TensorFlow 2 and Keras - Second Edition

Deep Learning with TensorFlow 2 and Keras - Second Edition

Antonio Gulli, Dr. Amita Kapoor, Sujit Pal

Publisher Resources

ISBN: 9781787128422Supplemental Content