It looks like the shape of your target ty might be wrong.
Currently it has the shape [100], while your model’s output is [100, 1].
This means that internally your target will be broadcasted such that the operation
(torch_model(tX) - ty) will yield a tensor of shape [100, 100].
This is most likely wrong.
Try to add dim1 to your target using ty = ty.unsqueeze(1) before passing it to your loss and your model should work.
Let me know, if that helps.