| build_swrc_model | R Documentation |
Constructs a Keras model implementing the monotone-integral architecture of Norouzi et al. (2025). The returned list contains two models that share weights:
theta_model — full prediction model (pF query + covariates → theta).
param_model — extracts the saturated water content (theta_s) from
covariates only.
build_swrc_model(
n_covariates,
hidden = c(128L, 64L),
dropout = 0.1,
K = 64L,
monotone = TRUE,
free_head = c("sigmoid", "integral")
)
n_covariates |
Integer. Number of soil-property covariates ( |
|
Integer vector of length 2. Number of filters in the
first and second Conv1D layers (default | |
dropout |
Numeric dropout rate after each Conv1D layer
(default |
K |
Integer. Number of knot points for the cumulative
integration grid (default |
monotone |
Logical. |
free_head |
Output head used when |
A named list:
theta_modelKeras model: inputs [Xseq_knots, pf_norm],
output shape [N, 2] (theta_hat, theta_s).
param_modelKeras model: input Xseq_knots,
output shape [N, 1] (theta_s only).
KThe K value used.
dkThe knot spacing 1 / (K - 1).
knot_gridNumeric vector of knot positions.
# Building the graph needs a working TensorFlow; without one this is a
# no-op rather than an error, so the example is safe to run anywhere.
if (reticulate::py_module_available("tensorflow")) {
# K = 16 keeps the example well inside CRAN's time budget on a
# machine that does have TensorFlow; the default is K = 64.
mod <- build_swrc_model(n_covariates = 9L, K = 16L)
mod$theta_model$count_params()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.