Loss functions¶
Gluon provides pre-defined loss functions in the mxnet.gluon.loss
module.
Neural network module.
loss.Loss(weight, batch_axis, **kwargs) |
Base class for loss. |
loss.L2Loss([weight, batch_axis]) |
Calculates the mean squared error between label and pred. |
loss.L1Loss([weight, batch_axis]) |
Calculates the mean absolute error between label and pred. |
loss.SigmoidBinaryCrossEntropyLoss([…]) |
The cross-entropy loss for binary classification. |
loss.SoftmaxCrossEntropyLoss([axis, …]) |
Computes the softmax cross entropy loss. |
loss.KLDivLoss([from_logits, axis, weight, …]) |
The Kullback-Leibler divergence loss. |
loss.HuberLoss([rho, weight, batch_axis]) |
Calculates smoothed L1 loss that is equal to L1 loss if absolute error exceeds rho but is equal to L2 loss otherwise. |
loss.HingeLoss([margin, weight, batch_axis]) |
Calculates the hinge loss function often used in SVMs: |
loss.SquaredHingeLoss([margin, weight, …]) |
Calculates the soft-margin loss function used in SVMs: |
loss.LogisticLoss([weight, batch_axis, …]) |
Calculates the logistic loss (for binary losses only): |
loss.TripletLoss([margin, weight, batch_axis]) |
Calculates triplet loss given three input tensors and a positive margin. |
loss.CTCLoss([layout, label_layout, weight]) |
Connectionist Temporal Classification Loss. |