SiaNet/Losses/MeanAbsolutePercentageError.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)
        {
            var diff = (preds - labels) / K.Clip(K.Abs(labels) * K.Abs(labels - preds), K.Epsilon(), float.MaxValue);
            return 100 * diff / preds.Shape[0];
        }
public override Tensor Backward ( Tensor preds , Tensor labels ) { var diff = ( preds - labels ) / K . Clip ( K . Abs ( labels ) * K . Abs ( labels - preds ) , K . Epsilon ( ) , float . MaxValue ) ; return 100 * diff / preds . Shape [ 0 ] ; }
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 .