In tensorflow 2.0, once the model is trained, how do we save the model to prevent retraining it from the beginning?
Asked
Active
Viewed 1,168 times
0
-
This has been asked and answered before, see https://stackoverflow.com/a/55770331/349130 for example – Dr. Snoopy Feb 05 '20 at 17:16
1 Answers
2
Once you have trained your model, to save it you can use the following code:
model.save('model.h5')
model
is the name of my model, 'model.h5' will be the name of the file containing the trained model where, '.h5' is the extension.
An H5 file is a data file saved in the Hierarchical Data Format (HDF). It contains multidimensional arrays of scientific data.
Now, to load this saved model, you can use the following code:
model = keras.models.load_model('model.h5')
Have a look at this example for a better understanding:
https://github.com/TheArhaam/Python-ML-Basics/blob/master/demo6.py

Arhaam Patvi
- 640
- 5
- 13