I am building a CNN model for age classification. Assuming age of a person is between 1-100, my last Linear Layer contains 100 output neuron.
Now i want to find an appropriate loss function for this classification problem.
I dont wish to use Regression
My Observations:
- I cannot use MSE or BCE loss because they only works element wise so unsuitable as if actual age is 25 then there will be same loss for predicted age 26 and 50. (Prediction will be 100 element vector as last layer has 100 neurons.)
- I found about Hinge Loss and Cosine Proximity Loss. But i dont think they can be used in this type of classifiaction either because they are only finding similarity between two vectors without giving any importance or weight to nearby actual-predicted pairs (ex actual age 25 and predicted age 26 should have a very low loss)
Can anyone suggest me a suitable loss function (Preferrably in Pytorch) for this classification problem?
Edit
Lets say I want a Loss Function (L(predicted, actual)) such that (Assuming for 5 class classification)
let actual = [0,0,1,0,0]
L([0,0,1,0,0], actual) < L([0,1,0,0,0], actual) < L([1,0,0,0,0], actual)
L([0,0,1,0,0], actual) < L([0,0,0,1,0], actual) < L([0,0,0,0,1], actual)
rms::orm
inR
. Your CNN is just an extension of that idea, same as how a CNN for MNIST digit classification is an extension of (multinomial) logistic regression. $\endgroup$