Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

compile.keras.engine.training.Model

Configure a Keras model for training


Description

Configure a Keras model for training

Usage

## S3 method for class 'keras.engine.training.Model'
compile(
  object,
  optimizer,
  loss,
  metrics = NULL,
  loss_weights = NULL,
  sample_weight_mode = NULL,
  weighted_metrics = NULL,
  target_tensors = NULL,
  ...
)

Arguments

object

Model object to compile.

optimizer

Name of optimizer or optimizer instance.

loss

Name of objective function or objective function. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of objectives. The loss value that will be minimized by the model will then be the sum of all individual losses.

metrics

List of metrics to be evaluated by the model during training and testing. Typically you will use metrics='accuracy'. To specify different metrics for different outputs of a multi-output model, you could also pass a named list such as metrics=list(output_a = 'accuracy').

loss_weights

Optional list specifying scalar coefficients 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 indvidual losses, weighted by the loss_weights coefficients.

sample_weight_mode

If you need to do timestep-wise sample weighting (2D weights), set this to "temporal". NULL defaults to sample-wise weights (1D). If the model has multiple outputs, you can use a different sample_weight_mode on each output by passing a list of modes.

weighted_metrics

List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing

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 target_tensors argument. It should be a single tensor (for a single-output sequential model),

...

When using the Theano/CNTK backends, these arguments are passed into K.function. When using the TensorFlow backend, these arguments are passed into tf$Session()$run.

See Also


keras

R Interface to 'Keras'

v2.4.0
MIT + file LICENSE
Authors
Daniel Falbel [ctb, cph, cre], JJ Allaire [aut, cph], François Chollet [aut, cph], RStudio [ctb, cph, fnd], Google [ctb, cph, fnd], Yuan Tang [ctb, cph] (<https://orcid.org/0000-0001-5243-233X>), Wouter Van Der Bijl [ctb, cph], Martin Studer [ctb, cph], Sigrid Keydana [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.