Try this code
import torch
from torch.autograd import Variable
import numpy as np
import torch.nn as nn

torch.manual_seed(7)
a = torch.Tensor((1,2,3))
b = torch.Tensor((4,5,6))
criterion = nn.MSELoss()
print(criterion(a,b))
a = torch.Tensor((1,2,3))
a = a.reshape(3,1)
b = torch.Tensor((4,5,6))
criterion = nn.MSELoss()
print(criterion(a,b))

The output is

torch.Size([3])
torch.Size([3])
tensor(9.)
torch.Size([3, 1])
torch.Size([3])
tensor(10.3333)