| save_swrc_model | R Documentation |
Saves the Keras model weights as an HDF5 file and the R metadata
(scalers, hyperparameters, etc.) as an .rds file inside dir.
save_swrc_model(fit, dir, name = "swrc_model")
fit |
A |
dir |
Directory where the model will be saved. Created if it does not exist. |
name |
Stem name for the output files (default |
Invisibly returns a named list with paths to the two files:
weights_pathPath to the .weights.h5 file.
meta_pathPath to the .rds metadata file.
if (reticulate::py_module_available("tensorflow")) {
# A deliberately small, fast fit: 20 pedons, K = 16 and 50 collocation
# points per residual set. The point here is the interface, not the
# model -- see the vignette for a realistic configuration.
d <- prepare_swrc_data(swrc_example, depth_col = "depth")
d <- d[d$PEDON_ID %in% utils::head(unique(d$PEDON_ID), 20L), ]
x <- c("clay", "silt", "bd_gcm3", "soc", "Depth_num")
SM <- list(K = 16L, S1 = 50L, S2 = 50L, S3 = 50L, S4 = 50L,
epochs = 2L, verbose = FALSE)
fit <- do.call(fit_swrc, c(list(train_df = d, x_inputs = x), SM))
save_swrc_model(fit, dir = tempdir(), name = "model_test")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.