View source: R/customMetrics.R
categorical_focal_loss | R Documentation |
The categorical focal loss discussed in this paper:
categorical_focal_loss(y_true, y_pred, gamma = 2, alpha = 0.25)
y_true |
True labels (Tensor) |
y_pred |
Predictions (Tensor of the same shape as |
gamma |
focusing parameter for modulating factor (1-p). Default = 2.0. |
alpha |
weighing factor in balanced cross entropy. Default = 0.25. |
https://arxiv.org/pdf/1708.02002.pdf
and ported from this implementation:
https://github.com/umbertogriffo/focal-loss-keras/blob/master/losses.py
Used to handle imbalanced classes .
function value
Tustison NJ
library( ANTsRNet )
library( keras )
model <- createUnetModel2D( c( 64, 64, 1 ) )
metric_categorical_focal_gain <-
custom_metric( "categorical_focal_gain",
categorical_focal_gain( alpha = 0.25, gamma = 2.0 ) )
model %>% compile( loss = categorical_focal_loss( alpha = 0.25, gamma = 2.0 ),
optimizer = optimizer_adam( lr = 0.0001 ),
metrics = c( metric_categorical_focal_gain ) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.