loss_sigmoid_focal_crossentropy: Sigmoid focal crossentropy loss

Description Usage Arguments Value Examples

View source: R/losses.R

Description

Sigmoid focal crossentropy loss

Usage

1
2
3
4
5
6
7
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
keras_model_sequential() %>%
  layer_dense(4, input_shape = c(784)) %>%
  compile(
    optimizer = 'sgd',
    loss=loss_sigmoid_focal_crossentropy(),
    metrics='accuracy'
  )

## End(Not run)

tfaddons documentation built on July 2, 2020, 2:12 a.m.