compile.keras.src.models.model.Model {keras3} | R Documentation |
Configure a model for training.
Description
Configure a model for training.
Usage
## S3 method for class 'keras.src.models.model.Model'
compile(
object,
optimizer = "rmsprop",
loss = NULL,
metrics = NULL,
...,
loss_weights = NULL,
weighted_metrics = NULL,
run_eagerly = FALSE,
steps_per_execution = 1L,
jit_compile = "auto",
auto_scale_loss = TRUE
)
Arguments
object |
Keras model object |
optimizer |
String (name of optimizer) or optimizer instance. See
|
loss |
Loss function. May be:
A loss function is any callable with the signature
|
metrics |
List of metrics to be evaluated by the model during training and testing. Each of these can be:
Typically you will use
If providing an anonymous R function, you can customize the printed name
during training by assigning |
... |
Additional arguments passed on to the |
loss_weights |
Optional list (named or unnamed) specifying scalar
coefficients (R numerics) to weight the loss contributions of
different model outputs. The loss value that will be minimized
by the model will then be the weighted sum of all individual
losses, weighted by the |
weighted_metrics |
List of metrics to be evaluated and weighted by
|
run_eagerly |
Bool. If |
steps_per_execution |
Int. The number of batches to run
during each a single compiled function call. Running multiple
batches inside a single compiled function call can
greatly improve performance on TPUs or small models with a large
R/Python overhead. At most, one full epoch will be run each
execution. If a number larger than the size of the epoch is
passed, the execution will be truncated to the size of the
epoch. Note that if |
jit_compile |
Bool or |
auto_scale_loss |
Bool. If |
Value
This is called primarily for the side effect of modifying object
in-place. The first argument object
is also returned, invisibly, to
enable usage with the pipe.
Examples
model |> compile( optimizer = optimizer_adam(learning_rate = 1e-3), loss = loss_binary_crossentropy(), metrics = c(metric_binary_accuracy(), metric_false_negatives()) )
See Also
Other model training:
evaluate.keras.src.models.model.Model()
predict.keras.src.models.model.Model()
predict_on_batch()
test_on_batch()
train_on_batch()