Hi MngFrc!



 MngFrc:

BCELoss is generally exploited when there’s a classification problem
…
Consequently, the output of the NN is a number comprised between zero and one. Based on the comparison of this latter and a threshold, they decide to accept or refuse a given parameter’s value (which was given as input to the NN). And that’s why they call this NN classifier


Yes, this is a conventional binary-classification problem.  The
input value for the parameter is either accepted – class-“1”,
“yes” – or refused – class-“0”, “no”.  That is, the input has been
classified into one of two classes.


even if its output is a real value which doesn’t correspond to any class.


This is standard.  The output of the classifier – a continuous
number between 0 and 1 – is understood as the predicted
probability of the input being in class-“1”.  This is good for a
number of reasons, not least of which is that it is the result of
a differentiable computation and can be fed into a differentiable
loss function, so the model can be trained with back-propagation.


Moreover, it is written that the loss function they use is the Binary Cross Entropy.
…
is it really possible to use the BCELoss function in such a case?


Yes.  The key is that the continuous output of the model is to be
understood as the predicted probability of the input being in
class-“1”.  And this is exactly what BCELoss expects.
(As an aside, for reasons of numerical stability, you’ll be better
off removing the Sigmoid and using BCEWithLogitsLoss.
This is mathematically – but not numerically – equivalent.)
Best.
K. Frank