Reputation: 359
I am a beginner with DNN and pytorch.
I am dealing with a multi-classification problem where my label are encoded into a one-hotted vector, say of dimension D
.
To this end, I am using the CrossEntropyLoss. However now I want to modify or change such criterion in order to penalize value distant from the actual one, say classify 4 instead of 5 is better than 2 instead of 5.
Is there a function already built-in in Pytorch that implement this behavior? Otherwise how can I modify the CrossEntropyLoss to achieve it?
Upvotes: 7
Views: 8545
Reputation: 5392
This could help you. It is a PyTorch implementation ordinal regression: https://www.ethanrosenthal.com/2018/12/06/spacecutter-ordinal-regression/
Upvotes: 2