# Gradient Agreement Hinders the Memorization of Noisy Labels
## 3 Proposed Method
### Pseudo-Labels Supervising  
The training set \(\mathcal{S}=(\mathcal{X},\mathcal{Y})\) consists of input data \(\mathcal{X}\) and corresponding labels \(\mathcal{Y}\). Part of \(\mathcal{Y}\) is made up of noisy labels. Models will over-fit to noisy labels if directly using \(\mathcal{Y}\) as the supervision for training, downgrading the generalization abilities. The gradient agreement updating method proposed above can effectively prevent \(\theta_{A}\) and \(\theta_{B}\) from memorizing noisy labels, yet the performance of trained models can be further strengthened leading by more correct supervision. However, if we directly correct the labels used to supervising \(\theta_{A}\) and \(\theta_{B}\), the training of models will suffer from accumulated confirmation biases. Therefore, we propose to train a third net \(\theta_{C}\) as shown in Algorithm 2.  
First, we use the average of the prediction logits outputted by \(\theta_{A}\) and \(\theta_{B}\) for sample \(x_{i}\) to represent the joint prediction:  
\[p_{i}^{joint}=\frac{1}{2}(\mathcal{P}_{model}(x_{i};\theta_{A})+\mathcal{P}_ {model}(x_{i};\theta_{B})) \tag{6}\]  
Then the label with maximum score in \(p_{i}^{joint}\) is used as pseudo-label \(\hat{y}_{i}\):  
\[\hat{y}_{i}=\arg\max(p_{i}^{joint}) \tag{7}\]With the logit \(p_{i}^{c}\) predicted by \(\theta_{C}\) for sample \(x_{i}\) according to Equation (8), the training of \(\theta_{C}\) is supervised by two losses, named classification loss and prediction logit loss respectively.  
\[p_{i}^{c}=\mathcal{P}_{model}(x_{i};\theta_{C}) \tag{8}\]  
Because \(\theta_{A}\) and \(\theta_{B}\) are hindered from memorizing noisy labels, the precision of pseudo labels generated is apparently much higher than the original annotation labels. Therefore, the classification loss \(\mathcal{L}_{c}\) is defined as:  
\[\mathcal{L}_{c}=\frac{1}{bs}\sum_{i=1}^{bs}\tfrac{1}{max(p_{i}^{joint})> \epsilon}CE(p_{i}^{c},\hat{y}_{i}) \tag{9}\]  
where only pseudo labels with confidence scores higher than \(\epsilon\) will be counted in the loss.  
```
Input: \(\theta_{A}\), \(\theta_{B}\), \(\theta_{C}\), confidence threshold \(\epsilon\), batch size \(bs\), class number \(M\), training dataset \(\mathcal{S}\) = (\(\mathcal{X}\),\(\mathcal{Y}\))
1 for\(\epsilon\) = WarmUpEpoch to MaxEpochdo
2 Draw a mini-batch \((x_{i},y_{i})_{i=1}^{bs}\) from \(\mathcal{S}\) /* obtain the joint prediction logit \(p^{joint_{i}}\) for sample \(x_{i}\) */ \(p_{i}^{joint}=\frac{1}{2}(\mathcal{P}_{model}(x_{i};\theta_{A})+\mathcal{P}_ {model}(x_{i};\theta_{B}))\) /* generate pseudo label \(\hat{y}_{i}\) for sample \(x_{i}\) */ \(\hat{y}_{i}\) = arg max(\(p_{i}^{joint}\)) /* obtain the prediction logit \(p_{i}^{c}\) for sample \(x_{i}\) using \(\theta_{C}\) */ \(p_{i}^{c}=\mathcal{P}_{model}(x_{i};\theta_{C})\) /* classification loss for \(\theta_{C}\) */ \(\mathcal{L}_{c}=\frac{1}{bs}\sum_{i=1}^{bs}\mathbb{1}_{max(p_{i}^{joint})> \epsilon}CE(p_{i}^{c},\hat{y}_{i})\) /* prediction logit loss for \(\theta_{C}\) */ \(\mathcal{L}_{d}=\frac{1}{bs}\sum_{i=1}^{bs}\sum_{j=1}^{M}p_{ij}^{joint}\log \frac{p_{ij}^{joint}}{p_{ij}^{c}}\) /* update \(\theta_{C}\) with the joint loss */ \(\mathcal{L}=\mathcal{L}_{d}+\mathcal{L}_{c}\)
```  
**Algorithm 2**Pseudo-Labels Supervising.  
The prediction logit loss \(\mathcal{L}_{d}\) is defined as the Kullback-Leibler Divergence between the joint logits and the output prediction logits of \(\theta_{C}\):  
\[\mathcal{L}_{d}=\frac{1}{bs}\sum_{i=1}^{bs}\sum_{j=1}^{M}p_{ij}^{joint}\log \frac{p_{ij}^{joint}}{p_{ij}^{c}} \tag{10}\]  
Then, the overall loss \(\mathcal{L}\) of \(\theta_{C}\) is the sum of \(\mathcal{L}_{d}\) and \(\mathcal{L}_{c}\):  
\[\mathcal{L}=\mathcal{L}_{d}+\mathcal{L}_{c} \tag{11}\]  
Leading by \(\mathcal{L}_{d}\), \(\theta_{C}\) is effectively prevented from over-fitting to noisy labels. Meanwhile the performance of \(\theta_{C}\) is further enhanced with \(\mathcal{L}_{c}\) which brings in more correct supervision.