Get/set the currently registered custom objects.
Source:R/model-persistence.R
get_custom_objects.RdCustom objects set using custom_object_scope() are not added to the
global list of custom objects, and will not appear in the returned
list.
Arguments
- objects
A named list of custom objects, as returned by
get_custom_objects()andset_custom_objects().- clear
bool, whether to clear the custom object registry before populating it with
objects.
Value
An R named list mapping registered names to registered objects.
set_custom_objects() returns the registry values before updating, invisibly.
Note
register_keras_serializable() is preferred over set_custom_objects() for
registering new objects.
Examples
You can use set_custom_objects() to restore a previous registry state.
# within a function, if you want to temporarily modify the registry,
function() {
orig_objects <- set_custom_objects(clear = TRUE)
on.exit(set_custom_objects(orig_objects))
## temporarily modify the global registry
# register_keras_serializable(....)
# .... <do work>
# on.exit(), the previous registry state is restored.
}See also
Other serialization utilities: deserialize_keras_object() get_registered_name() get_registered_object() register_keras_serializable() serialize_keras_object() with_custom_object_scope()