Since your model creates an output in [batch_size, 2], your target would need to match this shape while using nn.BCEWithLogitsLoss. I don’t know if you are working on a multi-class or multi-label classification, but given that you are using nn.BCEWithLogitsLoss and the model output shape it seems to be a multi-label classification, where zero, one, or multiple classes can be active in each sample.