gluonar.loss¶
Custom losses. Losses are subclasses of gluon.loss.SoftmaxCrossEntropyLoss which is a HybridBlock actually.
gluonar.loss.ArcLoss |
ArcLoss from “ArcFace: Additive Angular Margin Loss for Deep Face Recognition” paper. |
gluonar.loss.RingLoss |
Computes the Ring Loss from “Ring loss: Convex Feature Normalization for Face Recognition” paper. |
API Reference¶
Custom losses. Losses are subclasses of gluon.loss.SoftmaxCrossEntropyLoss which is a HybridBlock actually.
-
gluonar.loss.
get_loss
(name, **kwargs)[source]¶ Parameters: - name (str) – Loss name, check gluonar.loss for details.
- kwargs (str) – Params
Returns: The loss.
Return type: HybridBlock
-
class
gluonar.loss.
ArcLoss
¶ ArcLoss from “ArcFace: Additive Angular Margin Loss for Deep Face Recognition” paper.
Parameters: - classes (int.) – Number of classes.
- m (float.) – Margin parameter for loss.
- s (int.) – Scale parameter for loss.
- Outputs:
- loss: loss tensor with shape (batch_size,). Dimensions other than batch_axis are averaged out.
-
class
gluonar.loss.
RingLoss
¶ Computes the Ring Loss from “Ring loss: Convex Feature Normalization for Face Recognition” paper.
\[L = -\sum_i \log \softmax({pred})_{i,{label}_i} + \frac{\lambda}{2m} \sum_{i=1}^{m} (\Vert \mathcal{F}({x}_i)\Vert_2 - R )^2\]Parameters: lamda (float) – The loss weight enforcing a trade-off between the softmax loss and ring loss. - Outputs:
- loss: loss tensor with shape (batch_size,). Dimensions other than batch_axis are averaged out.