Reconstructs the CNN1D Keras model from the saved weights and metadata
and returns a swrc_fit-compatible list that can be passed to
predict_swrc(), predict_swrc_dense(), etc.
Value
A swrc_fit object carrying every field fit_swrc() returns
except history, which is not persisted. param_model is rebuilt, but
on a model saved with monotone = FALSE its theta_s output was never
trained, which is why predict_theta_s() refuses such a model.
Examples
# \donttest{
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")
fit2 <- load_swrc_model(tempdir(), "model_test")
}
# }
