docs icon indicating copy to clipboard operation
docs copied to clipboard

Keras ModelCheckpoint Path Update for Weight Serialization

Open poacosta opened this issue 10 months ago • 2 comments

Keras ModelCheckpoint Path Update for Weight Serialization

Overview

Updates ModelCheckpoint filepath to comply with Keras weight serialization requirements by appending .weights.h5 extension.

Technical Context

The ModelCheckpoint callback requires specific file extensions when save_weights_only=True is enabled.

From:

filepath='./training_checkpoints/ckpt_{epoch}'

To:

filepath='./training_checkpoints/ckpt_{epoch}.weights.h5'

Implementation Details

  • Maintains existing epoch-based checkpoint pattern using {epoch} placeholder
  • Adds required .weights.h5 extension
  • Preserves checkpoint directory structure and naming convention

Validation

  • Checkpoint saving executes without ValueError
  • Weight files load correctly into model instances
  • Per-epoch checkpoint pattern verified

Impact

No changes to model architecture, training dynamics, or checkpoint frequency. Purely file format compliance update for Keras weight serialization requirements.

References

  • https://keras.io/api/models/model_saving_apis/weights_saving_and_loading/

poacosta avatar Jan 10 '25 12:01 poacosta

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Jan 10 '25 12:01 google-cla[bot]

Preview

Preview and run these notebook edits with Google Colab: Rendered notebook diffs available on ReviewNB.com.

Format and style

Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:
$ python3 -m pip install -U --user git+https://github.com/tensorflow/docs

$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
If commits are added to the pull request, synchronize your local branch: git pull origin fix/train-model-bug

github-actions[bot] avatar Jan 10 '25 12:01 github-actions[bot]