SiaNet/Losses/CategorialHinge.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 = (1 - labels) * preds - K.Sum(labels * preds, -1);
            return K.Maximum(diff, 0);
        }
public override Tensor Backward ( Tensor preds , Tensor labels ) { var diff = ( 1 - labels ) * preds - K . Sum ( labels * preds , - 1 ) ; return K . Maximum ( diff , 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 .