I have a batch of shape (20,28)
and the output produced by the model has the same shape as I am not using sigmoid in the last layer. I am using BCEWithLogitsLoss as a criterion. How can I pass the y_pred and y_actual to this criterion. I mean in which shape should I modify the shape of the target and predicted value?
Hi Talha!
For a multi-label, multi-class classification problem,
BCWEithLogitsLoss
is an appropriate loss function. For it, your
y_pred
and y_actual
should have the same shape, namely
[nBatch, nClass]
.
Whether the output of your model, y_pred
, has the same shape
as the input to your model will depend on your use case – it doesn’t
have to.
(Note that y_pred
and y_actual
can have additional dimensions.
For example, if you were performing a multi-label segmentation of
an image, they would have shape [nBatch, nClass, H, W]
.)
Best.
K. Frank