View source on GitHub |
Turns the serialized form of a Keras object back into an actual object.
tf.keras.legacy.saving.deserialize_keras_object(
identifier,
module_objects=None,
custom_objects=None,
printable_module_name='object'
)
This function is for mid-level library implementers rather than end users.
Importantly, this utility requires you to provide the dict of
module_objects
to use for looking up the object config; this is not
populated by default. If you need a deserialization utility that has
preexisting knowledge of built-in Keras objects, use e.g.
keras.layers.deserialize(config)
, keras.metrics.deserialize(config)
,
etc.
Calling deserialize_keras_object
while underneath the
SharedObjectLoadingScope
context manager will cause any already-seen
shared objects to be returned as-is rather than creating a new object.
Returns | |
---|---|
The deserialized object. |
Example:
A mid-level library implementer might want to implement a utility for retrieving an object from its config, as such:
def deserialize(config, custom_objects=None):
return deserialize_keras_object(
identifier,
module_objects=globals(),
custom_objects=custom_objects,
name="MyObjectType",
)
This is how e.g. keras.layers.deserialize()
is implemented.