Hi Amos!



 Amos_Brazzoli:

So I can determine if the prediction is correct, not just the drop in loss, which I can get now.
Any idea about how can i do it differently or solve this?


You say “So I can determine if the prediction is correct.”  I would
call this the accuracy – the fraction of predictions that are correct.
Then you say “not just the drop in loss, which I can get now.”  From
this I assume that (when you don’t try to compute the accuracy)
you can compute your loss function, train your network to make
the loss smaller, and the loss does indeed go down.
In the standard approach, you train to reduce a loss function, and
then compute the accuracy independent of the training process.
(You typically compute the accuracy – or other statistics not directly
involved in the training process – in a with torch.no_grad():
block.)
The idea is that you want your loss function:


to measure not just whether your prediction is correct, but also
how far off it is;


and to be nicely differentiable so that you can get gradients that
are useful for training (back-propagation).


Based on this, the accuracy generally doesn’t make a good loss
function, so you don’t want to use it for training.
If I understand correctly what you are trying to do, this standard
framework applies to your case.  So you should train using your
loss function (as I am assuming that you have been able to do
successfully), and place your accuracy calculation in a
with torch.no_grad(): block.
Good luck.
K. Frank