Title: ModelCheckpoint Callback Fails to Save Models in .h5 Format in TensorFlow 2.17.0+
Description:
I’m experiencing an issue with TensorFlow’s tf.keras.callbacks.ModelCheckpoint
across different TensorFlow versions on different platforms.
Background:
- Platform 1: Windows with TensorFlow 2.10.0 (GPU-enabled).
- Platform 2: Docker container on Linux using TensorFlow 2.3.0 (nvcr.io/nvidia/tensorflow:20.09-tf2-py3).
With versions up to TensorFlow 2.15.0, I was able to save models in .h5
format using tf.keras.callbacks.ModelCheckpoint
with the save_weights_only=False
parameter. This allowed for easy cross-platform loading of saved models.
Problem: Since TensorFlow 2.17.0, tf.keras.callbacks.ModelCheckpoint
appears unable to save models in .h5
format, breaking backward compatibility. Models can only be saved in the .keras
format, which versions prior to 2.17.0 cannot load, creating a compatibility issue for users maintaining models across different TensorFlow versions.
Steps to Reproduce:
- Use TensorFlow 2.17.0 or later.
- Try saving a model with
tf.keras.callbacks.ModelCheckpoint
usingsave_weights_only=False
and specifying.h5
as the file format. - Load the model in a previous version, such as TensorFlow 2.10.0 or earlier.
Expected Behavior: The model should be saved in .h5
format without error, maintaining backward compatibility with earlier versions.
Actual Behavior: The model cannot be saved in .h5
format, only in .keras
format, making it incompatible with TensorFlow versions prior to 2.17.0.
Question: Is there a workaround to save models in .h5
format in TensorFlow 2.17.0+? Or, is there a plan to restore .h5
support in future updates for backward compatibility?
Environment:
- TensorFlow version: 2.17.0+
- Operating systems: Windows, Linux (Docker)
Thank you for your help and for maintaining this project!