0

In tensorflow 2.0, once the model is trained, how do we save the model to prevent retraining it from the beginning?

Arhaam Patvi
  • 640
  • 5
  • 13

1 Answers1

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