3

I have read that, Pickle library is used to save trained model into a .pkl file to use it later. Also, we can save the weights of a trained model into a hdf5 format using

model.save()

and use those weights afterwards.

So why we use pickle instead of hdf5 files?

Shiv
  • 719
  • 6
  • 20

2 Answers2

1

As of December 2021 neither pickle nor h5 is recommended (while h5 is still supported by Keras/TF).

The docs say:

There are two formats you can use to save an entire model to disk: the TensorFlow SavedModel format, and the older Keras H5 format. The recommended format is SavedModel. It is the default when you use model.save()

Peter
  • 7,896
  • 5
  • 23
  • 50
0

Avoid pickle, there are a couple of problems

Even in keras documentation they say

"It is not recommended to use pickle or cPickle to save a Keras model."

Also look at this solution.

Noah Weber
  • 5,829
  • 1
  • 13
  • 26