Magnetic gradient tensor field detection data error identification and labeling method
Through the deep learning Swin Transformer model and gradient analysis method, the qualitative and quantitative identification problems of magnetic gradient tensor field detection data error identification methods are solved, high-precision error identification and visual annotation are achieved, and the magnetic gradient tensor field detection is improved. Error identification accuracy of data.
Patent Information
- Application Number
- CN202410742592.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-06
AI Technical Summary
The existing magnetic gradient tensor field detection data error identification method relies too much on artificial prior knowledge, qualitatively identifies error factors, has low accuracy, and cannot quantitatively identify the proportion of multiple influencing factors and mark the error location.
The Swin Transformer model based on deep learning is used to build an error identification network through a tensor segmentation module, a position information encoding module, multiple Swin Transformer identification modules and error discrimination modules, and combined with the gradient analysis method to achieve quantitative identification and visual annotation of errors.
It improves the accuracy and interpretability of error identification, can quantitatively identify the proportion of various error factors, and marks the error location in a visual form, providing a better reference basis.
Smart Images

Figure CN118606786A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of geophysical exploration, and in particular relates to a method for identifying and marking errors in magnetic gradient tensor field detection data. Background Art
[0002] The geomagnetic field is an inherent physical property of the Earth, reflecting its internal structure and changing patterns. Detecting the geomagnetic field, also known as magnetic prospecting, is a key geophysical exploration method. This method utilizes the localized magnetic anomaly fields formed by magnetic differences among magnetic targets such as rocks and minerals within the geomagnetic field to locate magnetic bodies and infer their structure. This method has widespread application in mineral resource exploration, geoscience research, national defense, and military engineering.
[0003] With the innovation and development of detection methods and instrumentation, the order of observed physical quantities in magnetic exploration has continued to increase, evolving from measuring the total geomagnetic field to measuring the magnetic gradient tensor. The magnetic gradient tensor, the spatial rate of change of the magnetic field vector along the three coordinate axes of a Cartesian coordinate system, is multi-component and directional. Compared to the scalar and vector fields formed by the total field intensity and the three components of the magnetic field, the magnetic gradient tensor generated by a magnetic target is minimally affected by the temporal and spatial influences of the geomagnetic field and is insensitive to attitude angle errors, making it suitable for use on mobile platforms. The magnetic gradient tensor contains more independent components and can provide richer information for in-depth understanding of the Earth, precision exploration, and other research.
[0004] Due to limitations in measurement system accuracy, interference from the launch platform, and the complex and changing flight detection environment, actual magnetic gradient tensor field (MGT) data are susceptible to multiple factors and can result in significant errors. Before data interpretation, the data typically requires processing such as magnetic interference compensation, system error correction, and denoising. Therefore, after acquiring the detection data, it is crucial to quickly analyze the errors and identify the primary error sources. Identifying the primary error sources guides the direction and priority of data processing and verifies the effectiveness of data processing. On the other hand, completing a single detection mission requires significant human, material, and financial resources, and the detection process presents significant safety risks for both personnel and equipment. Error identification can provide a basis for timely adjustments to experimental plans, thereby reducing the number of flights, improving the quality of each detection, and ultimately saving costs and protecting lives and property. However, currently, few methods exist for error identification of MGT data. Existing methods fall into three main categories, all of which have significant limitations.
[0005] The first method uses the controlled variable method and orthogonal experimental design to simulate the influence of various factors and determine their levels. The error percentage of a specific tensor component is then used as an evaluation metric to calculate the variance under various levels. Finally, analysis of variance is used to determine the influence of each factor. This method only simulates the sensitivity of the error percentage of a specific tensor component to various factors and cannot identify errors in actual detection data.
[0006] The second method, primarily applied to gravity sounding data, identifies error factors by designing undulating flight experiments and analyzing the correlation between the bandpass filtering results of the sounding data and various error factors. This method relies on the rationality of the undulating flight experiment design and the requirement that the magnitude of the error in the flight line is significantly greater than the gravity perturbation. It is difficult to ensure that each simulation experiment is consistent with the actual sounding environment and instrument noise level, requiring significant human involvement and prior knowledge.
[0007] The third type of method combines the physical significance of the factors affecting the error of the airborne magnetic gradient tensor to predict a normalized error tensor that can comprehensively reflect the error characteristics of the magnetic gradient tensor. It proposes an error classification model based on a tensor machine and uses a process-based approach to sequentially identify whether the error factors of the magnetic gradient tensor detection data are attitude errors, magnetic interference, or instrument errors. However, this method uses the predicted normalized error tensor to make judgments, and it is impossible to accurately obtain the normalized error tensor for actual magnetic gradient tensor detection data. At the same time, this method can only identify the three main sources of error in the detection data. The identification method is rough and cannot distinguish error factors with similar error expressions, such as hard magnetic interference and zero bias error. Finally, this method can only qualitatively give the error factors, but cannot quantitatively identify the influence of each error factor and mark the error location in a visual form.
[0008] In summary, in addition to their own limitations, most of the existing error identification methods for magnetic gradient tensor detection data can only qualitatively provide the identification results of a single main influencing factor, and cannot quantitatively identify the proportion of multiple influencing factors, nor can they mark the location of the error. Summary of the Invention
[0009] The purpose of this invention is to provide a method for quantitatively identifying and labeling errors in magnetic gradient tensor field detection data. This method addresses the problem that existing methods for identifying errors in magnetic gradient tensor field detection data rely too heavily on artificial prior knowledge, can only qualitatively identify error factors, and suffer from low accuracy. This method achieves quantitative error identification and improves identification accuracy. Based on gradient analysis, this method visually labels error locations, improving the interpretability of the model.
[0010] The purpose of the present invention is achieved through the following technical solutions:
[0011] A method for identifying and labeling errors in magnetic gradient tensor field detection data comprises the following steps:
[0012] Step S1, obtaining magnetic gradient tensor detection data under various influencing factors based on the error data set forward model, solving the difference tensor and performing preprocessing, and dividing the data into training set and test set;
[0013] Step S2: constructing a Swin Transformer error recognition network, wherein the Swin Transformer error recognition network consists of a tensor segmentation module, a position information encoding module, four Swin Transformer recognition modules and an error discrimination module;
[0014] The tensor segmentation module can segment the difference tensor into fixed-size module deviation patches, and project each deviation patch into a vector of fixed length and send it to the subsequent module;
[0015] The position information encoding module position encoding is implemented by a fully connected neural network, which is used to project the tensor of dimension (H / 4×W / 4)×16 to any dimension C, convert the patch token dimension to (H / 4×W / 4)×C, and then feed it into the subsequent module;
[0016] The error discrimination module includes a global average pooling layer and a fully connected layer. It first obtains the output of the fourth SwinTransformer recognition module, then generates a feature map for each category of the error recognition task, takes the average of each feature map, and inputs the result into the fully connected layer to obtain a set of one-dimensional vectors, which are used as the target prediction value for error recognition;
[0017] Step S3: sending the training set to the network for training;
[0018] Step S4: using the trained model to perform magnetic gradient tensor detection data error identification and evaluating the identification results;
[0019] Step S5: complete the error identification result annotation using the gradient analysis method.
[0020] Furthermore, step S1 specifically includes the following steps:
[0021] Step S11: Integrate and simplify the measurement error model affected by the detection environment, the measurement error model of the carrier platform magnetic interference, and the measurement error model of the magnetic gradient tensor measurement component to obtain the magnetic gradient tensor component measurement value M in the navigation coordinate system. lf Survey model of the survey area;
[0022] Step S12: Based on the forward model of the data set, the magnetic gradient tensor detection data under various influencing factors are obtained, and the generalized Hilbert transform and inverse transform are performed on the measurement area data of all magnetic gradient tensor components to convert the measured value tensor into The relative deviation before and after the generalized Hilbert transform is used as the difference tensor to reflect the quality of the detection data.
[0023] Step S13: Reduce the order of the difference tensor to obtain the second-order measurement area difference tensor, and then take the root mean square of the difference of the five independent components at each measurement point in the measurement area to obtain the measurement area difference tensor Indicates the comprehensive difference between each component at each measuring point before and after the generalized Hilbert transform;
[0024] Step S14: Use the forward model in step S11 to generate multiple sets of magnetic gradient tensor detection data, take part of the magnetic gradient tensor detection data as training samples, and use the rest as verification samples.
[0025] Further, in step S2, the four Swin Transformer recognition modules are sequentially a first Swin Transformer recognition module, a second Swin Transformer recognition module, a third Swin Transformer recognition module and a fourth Swin Transformer recognition module;
[0026] Among them, the first Swin Transformer recognition module includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the position information encoding module and is specifically composed of a window multi-head self-attention mechanism layer and a sliding window multi-head self-attention mechanism layer. The Swin Transformer Block does not change the feature dimension, and the output dimension is the same as the input. The feature is input into the downsampling layer, and the downsampling layer reduces the global feature size of the input difference tensor to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of Output results;
[0027] The second Swin Transformer recognition module includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the first Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer. The downsampling layer reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result;
[0028] The third Swin Transformer recognition module includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the second Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer. The downsampling layer reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result;
[0029] The fourth Swin Transformer recognition module includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the third Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer. The downsampling layer reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result is:
[0030] Furthermore, step S4 is specifically as follows: in the magnetic gradient tensor detection data error identification task, the accuracy and recall rate are used to evaluate the classification effect, TP means predicting the positive class as the positive class, TN means predicting the negative class as the negative class, FP means predicting the negative class as the positive class, and FN means predicting the positive class as the negative class.
[0031] Furthermore, step S5 is specifically as follows: using the back propagation of gradients, the gradient information of the high-level feature map is propagated to the low-level feature map, thereby obtaining a visual class activation map, and finally converting the weights into a heat map, highlighting the areas in the input that play a decisive role in the output, and marking the source of the error.
[0032] Compared with the prior art, the present invention has the following beneficial effects:
[0033] Starting from the deep learning method, the present invention proposes a new Swin Transformer magnetic gradient tensor detection data error identification model. The error identification method of the present invention is both scientific and engineering practical. Through the quantitative identification method, the proportion of multiple influencing factors of a detection experiment can be given; it can distinguish error factors with similar error expressions, such as hard magnetic interference and zero bias error, with higher identification accuracy; based on the gradient analysis method, the error position can be marked in a visual form, the interpretability is improved, and a better reference basis is provided for engineering experiment personnel. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0035] Figure 1 Flow chart of the steps of the magnetic gradient tensor field detection data error identification and marking method of the present invention;
[0036] Figure 2 Schematic diagram of the error identification network of the present invention;
[0037] Figure 3 It is a structural diagram of Swin Transformer Block;
[0038] Figure 4 This is the interpretation result of the Swin Transformer model using the gradient analysis method, where: Figure 4 (a) is the difference tensor under the influence of magnetic interference, Figure 4 (b) is the magnetic interference identification result, Figure 4 (c) is the difference tensor under the influence of measurement noise, Figure 4 (d) is the measurement noise identification result, 4(e) is the difference tensor under the influence of instrument error, Figure 4 (f) is the instrument error identification result. DETAILED DESCRIPTION
[0039] The present invention will be further described below in conjunction with embodiment:
[0040] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.
[0041] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are used only to distinguish the description and should not be understood as indicating or implying relative importance.
[0042] Based on deep learning related technologies, the present invention provides a magnetic gradient tensor detection data error identification method based on Swin Transformer. The Swin Transformer model is applied to the magnetic gradient tensor detection data error, which realizes quantitative error identification, improves the recognition accuracy, can mark the error position in a visual form, and improves the model interpretability.
[0043] like Figure 1 As shown, the method for identifying and marking errors in magnetic gradient tensor field detection data of the present invention comprises the following steps:
[0044] Step S1: Based on the error data set forward model, magnetic gradient tensor detection data under various influencing factors are obtained, the difference tensor is solved and preprocessed, and the data is divided into a training set and a test set.
[0045] Step S11: Integrate and simplify the measurement error model affected by the detection environment, the measurement error model of the carrier platform magnetic interference, and the measurement error model of the magnetic gradient tensor measurement component to obtain the magnetic gradient tensor component measurement value M in the navigation coordinate system. lf Survey model of the survey area.
[0046] Step S12: Based on the forward model of the data set, the magnetic gradient tensor detection data under various influencing factors are obtained, and the generalized Hilbert transform and inverse transform are performed on the measurement area data of all magnetic gradient tensor components to convert the measured value tensor into The relative deviation before and after the generalized Hilbert transform is used as the difference tensor to reflect the quality of the detection data.
[0047] Step S13: Reduce the order of the difference tensor to obtain the second-order measurement area difference tensor, and then take the root mean square of the difference of the five independent components at each measurement point in the measurement area to obtain the measurement area difference tensor It represents the comprehensive difference between each component at each measuring point before and after the generalized Hilbert transform.
[0048] Step S14: Use the forward model in step S11 to generate 35,000 sets of magnetic gradient tensor detection data, wherein 80% of the magnetic gradient tensor detection data are used as training samples and 20% of the magnetic gradient tensor detection data are used as verification samples.
[0049] Step S2: Construct a Swin Transformer error recognition network.
[0050] In this embodiment, the Swin Transformer error recognition network consists of a tensor segmentation module, a position information encoding module, four Swin Transformer recognition modules and an error discrimination module, such as Figure 2 shown.
[0051] The tensor segmentation module can segment the difference tensor into modules (deviation patches) of fixed size, and project each deviation patch into a vector of fixed length and send it to the subsequent module.
[0052] The position information encoding module position encoding is implemented by a fully connected neural network, which is used to project the tensor of dimension (H / 4×W / 4)×16 at this time to any dimension C, convert the patch token dimension to (H / 4×W / 4)×C and then feed it into the subsequent module.
[0053] The four Swin Transformer recognition modules are respectively the first Swin Transformer recognition module (Stage1), the second Swin Transformer recognition module (Stage2), the third Swin Transformer recognition module (Stage3), and the fourth Swin Transformer recognition module (Stage4).
[0054] Among them, the first Swin Transformer recognition module (Stage 1) includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the position information encoding module, which is specifically composed of a window multi-head self-attention mechanism (W-MSA) layer and a sliding window multi-head self-attention mechanism (SW-MSA) layer. The Swin Transformer Block does not change the feature dimension, and the output dimension is the same as the input. The feature is input into the downsampling layer, which reduces the global feature size of the input difference tensor to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of Output the results.
[0055] The second Swin Transformer recognition module (Stage 2) includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the first Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer, which reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result is:
[0056] The third Swin Transformer recognition module (Stage 3) includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the second Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer, which reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result is:
[0057] The fourth Swin Transformer recognition module (Stage 4) includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the third Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer, which reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result is:
[0058] The error discrimination module includes a global average pooling layer and a fully connected layer. It first obtains the output of the fourth SwinTransformer recognition module, then generates a feature map for each category of the error identification task. The average of each feature map is then taken and input into the fully connected layer to produce a set of one-dimensional vectors, which serve as the target prediction value for error identification. Global average pooling is a mature existing technology.
[0059] Step S3: Send the training set to the network for training.
[0060] Step S4: Use the trained model to perform error recognition on magnetic gradient tensor detection data and evaluate the recognition results. Accuracy and recall, commonly used in existing techniques, are used to evaluate the classification performance in this task. TP (True Positive) indicates that a positive class is predicted as positive, TN (True Negative) indicates that a negative class is predicted as negative, FP (False Positive) indicates that a negative class is predicted as positive, and FN (False Negative) indicates that a positive class is predicted as negative.
[0061] Step S5: Use a gradient analysis method to complete the error identification result annotation. The core principle is to use the back propagation of gradients to propagate the gradient information of high-level feature maps to low-level feature maps, thereby obtaining a visual class activation map. Finally, the weights are converted into a heat map, highlighting the areas in the input that have a decisive effect on the output and annotating the source of the error.
[0062] like Figure 3 As shown in the figure, the Swin Transformer Block consists of a shifted window MSA module followed by an MLP layer containing GeLU units. Furthermore, a Layer Norm (LN) normalization layer is placed before each shifted window multi-head self-attention module and each fully connected neural network, and residual connections are used between each module. The Swin Transformer Block uses two different architectures, W-MSA and SW-MSA, in sequence, and they need to be used in pairs.
[0063] Example 1
[0064] A method for identifying and labeling errors in magnetic gradient tensor field detection data comprises the following steps:
[0065] Step S1: Based on the error data set forward model, magnetic gradient tensor detection data under various influencing factors are obtained, the difference tensor is solved and preprocessed, and the data is divided into a training set and a test set.
[0066] Step S11: constructing a forward model of the error data set:
[0067] In this embodiment, the data set for magnetic gradient tensor detection data error identification adopts the magnetic gradient tensor measurement area measurement model in the prior art, specifically including: a measurement area error model affected by the detection environment, a measurement area error model of magnetic interference of the carrier platform, and a measurement area error model of the magnetic gradient tensor measurement component.
[0068] By integrating and simplifying the above error models of each measurement area, we can obtain the measured value of the magnetic gradient tensor component M in the navigation coordinate system. lf The measurement model of the survey area is shown in formula (1):
[0069]
[0070] Among them, the fourth-order tensor Each element in represents the linear combination of the error model coefficients of each component at each actual measurement point in the navigation coordinate system. The measured value of each magnetic gradient tensor component in the survey area can be expressed as a linear combination of the true value of all components, measurement point offset error, magnetic interference, instrument error, and measurement noise.
[0071] Step S12: using the difference tensor reflecting the quality of the magnetic gradient tensor data:
[0072] It is known from the existing technology that the components of the magnetic gradient tensor field have the property of expressing each other. By performing generalized Hilbert transform and inverse transform on the measurement area data of all magnetic gradient tensor components, a new magnetic gradient tensor field calculation value can be obtained, which is expressed as a fourth-order tensor Theoretically, if the detection process satisfies the nearly ideal conditions of the generalized Hilbert transform, that is, the sampling points are dense enough, the measuring points are in the same plane, and the detection area is large enough so that the magnetic field value at the edge of the measurement area decays to zero, then the true value of the magnetic gradient tensor field without error is Calculated value Should still be equal to the true value However, for actual detection data, since it cannot meet the nearly ideal conditions of the generalized Hilbert transform and various errors or magnetic interferences are inevitable, the above-mentioned mutual transformation expressions between components cannot be satisfied. The relative deviation before and after the generalized Hilbert transform is defined as the difference tensor, which is expressed as a fourth-order tensor See formula (2):
[0073]
[0074] in, Represents element-wise division of two tensors.
[0075] This embodiment utilizes the property that the difference tensor includes the influence of multiple error factors and can reflect the quality of the detection data, and trains a deep learning model based on the difference tensor data under the influence of different influencing factors.
[0076] Step S13: Data preprocessing:
[0077] Considering that graphical analysis of the difference tensor according to the measurement area can provide more abundant information for error identification, it is necessary to first reduce the order of the fourth-order difference tensor to obtain the second-order measurement area difference tensor. Calculate the difference of each magnetic gradient tensor component measurement area data See formula (3):
[0078]
[0079] in, represents the measured value of a certain magnetic gradient tensor component in the survey area, Represents the measured value of a magnetic gradient tensor component obtained by generalized Hilbert transform, the second-order tensor The component is represented by d ij,mn .
[0080] Then, the root mean square of the differences of the five independent components at each measuring point in the measuring area is taken to obtain the measuring area difference tensor: The element form of its definition is shown in formula (4). Each element in It represents the comprehensive difference between each component at each measuring point before and after the generalized Hilbert transform.
[0081]
[0082] Step S14: Based on the above steps, construct a measurement area difference tensor for different random influencing factor categories (Classes I-VII) and different interference levels (Levels I-V). The influencing factor categories mainly include instrument error, magnetic interference, measurement point offset error, attitude error, measurement noise, undersampling, and truncation. The higher the interference level, the higher the weight of the factor in the measurement model, and the greater the impact on the detection data.
[0083] The forward model in step S11 is used to generate 35,000 sets of difference tensor data, of which 80% are used as training samples and 20% are used as validation samples. Subsequently, the survey area difference tensor data is reorganized into a tensor data format. This conversion involves rearranging and reconstructing the original data to facilitate processing in a deep learning framework (such as PyTorch, Tensorflow). Specifically, each sample in the original data is expanded by one dimension. For the survey area difference tensor, which is a second-order tensor matrix of size (m,n), it is converted into a third-order tensor of size (m,n,1). The data is reorganized in a higher dimension so that the model can better understand and utilize the structural information in the survey area difference data.
[0084] Step S2: Construct a Swin Transformer error recognition network.
[0085] In this embodiment, the magnetic gradient tensor detection data error identification network adopts the Swin Transformer model. The Swin Transformer introduces the hierarchical structure of the convolutional neural network, and processes the difference tensor in layers. The basic units (patches) of each layer need to be re-divided into different sizes. Each layer only calculates local self-attention, reducing the amount of calculation from the square relationship of the measurement area size to a linear relationship, thereby improving the recognition and inference speed of the model.
[0086] In this embodiment, the Swin Transformer error identification network consists of a tensor segmentation module, a position information encoding module, four Swin Transformer identification modules, and an error discrimination module. The four Swin Transformer extraction modules are the first Swin Transformer identification module (Stage 1), the second Swin Transformer identification module (Stage 2), the third Swin Transformer identification module (Stage 3), and the fourth Swin Transformer identification module (Stage 4).
[0087] Tensor segmentation module: Assume that the size of the difference tensor of the measurement area is H×W×1, and divide the difference tensor into fixed-size modules (deviation patches). The size of each deviation patch is P×P (to facilitate the description of the calculation principle, let P=4), then each difference tensor will generate deviation patch, that is, the input sequence length is Each deviation patch is projected into a fixed-length vector and fed into the Transformer. Its dimension is 4×4=16, so the dimension of the linear projection layer is That is, a total of tokens.
[0088] Positional Information Encoding Module: Positional encoding is added to the segmented sub-tensors before they are input into the Swin Transformer. Positional encoding is implemented using a fully connected neural network, which can be abstracted as a table structure with N rows, where N is the same as the length of the input sequence. Each row of the table represents a vector of dimension C. The positional information encoding module projects the tensor, which is currently of dimension (H / 4 × W / 4) × 16, onto any dimension C, converting the patch token dimension to (H / 4 × W / 4) × C before inputting it into the Swin Transformer block.
[0089] The first Swin Transformer recognition module (Stage 1) includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block takes the output of the position information encoding module and consists of a windowed multi-head self-attention mechanism (W-MSA) layer and a sliding window multi-head self-attention mechanism (SW-MSA) layer. The Swin Transformer Block does not change the feature dimension; the output dimension is the same as the input.
[0090] The features are input into the downsampling layer, which reduces the input difference tensor global feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of Output the results.
[0091] The second Swin Transformer recognition module (Stage 2) includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the first Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer, which reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result is:
[0092] The third Swin Transformer recognition module (Stage 3) includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the second Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer, which reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result is:
[0093] The fourth Swin Transformer recognition module (Stage 4) includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the third Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer, which reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result is:
[0094] The error discrimination module includes a global average pooling layer and a fully connected layer. Global average pooling is a pooling operation that first obtains the output of the fourth Swin Transformer recognition module. It then generates a feature map for each category in the error recognition task. The average of each feature map is then taken and the result is input into the fully connected layer, resulting in a set of one-dimensional vectors. The value of the vector represents the probability distribution of the magnetic gradient tensor detection data error and serves as the target prediction value for error recognition. Global average pooling is a mature existing technology.
[0095] Figure 1 The overall network structure of the Swin Transformer is demonstrated, constructing four stages, each composed of similar repeating unit modules. First, the input area difference tensor of size (H×W×1) is split into non-overlapping 4×4 patches using the tensor splitting module. The feature dimension of each patch after expansion is P×P×1=16, with a total of N=H / 4×W / 4=HW / 16 patch tokens, which serves as the effective input sequence length of the Swin Transformer.
[0096] The position information encoding module is composed of a fully connected neural network. Its function is to project the tensor of dimension (H / 4×W / 4)×16 to any dimension C, convert the patch token dimension to (H / 4×W / 4)×C, and then input it into the SwinTransformer block, as shown in the following example: Figure 2 As shown. The Swin Transformer block replaces the standard multi-head self-attention module (MSA) with a shift window-based multi-head self-attention module (W-MSA / SW-MSA). A Swin Transformer block consists of a shift window-based MSA module, followed by an MLP layer containing GeLU units. At the same time, a Layer Norm (LN) normalization layer is placed before each shift window-based multi-head self-attention module and each fully connected neural network, and residual connections are used between each module. The Swin Transformer block needs to use two different architectures, W-MSA and SW-MSA, in sequence, and needs to be used in pairs.
[0097] The first Swin Transformer block maintains the number of input and output tokens at H / 4×W / 4, and is combined with the position information encoding module to form Stage 1. As the number of network layers increases, the number of tokens decreases due to the merging of patch merging layers. The first patch merging layer and the second Swin Transformer block are combined into Stage 2. By connecting adjacent 2×2 patches, a new patch token is formed. The number of tokens becomes 1 / 4 of the original, while the dimension is expanded to four times the original, that is, 4C. Next, a linear layer is used for downsampling, reducing the output features to one-half, and then the Swin Transformer block is used for feature extraction.
[0098] The same process as in Stage 2 is repeated twice in Stage 3 and Stage 4, respectively. Each stage changes the dimension of the disparity tensor, thus achieving a hierarchical extraction process. The downsampling operation in the patch merging layer uses local tensor concatenation. Unlike the pooling layer in convolutional neural networks, this method reduces computational overhead by adjusting the number of channels. Assuming an 8×8 measurement area disparity tensor input, i.e., eight measurement lines with eight measurement points on each line, the patch merging layer first divides it into four 4×4 patches using alternate point sampling. Then, tensor values at the same position in each patch are concatenated depthwise. The resulting concatenated feature map becomes one-quarter the size of the original feature map and four times the dimension. This achieves both downsampling and upscaling of the disparity tensor feature map. After the Swin Transformer block in Stage 4 completes, a global average pooling layer and a fully connected layer are used to obtain the error recognition result.
[0099] The whole process can be described as:
[0100]
[0101]
[0102]
[0103]
[0104] in, and zl represent the output features and input features of the lth module respectively, W-MSA and SW-MSA represent two different types of multi-head self-attention modules. For each Swin Transformer module, W-MSA and SW-MSA are used alternately.
[0105] The most significant feature of the Swin Transformer error recognition network is its flexible selection of W-MSA and SW-MSA. These two methods leverage local prior knowledge to focus attention only on the data features within the window, thereby reducing computational effort. SW-MSA, through a sliding window approach, fosters greater connections between multiple windows. While W-MSA calculations typically occur within a single window, this shift allows for information exchange between adjacent windows, providing a more comprehensive view of the entire disparity tensor feature map while reducing computational effort.
[0106] W-MSA also significantly reduces the computational complexity of MSA. Assuming the depth is C, the size of the feature map is h×w, and the width and height of the window are both M, the computational complexity of W-MSA and MSA can be expressed as:
[0107] Ω(WMSA)=4hwC 2 +2M 2 hwC (9)
[0108] Ω(MSA)=4hwC 2 +2(hw) 2 C (10)
[0109] It can be seen that the computational complexity of MSA increases exponentially with the increase of feature map size, while the computational complexity of W-MSA increases linearly with the increase of feature map size. Compared with MSA, it can effectively reduce the amount of calculation, especially when the input data size is large. Using W-MSA can greatly improve the computational efficiency.
[0110] Step S3: Send the training set to the network for training.
[0111] The Swin Transformer model was implemented using the existing PyTorch framework. The Adam method was used as the optimizer to update network parameters. Two exponential decay rates were set to 0.9 and 0.999, respectively. The initial learning rate was set to 0.0001, and the batch size was set to 8. Seven error categories were considered, primarily including instrument error, magnetic interference, point offset error, attitude error, measurement noise, undersampling, and truncation error. Model training was performed using an NVIDIA GeForce RTX4080 (16GB). The experimental hardware configuration used was an Intel Core i7-11700 @ 2.5GHz processor, developed in Windows 10. The experimental environment configuration is shown in Table 1.
[0112] Table 1 Experimental environment configuration
[0113]
[0114] Step S4: Use the trained model to perform magnetic gradient tensor detection data error identification and evaluate the identification results.
[0115] In the magnetic gradient tensor detection data error identification task, accuracy and recall are used to evaluate the classification effect. TP (True Positive) indicates that a positive class is predicted as positive, TN (True Negative) indicates that a negative class is predicted as negative, FP (False Positive) indicates that a negative class is predicted as positive, and FN (False Negative) indicates that a positive class is predicted as negative.
[0116] The accuracy rate represents the ratio of positive samples to total predicted samples, see formula (11).
[0117]
[0118] The recall rate indicates the proportion of positive samples that are correctly predicted by the classifier, see formula (12).
[0119]
[0120] The cross-entropy loss function is used to measure the accuracy by comparing the class probability predicted by the model with the probability distribution of the true label. The calculation formula of the cross-entropy loss function is as follows:
[0121]
[0122] Step S5: complete error identification result annotation and model interpretation based on the gradient analysis method.
[0123] While deep learning models offer excellent performance, they also have limitations. Their model analysis and reasoning processes are like black boxes. Due to their lack of interpretability, researchers are unable to fully analyze their mechanisms, gain a deep understanding of their decision-making basis, and implement targeted improvements and optimizations. Therefore, conducting interpretability research on error identification models for magnetic gradient tensor detection data plays a crucial role in improving detection efficiency and quality.
[0124] Based on the identification of error factors, this embodiment further studies the error annotation method (i.e., SwinTransformer model interpretability). Its core principle is to use gradient backpropagation to propagate the gradient information of high-level feature maps to low-level feature maps, thereby obtaining a visual class activation map, which realizes the visualization of the Transformer model. The visualization method of this embodiment uses class activation maps to show the importance of the input (difference tensor) difference tensor to the output (error category). The information exchange process between the W-MAS and SW-MSA shift windows is used to backpropagate the gradient from high-level to low-level. Finally, the weights are converted into a heat map, highlighting the areas in the input that play a decisive role in the output and annotating the sources of error.
[0125] For each feature map A k , weight The calculation formula is:
[0126]
[0127] in, Represents the tensor value at the i-th row and j-th column position of the k-channel feature map, y c Represents the output function of error category c. Using the back propagation of gradients, we find the gradient of the output function for each element in the feature map and calculate the mean of the gradient of this feature map. Then, we get the class activation map:
[0128]
[0129] The ReLU function is an existing technology that plays a role in linear rectification. Since we are only interested in areas that have a positive impact on the target classification in error identification, we use the ReLU function to remove eigenvalues that have a negative impact on the classification score. The specific formula is as follows:
[0130]
[0131] The interpretation results of the Swin Transformer model using the gradient analysis method are as follows Figure 4 As shown. Figure 4 (a) is the difference tensor under the influence of magnetic interference, Figure 4 (b) is the magnetic interference identification result. The model mainly focuses on the multi-magnetic dipole interference characteristics in the central area. Figure 4 (c) is the difference tensor under the influence of measurement noise, Figure 4 (d) is the measurement noise recognition result. The model mainly focuses on the jagged edge parts under measurement noise interference. Figure 4 (e) is the difference tensor under the influence of instrument error, Figure 4(f) shows the instrument error identification result. The model primarily focuses on the shape of the center area. The results demonstrate that the error annotation method proposed in this example can maximize the focus on the measurement area affected by the target factor, suppress irrelevant information such as background information, and reasonably explain the decisions made by the Swin Transformer model during error analysis.
[0132] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for identifying and marking errors in magnetic gradient tensor field detection data, characterized in that: The following steps are involved: Step S1, based on the error data set forward model, obtain the magnetic gradient tensor detection data under various influencing factors, solve the difference tensor and perform preprocessing, and divide the training set and the test set; Step S2, constructing a Swin Transformer error recognition network, wherein the Swin Transformer error recognition network consists of a tensor segmentation module, a position information encoding module, four Swin Transformer recognition modules and an error discrimination module; The tensor segmentation module can segment the difference tensor into fixed-size module deviation patches, and project each deviation patch into a vector of fixed length and send it to the subsequent module; The position information encoding module position encoding is implemented by a fully connected neural network, which is used to project the tensor with a dimension of (H / 4×W / 4)×16 to any dimension C, convert the patch token dimension to (H / 4×W / 4)×C, and then send it to the subsequent module; The error discrimination module includes a global average pooling layer and a fully connected layer. The output of the fourth Swin Transformer recognition module is first obtained, and then a feature map is generated for each category of the error recognition task. The average value of each feature map is taken and the result is input into the fully connected layer to obtain a set of one-dimensional vectors, which are used as the target prediction value of error recognition. Step S3, sending the training set to the network for training; Step S4, using the trained model to perform magnetic gradient tensor detection data error identification and evaluating the identification result; Step S5: complete the error identification result labeling using the gradient analysis method.
2. A method for identifying and labeling errors in magnetic gradient tensor field detection data according to claim 1, characterized in that: Step S1 specifically includes the following steps: Step S11: Integrate and simplify the measurement error model affected by the detection environment, the measurement error model of the magnetic interference of the carrier platform, and the measurement error model of the magnetic gradient tensor measurement component to obtain the magnetic gradient tensor component measurement value M in the navigation coordinate system. lf The survey model of the survey area; Step S12: Based on the forward model of the data set, the magnetic gradient tensor detection data under various influencing factors are obtained, and the measurement area data of all magnetic gradient tensor components are subjected to generalized Hilbert transformation and inverse transformation to obtain the measured value tensor. The relative deviation before and after the generalized Hilbert transform is used as the difference tensor to reflect the quality of the detection data. Step S13: Reduce the order of the difference tensor to obtain a second-order measurement area difference tensor, and then take the root mean square of the difference of the five independent components at each measurement point in the measurement area to obtain the measurement area difference tensor It represents the comprehensive difference between each component at each measuring point before and after the generalized Hilbert transform; Step S14: Use the forward model in step S11 to generate multiple sets of magnetic gradient tensor detection data, take part of the magnetic gradient tensor detection data as training samples, and use the rest as verification samples.
3. The method for error identification and labeling of magnetic gradient tensor field detection data according to claim 1, characterized in that: In step S2, the four Swin Transformer recognition modules are a first Swin Transformer recognition module, a second Swin Transformer recognition module, a third Swin Transformer recognition module and a fourth Swin Transformer recognition module in sequence; Among them, the first Swin Transformer recognition module includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the position information encoding module, which is specifically composed of a window multi-head self-attention mechanism layer and a sliding window multi-head self-attention mechanism layer. The Swin Transformer Block does not change the feature dimension, and the output dimension is the same as the input. The feature is input into the downsampling layer, and the downsampling layer reduces the global feature size of the input difference tensor to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of Output the result; The second Swin Transformer recognition module includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the first Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer. The downsampling layer reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result of The third Swin Transformer recognition module includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the second Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer. The downsampling layer reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result of The fourth Swin Transformer recognition module includes a Swin Transformer Block and a downsampling layer. The Swin Transformer Block obtains the output of the third Swin Transformer recognition module without changing the feature dimension. The output dimension is the same as the input. The feature is input into the downsampling layer. The downsampling layer reduces the feature size to the input size. At the same time, the number of channels is increased to twice the input size, resulting in a size of The output result is:
4. The method for error identification and labeling of magnetic gradient tensor field detection data according to claim 1, characterized in that: Step S4, specifically: using accuracy and recall to evaluate the classification effect in the magnetic gradient tensor detection data error identification task, TP means predicting the positive class as the positive class, TN means predicting the negative class as the negative class, FP means predicting the negative class as the positive class, and FN means predicting the positive class as the negative class.
5. The method for error identification and annotation of magnetic gradient tensor field detection data according to claim 1, characterized in that: Step S5 is as follows: using the back propagation of gradients, the gradient information of the high-level feature map is propagated to the low-level feature map, thereby obtaining a visualized class activation map, and finally converting the weights into a heat map, highlighting the areas in the input that play a decisive role in the output, and marking the source of the error.
Citation Information
Cited By
Transform-based array magnetic field data error correction method and apparatus, and computer device
CN120180939A
Transformer-Based Array Magnetic Field Data Error Correction Method, Device, and Computer Equipment
CN120180939B
Data processing method and device, processor, electronic equipment and storage medium
CN120317289A
Distribution network line facility defect detection method based on line magnetic field variable characteristics
CN120522512A
Oil and gas block evaluation method and system based on two-factor model, and storage medium
CN121958916A
