gunz_ml.metrics.classification package
Submodules
gunz_ml.metrics.classification.adacos module
- class gunz_ml.metrics.classification.adacos.AdaCos(num_features, num_classes, m=0.5)[source]
Bases:
ModuleAdaCos: Adaptively Scaling Cosine Logits for Effectively Learning Deep Face Representations.
- Reference:
Zhang, X., Zhao, R., Qiao, Y., Wang, X., & Li, H. (2019). AdaCos: Adaptively Scaling Cosine Logits for Effectively Learning Deep Face Representations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR).
- Parameters:
- forward(input, label=None)[source]
Forward pass of AdaCos.
- Parameters:
input (torch.Tensor) – Input features with shape (batch_size, num_features).
label (torch.Tensor, optional) – Ground truth labels with shape (batch_size,). If None, returns raw logits.
- Returns:
Scaled logits with shape (batch_size, num_classes).
- Return type:
torch.Tensor
gunz_ml.metrics.classification.arcface module
- class gunz_ml.metrics.classification.arcface.ArcFace(num_features, num_classes, s=30.0, m=0.5)[source]
Bases:
ModuleArcFace: Additive Angular Margin Loss for Deep Face Recognition.
- Reference:
Deng, J., Guo, J., Xue, N., & Zafeiriou, S. (2019). ArcFace: Additive Angular Margin Loss for Deep Face Recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR).
- Parameters:
- forward(input, label=None)[source]
Forward pass of ArcFace.
- Parameters:
input (torch.Tensor) – Input features with shape (batch_size, num_features).
label (torch.Tensor, optional) – Ground truth labels with shape (batch_size,). If None, returns raw logits.
- Returns:
Scaled logits with shape (batch_size, num_classes).
- Return type:
torch.Tensor
gunz_ml.metrics.classification.cosface module
- class gunz_ml.metrics.classification.cosface.CosFace(num_features, num_classes, s=30.0, m=0.35)[source]
Bases:
ModuleCosFace: Large Margin Cosine Loss for Deep Face Recognition.
- Reference:
Wang, H., Wang, Y., Zhou, Z., Ji, X., Gong, D., Zhou, J., … & Liu, W. (2018). CosFace: Large Margin Cosine Loss for Deep Face Recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR).
- Parameters:
- forward(input, label=None)[source]
Forward pass of CosFace.
- Parameters:
input (torch.Tensor) – Input features with shape (batch_size, num_features).
label (torch.Tensor, optional) – Ground truth labels with shape (batch_size,). If None, returns raw logits.
- Returns:
Scaled logits with shape (batch_size, num_classes).
- Return type:
torch.Tensor
gunz_ml.metrics.classification.sphereface module
- class gunz_ml.metrics.classification.sphereface.SphereFace(num_features, num_classes, s=30.0, m=1.35)[source]
Bases:
ModuleSphereFace: Deep Hypersphere Embedding for Face Recognition.
- Reference:
Liu, W., Wen, Y., Yu, Z., Li, M., Raj, B., & Song, L. (2017). SphereFace: Deep Hypersphere Embedding for Face Recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR).
- Parameters:
- forward(input, label=None)[source]
Forward pass of SphereFace.
- Parameters:
input (torch.Tensor) – Input features with shape (batch_size, num_features).
label (torch.Tensor, optional) – Ground truth labels with shape (batch_size,). If None, returns raw logits.
- Returns:
Scaled logits with shape (batch_size, num_classes).
- Return type:
torch.Tensor