Saving a python list of Tensorflow Variables in TF2

Hi,

Could anyone please explain how to save a Python List consisting of TensorFlow variables. The Variables have different shapes. In TensorFlow v1, I used the “tf.compat.v1.train.Saver” to did the same thing. It seems to me there is no equivalent of that in TensorFlow 2. I have tried using “tf.train.Checkpoint” and “SavedModel”, but it seems they only work with TensorFlow Variables or Models.

Any help would be appreaciated.

Hi @Gaurav_Yadav, You can save the python list of TF variables by passing them to the var_list argument to the tf.train.Checkpoint. Please refer to this gist for working code example. Thank You.

1 Like