| ag_save_model | R Documentation |
Serializes the trainable parameters and persistent buffers of an
ag_sequential (or single ag_* layer) module as a portable
state dictionary of plain numeric matrices. This avoids serializing the live
module (environments + closures), which is brittle across ggmlR versions and
carries non-portable GPU pointers.
ag_save_model(model, path, model_fn = NULL)
model |
An |
path |
File path to write (an RDS container). |
model_fn |
Optional zero-argument function that rebuilds the module
architecture (fresh, untrained). If supplied, it is stored in the container
so |
Reconstruction requires the architecture. Either pass model_fn here so
it is stored in the file, or pass it later to ag_load_model.
path, invisibly.
ag_load_model
build <- function() ag_sequential(ag_linear(4L, 8L), ag_linear(8L, 3L))
model <- build()
ag_save_model(model, tempfile(fileext = ".rds"), model_fn = build)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.