## 3 The Proposed Method
### Long-Tail Data Detection Module
#### 3.4.2 Foreground Category Loss Calculation Module  
Due to the use of online methods for data augmentation and network training, accurately estimating tail categories during network training has become an important issue. The calculation of foreground categories also requires an estimation of the degree of imbalance between categories. To this end, we introduce the confusion matrix \(M\) as a long-term indicator to estimate the degree of imbalance in the dataset. In Equations (9) and (10), \(M_{i,j}\) represents the confusion matrix value that belongs to category \(i\) but is predicted as category \(j\). It can be calculated when the condition that label \(y\) is the \(i\)-th category holds. \(P\) is the prediction of the network, \(C\) represents the total number of categories, and \(n\) is an instance of the corresponding category under the current input. \(\|x\|\) is an operator that outputs \(1\) if and only if the input condition x holds. Specifically implemented in the program, we maintain a \(C\times C\) two-dimensional array, representing the degree of imbalance between every two types of samples counted at the beginning of the network's self-classifier learning stage. If \(M_{j,i}>M_{i,j}\), it means that the \(i\)-th category (header data) is greater than the \(j\)-th category (tail data).  
Meanwhile, we introduced short-term indicator pairs to represent the classification ability of the current stage network, as shown in Equation (11). In Equation (11), \(\widetilde{p}_{i}\) is the short-term indicator of category \(i\), \(C\) is the total number of categories and \(p_{C+1}\) is the predicted probability of the background category output by the network. These two indicators work together to monitor the learning status of different categories and guide the network in learning tail categories with poor classification performance.  
\[M_{i,j}=\frac{\sum\limits_{n}\overline{p}_{n,j}\|y_{n,i}=1\|}{\sum\limits_{n} \|y_{n,i}=1\|} \tag{9}\]  
\[\overline{p}_{n,j}=\frac{\exp(z_{j})}{\sum\limits_{k=1}^{C}\exp(z_{k})} \tag{10}\]  
\[\widetilde{p}_{i}=\begin{cases}(1-p_{C+1})\cdot p_{i},&1\leq i\leq C\\ p_{C+1},&i=C+1\end{cases} \tag{11}\]  
The final network loss function design is shown in Equation (12). In the equation, \(w_{j}\) is the weight for different classes, \(p^{\prime}_{j}\) is corrected probability, and \(\widetilde{p}_{t}\) is set to 0.7 by default; this hyperparameter is only used in extreme cases where the confidence level of the network's output data is not high, such as at the beginning of training or when the difficulty of classifying the current input samples is relatively high, resulting in a low confidence level of the network's output. It is used to quickly converge the network and accelerate the learning process of tail categories. If category \(i\) is stronger than \(j\), the margin \(\delta_{ij}\) is negative, guiding the network to output a larger output \(z_{j}\), resulting in a higher probability of obtaining \(p_{j}\) during prediction. \(w_{j}\), \(\delta_{ij}\), and \(p^{\prime}_{j}\) are defined in Equations (13)-(15).  
\[L_{cls}=-\log(p_{i})-\log(1-p_{C+1})-\sum\limits_{j=1,j\
eq i}^{C}w_{j}\log \Bigl{(}1-p^{\prime}_{j}\Bigr{)} \tag{12}\]\[w_{j}=\begin{cases}1,&\widetilde{p_{j}}\geq\widetilde{p_{i}}\\ 1,&\widetilde{p_{j}}\geq\widetilde{p_{t}}\\ 0,&\text{otherwise}\end{cases} \tag{13}\]  
\[\delta_{ij}=\log\left(\frac{M_{i,j}}{M_{j,i}}\right) \tag{14}\]  
\[{p^{\prime}}_{j}=\frac{1}{1+\exp\left[-\left(z_{j}+\delta_{ij}\right)\right]} \tag{15}\]