# Weighted Cluster-Range Loss and Criticality-Enhancement Loss for Speaker Recognition
## 3 Proposed Approaches
### Criticality-Enhancement Loss  
Previous improvements on triplet loss were inclined towards anchor or hard sample selection [9; 39; 40]. For instance, the hard loss in CRL stresses the selection of the hardest positive and negative for each speaker. Nevertheless, the optimization of the hardest samples is difficult in the initial stage of the training. To address this situation, another novel loss function is proposed, which is referred to as Criticality-Enhancement Loss (CEL). The CEL centers on selecting the most easily, but necessarily optimized triplets (we call them critical samples in this work) and thus dramatically speeds up the training process.  
A novel online critical sample mining method is presented for this loss, as illustrated in Figure 6. Again, we need to fetch the batch mentioned in Section 2.3. For each utterance, according to the cosine similarity, its positives are sorted from the largest to the smallest, while its negatives are sorted from the smallest to the largest. To obtain the critical positive and the critical negative, the sorted positives  
Figure 5: Learning process of the weighted cluster-range loss.  
and sorted negatives are traversed sequentially, and we try to find out the first pair (\(p\)-\(n\)) where the current \(s_{a,n}\) is larger than the current \(s_{a,p}\). Then, a loss function is obtained as below,  
\[L_{crt}=\frac{1}{K\times M}\sum_{i=1}^{K}\sum_{j=1}^{M}\left[C_{i,j}^{n}-C_{i,j} ^{p}\right]_{+} \tag{24}\]  
Given the \(j\)th utterance of the \(i\)th speaker as the anchor, \(L_{crt}\) tries to find out the most easily optimized hard triplet, where the similarity between anchor and the negative is denoted as \(C_{i,j}^{n}\) and the similarity between the anchor and the positive is denoted as \(C_{i,j}^{p}\). The max([.], 0) operation is used here in case there is no such critical pair.  
The criticality-enhancement loss is proposed to have two parts, and the first part is presented above, i.e., the criticality loss. The criticality loss could push those critical hard samples away from the incorrect state (\(s_{a,n}\) is larger than \(s_{a,p}\)). However, this is insufficient, and we need to push the optimized negatives further away from the optimized positives. Therefore, another part of the proposed loss function is presented, i.e., the enhancement loss. Formally,  
\[L_{enh}=\frac{1}{K\times M}\sum_{i=1}^{K}\sum_{j=1}^{M}\left[E_{i,j}^{n}-E_{i,j }^{p}+\alpha\right]_{+} \tag{25}\]  
Similar to \(L_{crt}\), \(L_{enh}\) aims to find those most easily optimized semi-hard triplets, where the similarity between anchor and the negative are denoted as \(E_{i,j}^{n}\) and the similarity between the anchor and the positive is denoted as \(E_{i,j}^{p}\). By combining the criticality loss and enhancement loss, the criticality-enhancement loss is formulated as,  
\[L_{CEL}=L_{crt}+L_{enh} \tag{26}\]  
The CEL aims to degrade the most easily optimized hard triplets per step to semi-hard triplets, whilst degrading the most easily optimized semi-hard triplets to easy triplets. Consequently, the training efficiency is significantly promoted. However, in this work, we still combine it with CRL, in that the optimization of the hard samples dominates the final performance. Formally,  
\[L_{total}=L_{CRL}+L_{CEL} \tag{27}\]  
The normal loss in CRL serves to stabilize the training, and the hard loss in CRL aims to promote the training effectiveness of the later stage. With the addition of CEL, the training efficiency of the  
Figure 6: Diagram of the critical sample selection of Criticality-Enhancement Loss (CEL). The values of the dark brown blocks in positives are one and could be skipped. Given the current positive (framed by the red box), the negatives are traversed (represented by the blue box) until the values in the boxes meet the requirement.  
initial stage is also improved, and relatively more time is gained for the update of the hard loss of CRL. As a result, better performance will be reached.