tf_compile_model {reservr} | R Documentation |
Compile a Keras model for truncated data under dist
tf_compile_model(
inputs,
intermediate_output,
dist,
optimizer,
censoring = TRUE,
truncation = TRUE,
metrics = NULL,
sample_weight_mode = NULL,
weighted_metrics = NULL,
target_tensors = NULL
)
inputs |
List of keras input layers |
intermediate_output |
Intermediate model layer to be used as input to distribution parameters |
dist |
A |
optimizer |
String (name of optimizer) or optimizer instance. For most
models, this defaults to |
censoring |
A flag, whether the compiled model should support censored
observations. Set to |
truncation |
A flag, whether the compiled model should support truncated
observations. Set to |
metrics |
List of metrics to be evaluated by the model during training
and testing. Each of this can be a string (name of a built-in function),
function or a |
sample_weight_mode |
If you need to do timestep-wise sample weighting
(2D weights), set this to "temporal". |
weighted_metrics |
List of metrics to be evaluated and weighted by
|
target_tensors |
By default, Keras will create a placeholder for the
model's target, which will be fed with the target data during training. If
instead you would like to use your own target tensor (in turn, Keras will
not expect external data for these targets at training time), you can
specify them via the |
A reservr_keras_model
that can be used to train truncated
and censored observations from dist
based on input data from inputs
.
dist <- dist_exponential()
params <- list(rate = 1.0)
N <- 100L
rand_input <- runif(N)
x <- dist$sample(N, with_params = params)
if (interactive() && keras::is_keras_available()) {
tf_in <- keras::layer_input(1L)
mod <- tf_compile_model(
inputs = list(tf_in),
intermediate_output = tf_in,
dist = dist,
optimizer = keras::optimizer_adam(),
censoring = FALSE,
truncation = FALSE
)
}