SiaNet/Losses/MeanSquaredError.cs
/// <summary>
/// Backpropagation method to calculate gradient of the loss function
/// </summary>
/// <param name="preds">The predicted result.</param>
/// <param name="labels">The true result.</param>
/// <returns></returns>
Backpropagation method to calculate gradient of the loss function
Backpropagation method to calculate gradient of the loss function
public override Tensor Backward(Tensor preds, Tensor labels)
        {
            float norm = 2f / (float)preds.Shape[0];
            return (preds - labels) * norm;
        }
public override Tensor Backward ( Tensor preds , Tensor labels ) { float norm = 2f / ( float ) preds . Shape [ 0 ] ; return ( preds - labels ) * norm ; }
Backpropagation method to calculate gradient of the loss function
Backpropagation method to calculate gradient of the loss function
None
preds
Tensor
The predicted result.
The predicted result .
labels
Tensor
The true result.
The true result .