weighted_categorical_crossentropy: Function for weighted categorical cross entropy

View source: R/customMetrics.R

weighted_categorical_crossentropyR Documentation

Function for weighted categorical cross entropy

Description

ported from this implementation:

Usage

weighted_categorical_crossentropy(y_true, y_pred, weights)

Arguments

y_true

True labels (Tensor)

y_pred

Predictions (Tensor of the same shape as y_true)

weights

weights for each class

Details

https://gist.github.com/wassname/ce364fddfc8a025bfab4348cf5de852d

Value

function value

Author(s)

Tustison NJ

Examples


library( ANTsRNet )
library( keras )

model <- createUnetModel2D( c( 64, 64, 1 ), numberOfOutputs = 2 )

model %>% compile( loss = weighted_categorical_crossentropy( weights = c( 1, 1 ) ),
 optimizer = optimizer_adam( lr = 0.0001 ),
   metrics = "accuracy" )


ANTsX/ANTsRNet documentation built on April 28, 2024, 12:16 p.m.