Learn R Programming

tfaddons (version 0.10.0)

loss_sigmoid_focal_crossentropy: Sigmoid focal crossentropy loss

Description

Sigmoid focal crossentropy loss

Usage

loss_sigmoid_focal_crossentropy(
  from_logits = FALSE,
  alpha = 0.25,
  gamma = 2,
  reduction = tf$keras$losses$Reduction$NONE,
  name = "sigmoid_focal_crossentropy"
)

Arguments

from_logits

If logits are provided then convert the predictions into probabilities

alpha

balancing factor.

gamma

modulating factor.

reduction

(Optional) Type of tf$keras$losses$Reduction to apply. Default value is SUM_OVER_BATCH_SIZE.

name

(Optional) name for the loss.

Value

Weighted loss float `Tensor`. If `reduction` is `NONE`,this has the same shape as `y_true`; otherwise, it is scalar.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
keras_model_sequential() %>%
  layer_dense(4, input_shape = c(784)) %>%
  compile(
    optimizer = 'sgd',
    loss=loss_sigmoid_focal_crossentropy(),
    metrics='accuracy'
  )
# }
# NOT RUN {

# }

Run the code above in your browser using DataLab