Skip to content

fix: Use Keras native format (.keras) for model serialization#3622

Open
hamztouiz wants to merge 1 commit into
tensorflow:mainfrom
hamztouiz:fix/keras-model-save-format
Open

fix: Use Keras native format (.keras) for model serialization#3622
hamztouiz wants to merge 1 commit into
tensorflow:mainfrom
hamztouiz:fix/keras-model-save-format

Conversation

@hamztouiz

@hamztouiz hamztouiz commented Jul 5, 2026

Copy link
Copy Markdown

BUG=3623

Summary

Fixes model serialization issues in the hello_world example by switching from TensorFlow SavedModel format to the Keras native format (.keras).

Problem

The training script fails with Keras 3 due to the save_format argument being deprecated:

ValueError: The save_format argument is deprecated in Keras 3.
Please remove this argument and pass a file path with either .keras or .h5 extension.
Received: save_format=tf

Solution

  • Changed model saving to use the .keras format (Keras native)
  • Added directory creation logic to handle cases where the output directory doesn't exist
  • Updated logging to reflect the actual file path being saved

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Testing

The change was tested with the hello_world training script and model serialization now works correctly with Keras 3.

The previous TensorFlow SavedModel format was failing in certain
environments. This change switches to the Keras native format (.keras)
which is more stable and is the recommended approach for saving Keras
models.

Changes:
- Use model.save() with .keras extension instead of SavedModel format
- Create output directory if it doesn't exist
- Update log message to reflect new file path

This fixes issues with model serialization in the hello_world example.
@hamztouiz hamztouiz requested a review from a team as a code owner July 5, 2026 16:13
@google-cla

google-cla Bot commented Jul 5, 2026

Copy link
Copy Markdown

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.

@ddavis-2015 ddavis-2015 added the type:bug Something isn't working as intended. label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working as intended.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants