quaterion.loss.center_loss module¶
- class CenterLoss(embedding_size: int, num_groups: int, lambda_c: float | None = 0.5)[source]¶
- Bases: - GroupLoss- Center Loss as defined in the paper “A Discriminative Feature Learning Approach for Deep Face Recognition” (http://ydwen.github.io/papers/WenECCV16.pdf) It aims to minimize the intra-class variations while keeping the features of different classes separable. - Parameters:
- embedding_size – Output dimension of the encoder. 
- num_groups – Number of groups (classes) in the dataset. 
- lambda_c – A regularization parameter that controls the contribution of the center loss. 
 
 - forward(embeddings: Tensor, groups: LongTensor) Tensor[source]¶
- Compute the Center Loss value. - Parameters:
- embeddings – shape (batch_size, vector_length) - Output embeddings from the encoder. 
- groups – shape (batch_size,) - Group (class) ids associated with embeddings. 
 
- Returns:
- Tensor – loss value. 
 
 - training: bool¶