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

Fix deserialization issue with custom_loss function while reloading #20820

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion keras/src/saving/serialization_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,15 @@ def _retrieve_class_or_fn(
)
if obj is not None:
return obj

# Fall back code for reloading saved models of versions <=3.6
# into versions >=3.7
filtered_dict = {
k: v
for k, v in custom_objects.items()
if k.endswith(full_config["config"])
}
if filtered_dict:
return next(iter(filtered_dict.values()))
# Otherwise, attempt to retrieve the class object given the `module`
# and `class_name`. Import the module, find the class.
package = module.split(".", maxsplit=1)[0]
Expand Down
Loading