torch MSELoss

2020-04-28  本文已影响0人  JeremyL

*CLASS* torch.nn.MSELoss(size_average=None, reduce=None, reduction=mean)

torch.nn.functional.mse_loss(input, target, size_average=None, reduce=None, reduction=mean) → Tensor


参数

输入

"mse_cpu" not implemented for 'Int'

例子

loss = nn.MSELoss(reduce=False, size_average=False)
input = torch.randn(3, 5)
target = torch.randn(3, 5)
output = loss(input.float(), target.float())
print(output)

tensor([[1.2459e+01, 5.8741e-02, 1.8397e-01, 4.9688e-01, 7.3362e-02],
        [8.0921e-01, 1.8580e+00, 4.5180e+00, 7.5342e-01, 4.1929e-01],
        [2.6371e-02, 1.5204e+00, 1.5778e+00, 1.1634e+00, 9.5338e-03]])
loss = nn.MSELoss(reduce = True, size_average=True)
input = torch.randn(3, 5)
target = torch.randn(3, 5)
output = loss(input, target)
print(output)

tensor(1.2368)

参考

TORCH.NN
torch.nn.functional

上一篇 下一篇

猜你喜欢

热点阅读