If you are using nn.MSELoss, the output and target shape should be equal.
Currently your target has an additional dimension.
You could remove it via target = target.squeeze(1) or target = target.squeeze(2).
What do the dimensions mean in the target?