Delen via


SmoothedHingeLoss Class

Definition

A smooth version of the HingeLoss function, commonly used in classification tasks.

public sealed class SmoothedHingeLoss : Microsoft.ML.Trainers.ILossFunction<float,float>, Microsoft.ML.Trainers.ISupportSdcaClassificationLoss
type SmoothedHingeLoss = class
    interface ISupportSdcaClassificationLoss
    interface ISupportSdcaLoss
    interface IScalarLoss
    interface ILossFunction<single, single>
    interface IClassificationLoss
Public NotInheritable Class SmoothedHingeLoss
Implements ILossFunction(Of Single, Single), ISupportSdcaClassificationLoss
Inheritance
SmoothedHingeLoss
Implements

Remarks

Let $f(\hat{y}, y) = 1 - y\hat{y}$, where $\hat{y}$ is the predicted score and $y \in \{-1, 1\}$ is the true label. $f(\hat{y}, y)$ here is the non-zero portion of the Hinge Loss.

Note that the labels used in this calculation are -1 and 1, unlike Log Loss, where the labels used are 0 and 1. Also unlike Log Loss, $\hat{y}$ is the raw predicted score, not the predicted probability (which is calculated by applying a sigmoid function to the predicted score).

The Smoothed Hinge Loss function is then defined as:

$ L(f(\hat{y}, y)) = \begin{cases} 0 & \text{if } f(\hat{y}, y) < 0 \\ \frac{(f(\hat{y}, y))^2}{2\alpha} & \text{if } f(\hat{y}, y) < \alpha \\ f(\hat{y}, y) - \frac{\alpha}{2} & \text{otherwise} \end{cases} $

where $\alpha$ is a smoothing parameter set to 1 by default.

Constructors

SmoothedHingeLoss(Single)

Constructor for smoothed hinge losee.

Methods

ComputeDualUpdateInvariant(Single)
Derivative(Single, Single)
DualLoss(Single, Single)
DualUpdate(Single, Single, Single, Single, Int32)
Loss(Single, Single)

Applies to