Difference betwee torch.unsqueeze and target.unsqueeze
I am training a simple MLP by computing the MSE and get the following error:

UserWarning: Using a target size (torch.Size([1])) that is different to the input size (torch.Size([1, 1])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.

The following gives me the right solution
target = target.unsqueeze(1) while torch.unsqueeze(target,1) does not. The former solution is from a previous question and the latter comes from the documentation
Why does the latter fix the UserWarning message with the former doesn't?

torch.unsqueeze Returns a new tensor with a dimension of size one inserted at the specified position. That is its not an inplace operation thus you need to assign its output to something. i.e. simply do :
target = torch.unsqueeze(target, 1)

Otherwise the tensor will remain the same, as you did not store the changes back into it!
