View source: R/tf_initialise.R
tf_initialise_model | R Documentation |
Initialises a compiled reservr_keras_model
weights such that the predictions are equal to, or close to, the
distribution parameters given by params
.
tf_initialise_model(
model,
params,
mode = c("scale", "perturb", "zero", "none")
)
model |
A |
params |
A list of distribution parameters compatible with |
mode |
An initialisation mode
|
Invisibly model
with changed weights
dist <- dist_exponential()
group <- sample(c(0, 1), size = 100, replace = TRUE)
x <- dist$sample(100, with_params = list(rate = group + 1))
global_fit <- fit(dist, x)
if (interactive()) {
library(keras3)
l_in <- layer_input(shape = 1L)
mod <- tf_compile_model(
inputs = list(l_in),
intermediate_output = l_in,
dist = dist,
optimizer = optimizer_adam(),
censoring = FALSE,
truncation = FALSE
)
tf_initialise_model(mod, global_fit$params)
fit_history <- fit(
mod,
x = group,
y = x,
epochs = 200L
)
predicted_means <- predict(mod, data = as_tensor(c(0, 1), config_floatx()))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.