Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving formats #18523

Closed
pedrobrs opened this issue Sep 28, 2023 · 12 comments
Closed

Saving formats #18523

pedrobrs opened this issue Sep 28, 2023 · 12 comments

Comments

@pedrobrs
Copy link
Contributor

I used to save models with ModelCheckpoint callback and filename .h5.
Recently update tensorflow to version 2.13.

Now If save the model in h5 format, a warning is logged:
UserWarning: You are saving your model as an HDF5 file via model.save(). This file format is considered legacy. We recommend using instead the native Keras format, e.g. model.save('my_model.keras').

But If use keras, I hit this issue:
https://stackoverflow.com/questions/76701617/the-following-arguments-are-not-supported-with-the-native-keras-format-opti

and, if I use tf format , I get no logs for fit!
When checkpoint filename ends with .h5 I get a log like:
absl - 1106/1106 - 41s - loss: 0.0014 - accuracy: 0.9996 - precision: 0.9998 - recall: 0.9996 - auc: 1.0000 - val_loss: 0.0046 - val_accuracy: 0.9978 - val_precision: 0.9987 - val_recall: 0.9984 - val_auc: 1.0000 - lr: 0.0010 - 41s/epoch - 37ms/step

But with a filename .tf, that log is not generated.

I would like to use a non legacy format but without exceptions nor logs missing.
What can I do?

@SuryanarayanaY
Copy link
Contributor

@pedrobrs ,

We have observed similar behaviour reported in TF repo as well recently and this issue persists from 2.13 version onwards. While saving model with .keras format and if model have a callback say for eg.

tf.keras.callbacks.ModelCheckpoint(
        "models/tmp_saved_model4" + "/{epoch}_model.keras", 
        save_best_only=True #making it to False or None works
)

It fails with similar error as reported in the attached SO link.

Similar issue was discussed in TF #61999. Please have a look into it.

As per my understanding there is issue with model.save('somename.keras', options=something) that causing the failure.

Could you please check and confirm for your case what are the options that are getting passed to model.save() ?

@SuryanarayanaY
Copy link
Contributor

Hi @pedrobrs ,

I believe this issue should have fixed by this PR #18545. The relevant tensorflow issue #tensorflow/tensorflow#61999 also resolved with this PR.

Could you please check the issue with nightly and let us know if yet to resolve. Thanks

@rajveer43
Copy link

can I work on this?

Copy link

github-actions bot commented Nov 1, 2023

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Nov 1, 2023
@rajveer43
Copy link

can I work on this?

@rickiepark
Copy link

Hi @SuryanarayanaY
Same issue is in TF 2.14, please check this [gist].(https://colab.research.google.com/drive/17Fbhpb5XJqRZURZm8wR9xyEM0wOf1Fdc)

@SuryanarayanaY
Copy link
Contributor

Hi @rickiepark ,

Could you please check with nightly version as changes are not merged into nightly only? Also your colab gist not accessible.

Copy link

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Nov 18, 2023
Copy link

github-actions bot commented Dec 3, 2023

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

@github-actions github-actions bot closed this as completed Dec 3, 2023
@steveepreston
Copy link

this issue exists in TensorFlow 2.16.1

@ghsanti
Copy link
Contributor

ghsanti commented Sep 2, 2024

@steveepreston

this issue exists in TensorFlow 2.16.1

Can you share a minimal colab that reproduces the error?

@YMasterous
Copy link

This issue also exists in TensorFlow 2.17.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants