public static void MeanSquareError(TensorOld y, TensorOld yHat, TensorOld result) { //因为存在learning rate,所以梯度前面的系数不那么重要,但最好和损失函数一致, TensorOld.Minus(yHat, y, result); result.Multiple(2d / y.ElementCount); }
public static void SquareError(TensorOld y, TensorOld yHat, TensorOld result) { TensorOld.Minus(y, yHat, result); result.Apply(a => a * a); }