python - How to save checkpoint in tensorflow format in ver 2.18? - Stack Overflow

admin2025-04-16  4

There was a feature - tensorflow format to save a checkpoint. I have checked and it is everywhere in the official docs and samples:

However in the TF I am running (2.18) if I write model.save('something') I get this:

Invalid filepath extension for saving. Please add either a `.keras` extension for the native Keras format (recommended) or a `.h5` extension.

How do I save in "tensorflow" format in the latest versions?

There was a feature - tensorflow format to save a checkpoint. I have checked and it is everywhere in the official docs and samples: https://www.tensorflow.org/tutorials/keras/save_and_load#savedmodel_format

However in the TF I am running (2.18) if I write model.save('something') I get this:

Invalid filepath extension for saving. Please add either a `.keras` extension for the native Keras format (recommended) or a `.h5` extension.

How do I save in "tensorflow" format in the latest versions?

Share Improve this question asked Feb 2 at 10:18 Boppity BopBoppity Bop 10.5k18 gold badges89 silver badges174 bronze badges 1
  • i know .keras/h5 works - i need TF format – Boppity Bop Commented Feb 2 at 10:43
Add a comment  | 

1 Answer 1

Reset to default 0

In TensorFlow 2.18 the behavior of model.save() has changed. In previous versions you could save a model in the “SavedModel” (TensorFlow) format simply by calling, for example, model.save("my_model"). Now, however, model.save() requires that you either specify a .keras or a .h5 extension. To save your model in the TensorFlow SavedModel format, use the save_format parameter:

model.save("my_model", save_format="tf")
转载请注明原文地址:http://anycun.com/QandA/1744804907a87857.html