SiaNet/Losses/MeanAbsolutePercentageError.cs
/// <summary>
/// Forwards the inputs and calculate the loss.
/// </summary>
/// <param name="preds">The predicted result.</param>
/// <param name="labels">The true result.</param>
/// <returns></returns>
Forwards the inputs and calculate the loss.
Forwards the inputs and calculate the loss .
public override Tensor Forward(Tensor preds, Tensor labels)
        {
            var diff = K.Abs(preds - labels) / K.Clip(K.Abs(labels), K.Epsilon(), float.MaxValue);
            return 100 * K.Reshape(K.Mean(diff, 1), 1, -1);
        }
public override Tensor Forward ( Tensor preds , Tensor labels ) { var diff = K . Abs ( preds - labels ) / K . Clip ( K . Abs ( labels ) , K . Epsilon ( ) , float . MaxValue ) ; return 100 * K . Reshape ( K . Mean ( diff , 1 ) , 1 , - 1 ) ; }
Forwards the inputs and calculate the loss.
Forwards the inputs and calculate the loss .
None
preds
Tensor
The predicted result.
The predicted result .
labels
Tensor
The true result.
The true result .