# An Aeromagnetic Compensation Algorithm Based on a Residual Neural Network
## 3 Experiment
### Compensation Experiment  
To determine whether Res-Bp can effectively solve the gradient disappearance problem and improve compensation accuracy, we performed compensation experiments with the data of flights A and B. First, we used the data of flights A and B as the test set and training set, respectively, which are compensated by linear regression methods LS and RR. The results shown in Figure 6 and Table 1 show that during flight A, LS reduces STD from 2.171 to 0.355, and IR is 6.115. RR reduces STD to 0.324 and IR to 6.701, so the fitting ability of LS is weaker than that of RR, which is a biased estimation regression method for collinear data analysis. By giving up the unbiasedness of LS, the regression coefficient is obtained at the cost of some information loss and reduced accuracy. It has a higher fitting accuracy and stronger stability than LS. We used the data of flights A and B as the training set and test set, respectively, to compensate flight B and flight A. The compensation results are shown in Figures 7 and 8. Table 2 compares the results of Res-Bp and neural networks (BP). In flight B, Res-Bp reduces STD from 2.334 to 0.260, and IR is 8.977. In flight A, Res-Bp reduces STD from 2.112 to 0.266, and IR is 7.940. Compared with the linear regression method (Table 1), Res-Bp has a stronger compensation ability for complex and nonlinear data. Compared with the neural network, Res-Bp improves the compensation accuracy and fitting ability. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Test Set** & **Training Set** & **Method** & **STD\({}_{\mathbf{u}}\)** & **STD\({}_{\mathbf{c}}\)** & **IR** \\ \hline Flight A & Flight B & LS & 2.171 & 0.355 & 6.115 \\  & & RR & 0.324 & 6.701 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Comparison of compensation results of LS and RR. Figure 6: LS and RR compensation results for flight A.  
Figure 8: BP and Res-Bp compensation results for flight A.  
Figure 7: BP and Res-Bp compensation results for flight B. Because the parameter update is related to the gradient of the loss function, the larger the gradient, the faster the parameter update, which is conducive to the convergence of the network. Figure 9 and the Loss curve (Figure 10a,b) show that the gradient of Res-Bp is larger than that of BP, the convergence speed of Res-Bp is faster than that of BP, and the algorithm is more stable, demonstrating that Res-Bp effectively alleviates the gradient disappearance problem and improves the fitting ability of the network. However, as the network descends along the direction of negative gradient, the principle of weight adjustment is to take the local optimum at each step, leading to the local minimum (Figure 11), and the global optimum solution cannot be obtained. Figure 10 shows that BP and Res-Bp have local minimum values, preventing the network from reaching the expected optimal state, resulting in unstable performance. The decisive coefficient (R\({}^{2}\)) measures the goodness of fit [23] and is expressed as:  
\[R^{2}(y,\;\hat{y})\;=\;1-\frac{\Sigma_{k=1}^{m}y_{k}-\hat{y}_{k}^{2}}{\Sigma_{k= 1}^{m}y_{k}-\overline{y}_{k}^{2}}, \tag{24}\]  
where \(y_{k}\) is the real value, \(\hat{y}_{k}\) is the predicted value, and \(\overline{y}_{k}\) is the mean real value. We used R\({}^{2}\) to measure the performance of the model. The closer R\({}^{2}\) is to 1, the better the fitting degree of the regression line to the real value and the better the model's performance. Therefore, according to the R\({}^{2}\) curve (Figure 10c,d), the fitting degree of Res-Bp is stronger than that of the neural network, and it converges faster.