# Vector Magnetic Anomaly Detection via an Attention Mechanism Deep-Learning Model
## 1 Introduction
In order to eliminate the Earth's magnetism and reject distant external interferences, the reference magnetometer should be away from the target and under the same background noise as the measurement magnetometer. It requires data from both magnetometers before the signal processing. The above methods need the differential signal because they lack focus on the extraction of the overall features and attention to the target change areas. Rapid changing magnetic fields are easier to pick out, and the signals change slowly as the target enters the detection range. In recent years, deep learning has developed rapidly in time-series processing, which provides new techniques for MAD. Recursive Neural Networks (RNNs) [14] can effectively capture features of temporal data, but they have problems in modeling long-term relationships. This problem is solved by introducing long and short-term memory networks, which are special kinds of RNNs. However, LSTM will lead to overfitting when the sequence contains linear relationships or noise. Bi-directional LSTM (BiLSTM) [15] further develops LSTM by combining forward and backward hidden layers, which can utilize information from both directions. Currently, LSTM and BiLSTM have been applied to text classification and other fields. In addition, the Attention Mechanism [16], which is based on the human attention mechanism, was first used in machine translation tasks and has now been extended to various research areas, such as image segmentation. It can obtain weight by calculating the magnitude of the influence of each time point of the input sequence on the output, and the obtained weight can be used in the attribution analysis of the data. Nowadays, it is also widely used with LSTM and CNN to process sequence data in a structure similar to U-Net [17]. This structure has been used in different anomaly detection demands, such as social media [18], marine science [19], and natural language processing [20]. In this study, we introduce a new end-to-end deep-learning model for MAD. An attention mechanism module was incorporated in the model to assist the CNN. This improved the ability to identify the target signal in the input time series. The attention mechanism in deep learning was inspired by human focus patterns. Humans will scan the global environment and focus their attention on a certain area to analyze it when confronted with a complex image. Our model was simulated through two levels of attention mechanisms. One level globally detected the range of possible targets. Another one locally picked up the exact time point when the target appears. The training and detection processes are as follows. First, the network is trained by a training set of computer numerical simulations. Secondly, the model will output the probability of the presence of magnetic anomalies at each time point from the three-component magnetic signal recordings in the field experiment. Finally, the threshold value as needed is selected to help the detection. The main advantages can be summarized as follows:  
1. The observation system is simple because there is no need for another magnetometer to calculate the differential signal. 2. There is no need to make assumptions about geomagnetic noise and record it in advance. Targets can be detected in colored noise with low SNR. 3. The computational cost is mainly concentrated in the model training phase. Due to low computational complexity for practical applications, it is suitable for edge computing and real-time detection.