I assume you are working with a binary classification use case?
In that’s the case, your last linear layer should output two logits, as currently you are only dealing with a single class.
Alternatively, you could keep the shape and use nn.BCEWithLogitsLoss.
Make sure to pass the targets as FloatTensors and with the same shape as the model output to this loss function.