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

Model weights cannot be saved #68467

Closed
gcelano opened this issue May 22, 2024 · 8 comments
Closed

Model weights cannot be saved #68467

gcelano opened this issue May 22, 2024 · 8 comments
Assignees
Labels
comp:keras Keras related issues stat:awaiting response Status - Awaiting response from author TF 2.16 type:support Support issues

Comments

@gcelano
Copy link

gcelano commented May 22, 2024

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

2.16.1 and inferior

Custom code

Yes

OS platform and distribution

Debian 12 Bookworm

Mobile device

No response

Python version

No response

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

After model.save_weights is used, if a new process is started and model.load_weights is used, the results produced by the model are poor (very different from the ones at training time). The code can be found at https://git.informatik.uni-leipzig.de/celano/dithrax_test (with instructions).

(Since it is not clear if it is a keras or tensorflow problem, an issue has also been opened at keras-team/keras#19693 (comment))

Standalone code to reproduce the issue

https://git.informatik.uni-leipzig.de/celano/dithrax_test

Relevant log output

No response

@SuryanarayanaY
Copy link
Collaborator

Hi @gcelano,

In Keras3, In order to save weights using model.save_weights method you need to add .weights.h5 extension to the path.

model.save_weights('dir/my_model.weights.h5')

Please check the doc source for same.

@SuryanarayanaY SuryanarayanaY added type:support Support issues comp:keras Keras related issues TF 2.16 stat:awaiting response Status - Awaiting response from author and removed type:bug Bug labels May 23, 2024
@testhowtest
Copy link

These issues might share common themes or underlying causes related to saving and loading model weights in TensorFlow. Exploring them further could provide insights into resolving the "Model weights cannot be saved" issue. #65279 , #62483 , #61859 , #61279 , #60064 , #59287

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label May 23, 2024
@gcelano
Copy link
Author

gcelano commented May 23, 2024

@SuryanarayanaY , in my code at link above I use ".weights.h5", and this has no impact on the problem. @testhowtest, is there a provisional workaround? Without saving, there is not much use in using TF

@tilakrayal
Copy link
Contributor

@gcelano,
Looks like this is the Keras issue. It's better to track in the Keras repo which was raised for the quick resolution. Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label Jun 14, 2024
@gcelano
Copy link
Author

gcelano commented Jun 14, 2024

An issue has been opened here keras-team/keras#19693

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label Jun 14, 2024
@tilakrayal
Copy link
Contributor

@gcelano,
Could you please feel free to move this issue to the closed status, as the same issue can be tracked in the Keras repo issue. Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label Jun 17, 2024
@gcelano
Copy link
Author

gcelano commented Jun 17, 2024

Closed because the issue is here: keras-team/keras#19693

@gcelano gcelano closed this as completed Jun 17, 2024
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:keras Keras related issues stat:awaiting response Status - Awaiting response from author TF 2.16 type:support Support issues
Projects
None yet
Development

No branches or pull requests

4 participants