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