You have a shape mismatch for your output and labels.
Add dim1 to labels and it should work:
loss = loss_fn(outputs, labels.unsqueeze(1).float())

I’m creating a feature request to add a warning, since I’ve seen this particular error a few times in the past already.
EDIT:
It’s already being tracked here 1.