Skip to content
Open
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
12 changes: 7 additions & 5 deletions keras/src/legacy/saving/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,13 @@ def serialize_keras_class_and_config(
# already serialized this config. If so, just use that config. This will
# store an extra ID field in the config, allowing us to re-create the shared
# object relationship at load time.
if _shared_object_saving_scope() is not None and obj is not None:
shared_object_config = _shared_object_saving_scope().get_config(obj)
if shared_object_config is None:
return _shared_object_saving_scope().create_config(base_config, obj)
return shared_object_config
if obj is not None:
scope = _shared_object_saving_scope()
if scope is not None:
shared_object_config = scope.get_config(obj)
if shared_object_config is None:
return scope.create_config(base_config, obj)
return shared_object_config

return base_config

Expand Down