## 3 Methods
### Two-Stage Training Strategy
#### 3.3.2 Real-Time Error Stability Detection Method  
Determining how to transition in a timely manner from the first stage of training to the second stage, in order to enhance the overall training efficiency, is a key issue addressed during the training process. For this purpose, we introduces a real-time error stability detection method.  
Figure 4a,b illustrate two common trends in error variation: decrease and increase. The red points, \(center_{1}\) and \(center_{2}\), represent the average values of errors in the first and second halves, respectively, while \(\triangle E\) represents the absolute difference between the average values of the first and second halves. Figure 4c presents a schematic diagram of parameters  
Figure 3: Two-stage training flowchart.  
related to the degree of fluctuation. The red points still represent the averages in the first and second halves, while the red points represent the maximum and minimum errors in the first or second half. \(\triangle E_{1}\) and \(\triangle E_{2}\), respectively, indicate the differences between the maximum and minimum values in the first and second halves.  
This method mainly relies on two key indicators: the trend of error variation and the degree of error fluctuation. When the downward trend of the error begins to slow (that is, the slope approaches zero) or even reverses into an upward trend, and the fluctuation ranges of the two subsequences are similar, it is determined that the error has reached a relatively stable state. At this point, the system emits a stage transition signal. In this paper, \"error\" refers to the value of the loss function. The specific algorithmic process is shown in Algorithm 1. In this algorithm, \(E\) represents the error time series. \(m_{prev}\) is the slope calculated from the previous measurement. \(\tau_{f}\) is the fluctuation threshold we set, with a default value of 0.8, and \(\tau_{m}\) is the threshold for the slope, with a default value of \(-0.1\).  
```
1:functionStabilityDetection(\(E,m_{\text{prev}},\tau_{f},\tau_{m}\))
2:\(n\leftarrow\text{length}(E)\)
3:\(\Delta E\leftarrow\max(E)-\min(E)\)
4:\(E_{1}\gets E[1\ldots\frac{n}{2}]\)
5:\(E_{2}\gets E[\frac{n}{2}+1\ldots n]\)
6:\(Center_{1}\leftarrow\frac{2}{n}\sum_{i=1}^{n}E_{1}[i]\)
7:\(Center_{2}\leftarrow\frac{2}{n}\sum_{i=\frac{n}{2}+1}^{n}E_{2}[i]\)
8:\(m\leftarrow\frac{Center_{2}-Center_{1}}{\Delta E}\)
9:\(\Delta E_{1}\leftarrow\max(E_{1})-\min(E_{1})\)
10:\(\Delta E_{2}\leftarrow\max(E_{2})-\min(E_{2})\)
11:\(F\leftarrow\frac{\min(\Delta E_{1}\Delta E_{2})}{\max(\Delta E_{1}\Delta E_ {2})}\)
12:if\(m>\tau_{m}\)and\(F>\tau_{f}\)then
13:\(S\leftarrow\text{True}\)
14:else
15:\(S\leftarrow\text{False}\)
16:endif
17:return\(m,S\)
18:endfunction
```  
**Algorithm 1** Error Stability Signal Detection.  
When setting \(\tau_{m}\), it should be noted that the closer the value is to 0, the smaller the change in the loss function, indicating a potential convergence. At this point, a stage transition may be considered. The value is the main factor affecting trend determination, and its range should not be too large. The range between \(-0.3\) and \(-0.1\) can be considered.  
When setting \(\tau_{f}\), consider that the training process is a continuous optimization, with the loss function consistently undergoing increases and decreases, resulting in instability. A too-high threshold makes the conditions overly strict, hindering stage transitions. On the other hand, a too-low threshold may misjudge phases of rapid change. The closer this value is to 1, the more similar the fluctuation levels of the two subsequences, and the smaller the value, the greater the fluctuation of the loss function, indicating an unstable training process. A range between 0.4 and 0.8 can be considered.  
Figure 4: Schematic representation of the trend and degree of error variation. (**a**) Trend of error increase. (**b**) Trend of error decrease. (**c**) Degree of error fluctuation.