nn.BCEWithLogitsLoss expects the model output and target to have the same shape, so you would need to provide a model output in [batch_size, nb_classes] (same as the target) where a high value indicates an active class and a low one an inactive.