register_keras_serializable | R Documentation |
This function registers a custom class or function with the Keras custom
object registry, so that it can be serialized and deserialized without
needing an entry in the user-provided custom_objects
argument. It also injects a
function that Keras will call to get the object's serializable string key.
Note that to be serialized and deserialized, classes must implement the
get_config()
method. Functions do not have this requirement.
The object will be registered under the key 'package>name'
where name
,
defaults to the object name if not passed.
register_keras_serializable(object, name = NULL, package = NULL)
object |
A keras object. |
name |
The name to serialize this class under in this package. |
package |
The package that this class belongs to. This is used for the
|
object
is returned invisibly, for convenient piping. This is
primarily called for side effects.
# Note that `'my_package'` is used as the `package` argument here, and since # the `name` argument is not provided, `'MyDense'` is used as the `name`. layer_my_dense <- Layer("MyDense") register_keras_serializable(layer_my_dense, package = "my_package") MyDense <- environment(layer_my_dense)$`__class__` # the python class obj stopifnot(exprs = { get_registered_object('my_package>MyDense') == MyDense get_registered_name(MyDense) == 'my_package>MyDense' })
Other saving and loading functions:
export_savedmodel.keras.src.models.model.Model()
layer_tfsm()
load_model()
load_model_weights()
save_model()
save_model_config()
save_model_weights()
with_custom_object_scope()
Other serialization utilities:
deserialize_keras_object()
get_custom_objects()
get_registered_name()
get_registered_object()
serialize_keras_object()
with_custom_object_scope()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.