Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

serialize_model

Serialize a model to an R object


Description

Model objects are external references to Keras objects which cannot be saved and restored across R sessions. The serialize_model() and unserialize_model() functions provide facilities to convert Keras models to R objects for persistence within R data files.

Usage

serialize_model(model, include_optimizer = TRUE)

unserialize_model(model, custom_objects = NULL, compile = TRUE)

Arguments

model

Keras model or R "raw" object containing serialized Keras model.

include_optimizer

If TRUE, save optimizer's state.

custom_objects

Mapping class names (or function names) of custom (non-Keras) objects to class/functions (for example, custom metrics or custom loss functions). This mapping can be done with the dict() function of reticulate.

compile

Whether to compile the model after loading.

Value

serialize_model() returns an R "raw" object containing an hdf5 version of the Keras model. unserialize_model() returns a Keras model.

Note

The save_model_hdf5() function enables saving Keras models to external hdf5 files.

See Also


keras

R Interface to 'Keras'

v2.4.0
MIT + file LICENSE
Authors
Daniel Falbel [ctb, cph, cre], JJ Allaire [aut, cph], François Chollet [aut, cph], RStudio [ctb, cph, fnd], Google [ctb, cph, fnd], Yuan Tang [ctb, cph] (<https://orcid.org/0000-0001-5243-233X>), Wouter Van Der Bijl [ctb, cph], Martin Studer [ctb, cph], Sigrid Keydana [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.