Hi Lee!



 UserLee:

It seems that the indices from max is not differentiable which i have to use for loss function.


First the “why” of your error:
The pytorch framework uses various gradient-descent methods
to train your network – that is to minimize your loss function
with respect to your model’s parameters.  For this to work, your
loss function must be a (usefully) differentiable function of the
model parameters.
As you have seen, the argmax() function (“the indices from
max”) is not differentiable, so you can’t use it in your loss function.
As to how to fix your issue:
The short answer is that you have to modify your loss function
to be (usefully) differentiable.
I don’t understand the concept behind your loss functions, so I
don’t have suggestions for you.
What type of problem are you trying to solve?
What are the inputs to your network, and what do those inputs
mean?
What are the meanings of m_label and n_label?
What, conceptually, determines whether your model has made
a good prediction, and how is your loss function trying to measure
that?
Good luck!
K. Frank