TF version: 2.6
What is the most general way to serialize/save custom Tensorflow model (a subclass of tf.keras.Model
) so far?
I have tried several ways, some of them are from Q&A several years ago. I wonder if there is any updates or some new "one for all` approach.
-
pickle: For example, for Pytorch model, we can directly pickle. But if I pickle a model subclass of
tf.keras.Model
, it raisescan not pickle weakref
. -
SavedModel: this requires input signature when loading, which I think is an extra step. And I want to save a model with list of tensor as input. But I only saw some workaround to do this, e.g. stack to a single Tensor, or use dict instead.
-
Keras H5 model: this can not save subclass model. It only support functional model.