MSE : meansquarederror (http://www.Sina.com /
含义:均方误差表示预测值与真值之差的平方和的平均值,即:
me=1nI=1n(xIyI )2(begin ) Aligned ) MSE=(cfRAC(1) n ) sum _ (I=1) ) x_I-y_I ) ) )2)
但在具体应用中与定义略有不同。 主要区别在于参数设置,torch.nn.MSELoss具有reduction参数。 reduction是否折叠维以及折叠方法主要有三个选项。
‘none’: noreductionwillbeapplied .‘mean’: thesumoftheoutputwillbedividedbythenumberofelementsintheoutput .‘sum wwww
请看一个例子:
importtorchimporttorch.nnasnna=torch.tensor ([ 1,2 ]、[ 3,4 ]、dtype=torch.float ) b=torch.tensor )。 type=torch.float (loss _ fn1=torch.nn.MSE loss (reduction=' none ' ) loss1=loss_fn1 ) b.float ), b.b.) ) ) ) 652 4.] ) loss _ fn2=torch.nn.MSE loss (reduction=' sum ' ) loss2=loss_fn2 ) a.FLL 在loss3中,将对应的位置合计并取平均。
此外,torch.nn.MSELoss还有一个妙计。 http://www.Sina.com/(f范数的详细解)当然需要针对要求的结果开具处方。
参考文献[1]pytorch的nn.MSELoss损失函数
[2]状态估计的基本概念(3)最小均方估计和最小均方误差估计