Weighted Categorical Crossentropy

Hi,

since this is related to the new library, I guess I should ask here first.

@jeremy , any chance some kind of weighted categorical crossentropy is already implemented in fastai? This should included imho, to be able to penalize some misclassifications over others: one example would be on MNIST penalize more the 1-7 misclassification than the 8-0 on the loss computation.

One discussion over this is here: https://github.com/fchollet/keras/issues/2115

Can’t wait for tonight’s lecture!

1 Like

You can use any pytorch loss function, or write your own. There’s some info on weighted loss functions here:

To set the loss function, just set learn.crit to the function of your choice. E.g.:

learn.crit = F.cross_entropy
3 Likes