Note: Assumption is that y_true is not a one-hot representation of the segmentation batch. For use with e.g., sigmoid activation.

binary_dice_coefficient(y_true, y_pred, smoothingFactor = 0)

Arguments

y_true

True labels (Tensor)

y_pred

Predictions (Tensor of the same shape as y_true)

smoothingFactor

parameter for smoothing the metric.

Value

Dice value (negative)

Author

Tustison NJ

Examples

library( ANTsR ) library( ANTsRNet ) library( keras ) model <- createUnetModel2D( c( 64, 64, 1 ) )
#> Error in py_discover_config(required_module, use_environment): Python specified in RETICULATE_PYTHON (/Users/ntustison/anaconda3/envs/antsx/bin/python3) does not exist
dice_loss <- binary_dice_coefficient( smoothingFactor = 0.1 ) model %>% compile( loss = dice_loss, optimizer = optimizer_adam( lr = 0.0001 ) )
#> Error in compile(., loss = dice_loss, optimizer = optimizer_adam(lr = 1e-04)): object 'model' not found
rm(model); gc()
#> Warning: object 'model' not found
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) #> Ncells 2488151 132.9 4570014 244.1 NA 4570014 244.1 #> Vcells 4379727 33.5 10146329 77.5 65536 6511633 49.7