thank you for answering!
The cuda calls are there because it kept giving me errors about something tha was on the cpu, while it expected cuda and I tried them everywhere.
torch.mul(torch.ones(n_class).cuda(), y_out) is supposed to be a tensor of size n_class that has all values equal to y_out, which is the value of the score for the true class (probabily there is a more elegant solution to do it, I kinda learned python by trial and error…)
do you have any advice on how to avoid the gradient pushing everything on the flat side?