MSELoss(size_average=False)

nn.MSELoss()得到的是平均到像素的loss

nn.MSELoss(size_average=False)得到整个batch所有像素loss和

MSELoss(size_average=False).div(batch_size)得到平均图像loss

a=torch.Tensor([[1,1],[1,1]])
b=torch.Tensor([[0,0],[0,0]])

f = nn.MSELoss()
f(a,b)
>>>tensor(1.)

f = nn.MSELoss(size_average=False)
f(a,b)
>>>tensor(4.)

 

posted @ 2020-02-25 16:44  Junzhao  阅读(1926)  评论(0编辑  收藏  举报