| save_model_weights | R Documentation |
By default, the weights are saved in a single .weights.h5 file. Enable
sharding via max_shard_size to split weights across multiple files (in GB)
and produce a .weights.json manifest that tracks shard metadata.
The saved sharded files contain:
*.weights.json: configuration file containing metadata and
weight_map entries.
*_xxxxxx.weights.h5: weight shards limited by max_shard_size.
model <- keras_model_sequential(input_shape = 2) |> layer_dense(4) path_h5 <- tempfile(fileext = ".weights.h5") path_json <- tempfile(fileext = ".weights.json") model |> save_model_weights(path_h5) model |> save_model_weights(path_json, max_shard_size = 0.01) model |> load_model_weights(path_h5) model |> load_model_weights(path_json)
save_model_weights(model, filepath, overwrite = FALSE, max_shard_size = NULL)
model |
A keras Model object. |
filepath |
Path where the weights will be saved. Accepts |
overwrite |
Whether to overwrite any existing weights at the target location, or instead ask the user via an interactive prompt. |
max_shard_size |
Numeric size in GB for each sharded file. Use |
This is called primarily for side effects. model is returned,
invisibly, to enable usage with the pipe.
Other saving and loading functions:
export_savedmodel.keras.src.models.model.Model()
layer_tfsm()
load_model()
load_model_weights()
register_keras_serializable()
save_model()
save_model_config()
with_custom_object_scope()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.