SiaNet/Losses/BinaryCrossentropy.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)
        {
            Tensor output = preds;
            if (!FromLogit)
            {
                output = K.Clip(preds, K.Epsilon(), 1f - K.Epsilon());
            }
            return (output - labels) / (output * (1 - output));
        }
public override Tensor Backward ( Tensor preds , Tensor labels ) { Tensor output = preds ; if ( ! FromLogit ) { output = K . Clip ( preds , K . Epsilon ( ) , 1f - K . Epsilon ( ) ) ; } return ( output - labels ) / ( output * ( 1 - output ) ) ; }
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 .