# An Aeromagnetic Compensation Algorithm Based on a Residual Neural Network
## 2 Compensation Model and Method
### Res-Bp  
To address the problem of gradient disappearance in the aeromagnetic compensation process of the neural network, we introduce the idea of residual connection and propose an algorithm with strong fitting ability, Res-Bp. The core of residual connection is the data fusion of nonlinear and linear features [18]. In forward propagation, the input signal can be directly propagated from any low level to a high level and has identity-mapping ability. As shown in Figure 1, the residual connection has an identity-mapping structure compared to the ordinary connection. That is, the output (\(Z^{l}\)) of a layer is added to the new information (\(F(Z^{l})\)) of the layer after nonlinear transformation, and the sum result is input into the activation function as the output of the next layer. In the process of forward propagation, assuming that \(f\)\((\cdot)\) is a linear activation function, the features of layer \(L\) are:  
\[Z^{L}{=}\ F\ \big{(}F\ \left(\ldots F\ \Big{(}Z^{l},W^{l}\Big{)}\right)\big{)}. \tag{16}\]  
\[Z^{L}{=}\ Z^{l}+\sum_{i=l}^{L-1}\ F\ \Big{(}Z^{i},W^{i}\Big{)}, \tag{17}\]where \(F\) represents the nonlinear transformation function. Equations (16) and (17) represent the training process from layer \(l\) to layer \(L\) in the forward propagation process of ordinary and residual connections, respectively. Residual connection layer \(L\) can be expressed as the sum of any layer \(l\) (\(L>l\)) and the residual parts between them, which shows that the residual network always retains the original information in the process of training and obtains new information in the network. The training of an ordinary connection from layer \(l\) to layer \(L\) can only be formed through the training iteration of each layer between them. When the dimensions of input \(Z^{l}\) and output \(Z^{L}\) are inconsistent, a weight (\(W^{\prime}\)) is necessary to adjust the dimension of \(Z^{l}\) to attain consistency. It realizes the residual operation of tensors between different dimensions and jumps out of the limitation of dimensions. It is expressed as:  
\[Z^{L}=W^{\prime}Z^{l}+\sum_{i=l}^{L-1}\ F\Big{(}Z^{i},W^{i}\Big{)}. \tag{18}\]  
In the process of backpropagation, the gradient of loss to \(Z^{l}\) is:  
\[\frac{\alpha loss}{\alpha Z^{l}}=\frac{\alpha loss}{\alpha Z^{L}}.\frac{\alpha Z ^{L}}{\alpha Z^{l}}=\frac{\alpha loss}{\alpha Z^{L}}.\frac{\alpha Z^{L}}{ \alpha Z^{L-1}}.\dots\frac{\alpha Z^{l+1}}{\alpha Z^{l}} \tag{19}\]  
\[ \begin{array}{c}\frac{\alpha loss}{\alpha Z^{l}}=\frac{\alpha loss}{\alpha Z ^{L}}\frac{\alpha Z^{L}}{\alpha Z^{L}}=\frac{\alpha loss}{\alpha Z^{L}}\left( 1+\frac{\alpha\sum_{i=l}^{L-1}\ F(Z^{i};W^{i})}{\alpha Z^{L}}\right)\\ =\frac{\alpha loss}{\alpha Z^{L}}+\frac{\alpha loss}{\alpha Z^{L}}\frac{\alpha \sum_{i=l}^{L-1}\ F(Z^{i};W^{i})}{\alpha Z^{L}}.\end{array}  \tag{20}\]  
Equations (19) and (20) represent the gradient process of finding loss function pair parameters in the backpropagation process of ordinary and residual connections, respectively. When the residual connection is backpropagation, the high-level information can be directly propagated to the low level without the transformation of the intermediate weight matrix [19]. Even if there is gradient attenuation between layers \(L\) and \(l\), the gradient of layer \(L\) can still be directly transmitted to layer \(l\), realizing the cross-layer propagation of the gradient, which can solve the problem of gradient disappearance and improve the accuracy of aeromagnetic compensation. When ordinary connections are backpropagating,  
Figure 1: Connection mode of a neural network: (**a**) ordinary connected structure; (**b**) residual connected structure. gradient information cannot be effectively propagated to the lower layer, so the gradient disappears. In this paper, the T-L equation is used as the coefficient matrix \((X_{nx18}\), where \(n\) is the sample size) and as the input parameter of the neural network model. The total (\(y_{n}\)= \(H_{tn}\)) magnetic interference field is used as the output parameter of the model.