Transformer-Based Array Magnetic Field Data Error Correction Method, Device, and Computer Equipment

Through the array magnetic field data error correction method based on Transformer, the error optimization model is trained using magnetic gradient tensor reconstruction loss, rotation invariance loss and smoothness loss, which solves the problem of poor error optimization accuracy in traditional magnetic anomaly detection, and achieves higher magnetic gradient tensor accuracy.

CN120180939BActive Publication Date: 2025-07-22TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510655343.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2025-07-22
Estimated Expiration
2045-05-21

AI Technical Summary

Technical Problem

In traditional magnetic anomaly detection technology, the nonlinear equations based on the magnetometer array structure are complex and the magnetic gradient tensor matching poorly, resulting in multiple collinearity in the magnetic gradient tensor error optimization, affecting the accuracy of the optimization results.

Method used

The array magnetic field data error correction method based on Transformer is adopted, and the target loss function composed of loss, rotation invariance loss and smoothness loss is reconstructed by acquiring the magnetic field data and error optimization model, and dynamic error compensation and data mapping are performed to realize the mapping of magnetic field data to the target magnetic gradient tensor.

Benefits of technology

The complexity of parameter mapping in error analysis is reduced, redundant features are suppressed, and the risk of multicollinearity is avoided, and the accuracy of the target magnetic gradient tensor is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120180939B_ABST
    Figure CN120180939B_ABST
Patent Text Reader

Abstract

This application relates to a method, device, and computer equipment for error correction of array magnetic field data based on Transformer. The method includes: obtaining magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss; inputting the magnetic field data into the error optimization model, and performing dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism and non-linear mapping relationship of the error optimization model to obtain the target magnetic gradient tensor. Using this method can improve the accuracy of the target magnetic gradient tensor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of magnetic anomaly detection, and particularly to a method, device, and computer device for correcting errors in array magnetic field data based on Transformer. Background Art

[0002] With the development of sensors and algorithms, the application of magnetic anomaly detection (MAD) technology in pipeline positioning, unexploded ordnance detection, etc. has become increasingly mature.

[0003] In traditional technologies, magnetic field data and rotation data are collected by a triaxial magnetometer of a symmetric cube array, and an initial magnetic gradient tensor (MGT) is calculated based on the magnetic field data. Using the rotation invariance constraint and multiple sets of rotation data, a non-linear equation based on the physical characteristics of the magnetometer array structure is constructed, and the initial magnetic gradient tensor is error-compensated and optimized through the Levenberg-Marquardt (LM) algorithm and the non-linear equation to obtain the target magnetic gradient tensor.

[0004] However, in the current traditional technologies, due to the complexity of the non-linear equation based on the physical characteristics of the magnetometer array structure and the poor matching between the magnetic gradient tensor and the non-linear equation, there is multicollinearity in the error optimization for the magnetic gradient tensor, resulting in poor accuracy of the optimization results. Summary of the Invention

[0005] Based on this, it is necessary to provide a method, device, and computer device for correcting errors in array magnetic field data based on Transformer for the above technical problems.

[0006] In a first aspect, the present application provides a method for correcting errors in array magnetic field data based on Transformer, including:

[0007] Obtain magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss;

[0008] Input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism of the error optimization model and the non-linear mapping relationship to obtain the target magnetic gradient tensor.

[0009] In one embodiment, before obtaining the magnetic field data and the error optimization model, the method further includes:

[0010] Obtain a sample data set and an initial error optimization model to be trained; the sample data set includes a first sample data set and a second sample data set, the first sample data set includes first sample magnetic field data and first sample target magnetic gradient tensors under various environmental conditions; the second sample data set includes second sample magnetic field data and second sample target magnetic gradient tensors corresponding to adjacent time points;

[0011] Respectively input the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model, perform dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model, and obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor;

[0012] Determine the target loss of the initial error optimization model according to the first intermediate target magnetic gradient tensor, the second intermediate target magnetic gradient tensor, the first sample target magnetic gradient tensor and the second sample target magnetic gradient tensor;

[0013] In the case that the target loss does not meet the preset loss condition, adjust the model parameters of the initial error optimization model, and repeat the step of respectively inputting the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model, performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model, and obtaining a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor until the target loss meets the preset loss condition, and obtain a trained error optimization model.

[0014] In one embodiment, the determining the target loss of the initial error optimization model according to the first intermediate target magnetic gradient tensor, the second intermediate target magnetic gradient tensor, the first sample target magnetic gradient tensor and the second sample target magnetic gradient tensor includes:

[0015] Determine the magnetic gradient tensor reconstruction loss of the initial error optimization model based on the first sample target magnetic gradient tensor and the first intermediate target magnetic gradient tensor;

[0016] Determine the rotation invariance loss of the initial error optimization model based on the first intermediate target magnetic gradient tensor obtained by optimizing the error of the sample magnetic field data of magnetic sensors with different rotation angles and the first sample target magnetic gradient tensor corresponding to the first sample magnetic field data;

[0017] Determine the smoothness loss of the initial error optimization model based on the second intermediate target magnetic gradient tensor and the second sample target magnetic gradient tensor corresponding to the second sample magnetic field data of adjacent time series;

[0018] Construct the objective loss of the initial error optimization model based on the magnetic gradient tensor reconstruction loss, the rotation invariance loss, and the smoothness loss.

[0019] In one embodiment, when the objective loss does not meet the preset loss condition, adjust the model parameters of the initial error optimization model, and repeat the step of inputting the sample magnetic field data into the initial error optimization model, performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain the intermediate target magnetic gradient tensor, until the objective loss meets the preset loss condition. After obtaining the trained error optimization model, the method further includes:

[0020] Perform knowledge distillation on the trained error optimization model according to the knowledge distillation strategy to obtain a lightweight error optimization model.

[0021] In one embodiment, the step of inputting the magnetic field data into the error optimization model, performing dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism and the non - linear mapping relationship of the error optimization model to obtain the target magnetic gradient tensor includes:

[0022] Input the magnetic field data into the error optimization model, extract features from the magnetic field data according to the error optimization model to obtain the first feature vectors under multiple feature dimensions corresponding to the magnetic field data;

[0023] Allocate weights to the feature dimensions according to the attention mechanism to obtain the attention weight matrix corresponding to the first feature vectors;

[0024] Perform dynamic error compensation and data mapping on the first feature vectors based on the attention weight matrix and the non - linear mapping relationship to obtain the target magnetic gradient tensor.

[0025] In one embodiment, the step of performing dynamic error compensation and data mapping on the first feature vectors based on the attention weight matrix and the non - linear mapping relationship to obtain the target magnetic gradient tensor includes:

[0026] Based on the attention weight matrix and the non - linear mapping relationship, determine the error parameters corresponding to the magnetic field data, and perform error compensation on the first feature vectors based on the error parameters to obtain the second feature vectors;

[0027] Perform data mapping on the second feature vectors to obtain the target feature vectors corresponding to the target magnetic gradient tensor;

[0028] Decode the target feature vectors to obtain the target magnetic gradient tensor.

[0029] In a second aspect, the present application further provides an array magnetic field data error correction device based on a Transformer, including:

[0030] A first acquisition module, configured to acquire magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and a target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss;

[0031] An error optimization module, configured to input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism of the error optimization model and the non-linear mapping relationship to obtain the target magnetic gradient tensor.

[0032] In one embodiment, the device further includes:

[0033] A second acquisition module, configured to acquire a sample data set and an initial error optimization model to be trained; the sample data set includes a first sample data set and a second sample data set, the first sample data set includes first sample magnetic field data and first sample target magnetic gradient tensors under various environmental conditions; the second sample data set includes second sample magnetic field data and second sample target magnetic gradient tensors corresponding to adjacent time points;

[0034] An inference module, configured to respectively input the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model, and perform dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor;

[0035] A loss calculation module, configured to determine the target loss of the initial error optimization model according to the first intermediate target magnetic gradient tensor, the second intermediate target magnetic gradient tensor, the first sample target magnetic gradient tensor, and the second sample target magnetic gradient tensor;

[0036] A parameter adjustment module, configured to, when the target loss does not meet a preset loss condition, adjust the model parameters of the initial error optimization model, and repeat the step of respectively inputting the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model, and performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor until the target loss meets the preset loss condition to obtain a trained error optimization model.

[0037] In one embodiment, the loss calculation module is specifically configured to determine the magnetic gradient tensor reconstruction loss of the initial error optimization model based on the first sample target magnetic gradient tensor and the first intermediate target magnetic gradient tensor;

[0038] Based on the first intermediate target magnetic gradient tensor obtained by optimizing the error of the sample magnetic field data of magnetic sensors at different rotation angles, and the first sample target magnetic gradient tensor corresponding to the first sample magnetic field data, determine the rotation invariance loss of the initial error optimization model;

[0039] Based on the second intermediate target magnetic gradient tensor and the second sample target magnetic gradient tensor corresponding to the second sample magnetic field data of adjacent time series, determine the smoothness loss of the initial error optimization model;

[0040] Construct the target loss of the initial error optimization model according to the magnetic gradient tensor reconstruction loss, the rotation invariance loss and the smoothness loss.

[0041] In one embodiment, the parameter adjustment module is specifically configured to perform knowledge distillation on the trained error optimization model according to the knowledge distillation strategy to obtain a lightweight error optimization model.

[0042] In one embodiment, the error optimization module is specifically configured to input the magnetic field data into the error optimization model, extract features from the magnetic field data according to the error optimization model, and obtain the first feature vectors under multiple feature dimensions corresponding to the magnetic field data;

[0043] Allocate weights to the feature dimensions according to the attention mechanism to obtain the attention weight matrix corresponding to the first feature vectors;

[0044] Perform dynamic error compensation and data mapping on the first feature vectors based on the attention weight matrix and the non-linear mapping relationship to obtain the target magnetic gradient tensor.

[0045] In one embodiment, the error optimization module is specifically configured to determine the error parameters corresponding to the magnetic field data based on the attention weight matrix and the non-linear mapping relationship, and perform error compensation on the first feature vectors based on the error parameters to obtain second feature vectors;

[0046] Perform data mapping on the second feature vectors to obtain the target feature vectors corresponding to the target magnetic gradient tensor;

[0047] Decode the target feature vectors to obtain the target magnetic gradient tensor.

[0048] In a third aspect, the present application also provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0049] Obtain magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss;

[0050] Input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism of the error optimization model and the non-linear mapping relationship to obtain the target magnetic gradient tensor.

[0051] In a fourth aspect, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0052] Obtain magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss;

[0053] Input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism of the error optimization model and the non-linear mapping relationship to obtain the target magnetic gradient tensor.

[0054] In a fifth aspect, the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the following steps are implemented:

[0055] Obtain magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss;

[0056] Input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism of the error optimization model and the non-linear mapping relationship to obtain the target magnetic gradient tensor.

[0057] The above-mentioned Transformer-based array magnetic field data error correction method, device, and computer device obtain magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss; input the magnetic field data into the error optimization model, and according to the attention mechanism and non-linear mapping relationship of the error optimization model, perform dynamic error compensation and data mapping on the magnetic field data to obtain the target magnetic gradient tensor. By adopting this method, the complexity of parameter mapping in error analysis is reduced by modeling the non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor. At the same time, the attention mechanism can screen the features of the collected data, realize the suppression of redundant features, and effectively avoid the risk of multicollinearity. And training the error optimization model with an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss can avoid the influence of the multicollinearity risk on error compensation during the data mapping and dynamic error compensation of the magnetic field data, making the target magnetic gradient tensor after error correction closer to the true value, thereby improving the accuracy of the target magnetic gradient tensor. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] To more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments of the present application or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.

[0059] Figure 1 It is an application environment diagram of the Transformer-based array magnetic field data error correction method in an embodiment;

[0060] Figure 2 It is a schematic diagram of a regular tetrahedron magnetometer array in an embodiment;

[0061] Figure 3 It is a schematic flowchart of error optimization for magnetic field data in an embodiment;

[0062] Figure 4 It is a schematic flowchart of training an error optimization model in an embodiment;

[0063] Figure 5 It is a schematic flowchart of model inference of an error optimization model during training in an embodiment;

[0064] Figure 6 It is a schematic flowchart of calculating the target loss in an embodiment;

[0065] Figure 7 A schematic flow chart of knowledge distillation for the trained error optimization model in one embodiment;

[0066] Figure 8 A schematic flow chart of the error optimization model for optimizing the magnetic field data in one embodiment;

[0067] Figure 9 A schematic flow chart of model inference based on attention weights and non - linear mapping relationships in one embodiment;

[0068] Figure 10 A structural block diagram of an array magnetic field data error correction device based on Transformer in one embodiment;

[0069] Figure 11 An internal structure diagram of a computer device in one embodiment. Detailed implementation manners

[0070] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0071] In one embodiment, as Figure 1 shown, a method for correcting errors in array magnetic field data based on Transformer is provided. In this embodiment, the method is exemplified by being applied to a terminal. The terminal can be an embedded platform or a lightweight edge computing device in scenarios such as mobile deployment or drone mounting. It can be understood that the method can also be applied to a server and can also be applied to a system including a terminal and a server, and is realized through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0072] Step 102, obtain magnetic field data and an error optimization model.

[0073] Among them, the error optimization model includes a non - linear mapping relationship between magnetic field data and a target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss.

[0074] In the embodiment of the present application, the magnetic field data is collected by each magnetometer in the magnetometer array. The magnetometer is a magnetic sensor, and the magnetometer array can be a complex three - dimensional array structure. For example, in the embodiment of the present application, a magnetometer array with a regular tetrahedron structure is taken as an example for illustration, as Figure 2As shown, the magnetometer array with a regular tetrahedron structure has a higher spatial coverage and detection sensitivity, and can achieve magnetic anomaly detection under a non-uniform magnetic field. In this embodiment, each magnetometer in the magnetometer array is a three-axis fluxgate magnetometer, which is used to measure the local magnetic field vector in real time, that is, the terminal measures and obtains the magnetic field data in the current environment through each magnetometer in the magnetometer array.

[0075] The terminal in this embodiment can be an embedded platform or a lightweight edge computing device. An error optimization model is deployed in the terminal. After the terminal reads or receives the magnetic field data collected by the magnetometer array, it can call the error optimization model, and the error optimization model optimizes the error of the magnetic field data and directly maps it to the original data for subsequent magnetic anomaly detection (ferromagnetic target positioning).

[0076] Step 104: Input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism and non-linear mapping relationship of the error optimization model to obtain the target magnetic gradient tensor.

[0077] In the embodiment of the present application, after the terminal obtains the magnetic field data collected by the magnetometer array, it inputs the magnetic field data into the error optimization model. The error optimization model can be a model structure designed based on the Transformer network architecture, and the attention mechanism of the Transformer network architecture is a multi-head attention mechanism. Specifically, as Figure 3 shown, the terminal inputs the magnetic field data into the error optimization model through the data acquisition module of the error optimization model, and through the multi-head attention mechanism of the Transformer architecture, learns the coupling relationship between magnetometers and the non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor during the training process, batch-computes and parallel-processes the mixed features of the magnetic field data in space and time, and performs mapping inference according to the multi-dimensional mixed features of the magnetic field data in space and time to obtain the possible error parameters of the magnetic field data in the current environment. Furthermore, the terminal analyzes and infers the magnetic field environment based on the current magnetic field data through the error optimization model, obtains the error parameters corresponding to the current magnetic field data, performs dynamic error compensation on the magnetic field data, and finally generates the target magnetic gradient tensor based on the error-corrected magnetic field data, that is, obtains the MGT reconstruction output. In an optional embodiment, the error optimization model can also be a combined network architecture based on LSTM (Long Short-Term Memory), a variant architecture of GRU (Gate Recurrent Unit), TCN (Temporal Convolutional Networks), or a multi-head residual attention network. The embodiment of the present application does not limit the model architecture of the error optimization model.

[0078] In an alternative embodiment, after the terminal obtains the magnetic field data collected by each magnetometer, it uses the physical definition formula of the magnetic field gradient tensor and converts the original magnetic field data into an initial magnetic gradient tensor through numerical differentiation or difference methods. Then, the terminal inputs the preprocessed initial magnetic gradient tensor into the error optimization model, and based on the non-linear mapping relationship between the initial magnetic gradient tensor and the target magnetic gradient tensor, completes dynamic error compensation to obtain the target magnetic gradient tensor.

[0079] In the above error correction method for array magnetic field data based on Transformer, by modeling the non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, the complexity of parameter mapping in error analysis is reduced. At the same time, the attention mechanism can screen the features of the collected data, realize the suppression of redundant features, and effectively avoid the risk of multicollinearity. And the target loss function composed of the magnetic gradient tensor reconstruction loss, rotation invariance loss, and smoothness loss is used to train the error optimization model. During the process of data mapping and dynamic error compensation for the magnetic field data, the influence of the multicollinearity risk on error compensation is avoided, making the target magnetic gradient tensor after error correction closer to the true value, and thus improving the accuracy of the target magnetic gradient tensor.

[0080] In an exemplary embodiment, before the error optimization model is applied, it is necessary to pre-train the error optimization model. As Figure 4 shown, before step 102, the method further includes steps 402 to 408. Among them:

[0081] Step 402, obtain a sample data set and an initial error optimization model to be trained.

[0082] Among them, the sample data set includes a first sample data set and a second sample data set. The first sample data set includes first sample magnetic field data and first sample target magnetic gradient tensors under various environmental conditions; the second sample data set includes second sample magnetic field data and second sample target magnetic gradient tensors corresponding to adjacent time points.

[0083] In the embodiments of the present application, the first sample data set is single-frame sample magnetic field data. To cover various possible magnetic field environments, the terminal pre-constructs, through simulation, a first sample data set containing sample magnetic field data under various environmental conditions, that is, the magnetic field of the first sample magnetic field data, the array error parameters, etc. vary greatly. Specifically, first, the terminal sets the parameter range and randomly combines various factors, including different rotation times, rotation angles corresponding to the sensor array, array error parameters (for example, sensitivity, non-orthogonality, zero bias, etc. are randomly generated according to the prior distribution), target magnetic moment (uniformly distributed within a specified intensity range, used to simulate the environment of non-uniform magnetic fields), background Earth magnetic field (for example, set to 50 - 60 μT and applied with a time-varying fluctuation of ±0.5%), noise level (simulating different SNR scenarios through an AWGN channel, for example, randomly sampling from 30 dB to 50 dB), and the degree of array center displacement (simulating the rigid body displacement of the sensor, and the displacement vector is randomly generated within the range of ±10 cm), thereby generating magnetic field data in different situations and the error parameters corresponding to the magnetic field data.

[0084] The second sample data set is a small continuous-frame simulation data set. The terminal continuously collects magnetic sensor array data at adjacent time points and constructs the second sample data set through all the second sample magnetic field data under a preset time series. Each frame in the second sample data set represents a complete magnetic measurement data (that is, an array observation of rep×12), corresponding to the attitude and error environment of the sensor array at a moment. Among them, during the continuous sampling process, the magnetic field, array error parameters, etc. of each second sample magnetic field data in the second sample data set usually change slowly.

[0085] For the error model in the initial error optimization model, this error model is a physical modeling model, including sensitivity error , non-orthogonal error , zero bias error , hard magnetic error , soft magnetic error and misalignment error , where the error model is shown in the following formula (1):

[0086] (1)

[0087] Among them, is the magnetic field data measured by the magnetometer, is the true value of the magnetic field after error compensation.

[0088] Then, all errors are modeled in the form of an affine transformation as the objective function of the error optimization model to reduce the parameter dimension and mitigate the curse of dimensionality caused by excessive parameters, and an error model shown in the following formula (2) is established:

[0089] (2)

[0090] Among them, and are calibration parameters to be learned. Each magnetic sensor has a corresponding linear parameter matrix and bias vector . The linear parameter matrix can be a 3×3 matrix, which is used to reflect misalignment error, non-orthogonal error, sensitivity error, and soft magnetic error. The bias vector can be a 3×1 vector, which is used to reflect zero-bias error and hard magnetic error. Through affine transformation for unified parameterization, the complex original error types are compressed into a concise form, greatly reducing the parameter dimension and the complexity of the high-dimensional error optimization problem.

[0091] Regarding the relationship between the true magnetic field value and the target magnetic gradient tensor, the spatial change rates of the true magnetic field value in the x, y, and z axes are defined as MGT, that is, the magnetic gradient tensor matrix . Among them, the magnetic gradient tensor matrix adopts the method of differential approximation gradient and uses the artificially designed sensor baseline. At the same time, there is an inverse matrix. Therefore, the calculation of the magnetic gradient tensor matrix is shown in the following formula (3):

[0092] (3)

[0093] Furthermore, by using the obtained magnetic gradient tensor matrix of each measurement point, the rotation invariants can be calculated according to the following formulas (4) and (5):

[0094] (4)

[0095] (5)

[0096] Among them, is the determinant, is the F-norm of the magnetic gradient tensor matrix .

[0097] Step 404: Input the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model respectively. According to the initial error optimization model, perform dynamic error compensation and data mapping on the sample magnetic field data to obtain the first intermediate target magnetic gradient tensor and the second intermediate target magnetic gradient tensor.

[0098] In the embodiments of the present application, the terminal inputs the first sample magnetic field data and the second sample magnetic field data in batches according to a preset quantity, and the input sample magnetic field data is organized in the form of a tensor as where represents the size of the input data set, represents the number of rotations in a single experiment (which can vary dynamically), and the 12-dimensional data corresponds to 4 three-axis fluxgate sensors (each sensor outputs the three-dimensional magnetic field values of x, y, and z). Optionally, the terminal can also incorporate environmental auxiliary information (such as rough attitude angles, rotation angles, etc.) as extended information into the input to enhance the adaptability of the error optimization model to complex environmental changes.

[0099] Specifically, the first sample magnetic field data is used for main path training to optimize the traditional RMSE loss function and ensure the accurate matching of the output target magnetic gradient tensor and the true magnetic gradient tensor of the error optimization model. The second sample magnetic field data is used for auxiliary path training to calculate the smoothness loss (auxiliary loss) and ensure the continuity of the output of the error optimization model on adjacent time frames, avoiding sudden changes in the correction parameters. The continuous frame data (the second sample magnetic field data) retains the time order (such as 3 frames or 5 frames) and is sequentially input into the same Transformer encoder, and each frame independently regresses the corresponding correction parameters. Subsequently, the network applies a smoothness constraint loss to the correction knots estimated between consecutive frames.

[0100] The main path training and the auxiliary path training are respectively driven by different Dataloaders (data iterators), but share the same set of backbone Transformer network parameters. In each training cycle of the initial error optimization model, the initial error optimization model first performs the error correction task on the single-frame data (the first sample magnetic field data) with the order shuffled, and then corrects and calculates the smoothness constraint on the continuous frame data (the second sample magnetic field data). Finally, the two parts of the loss in the main path and the auxiliary path are jointly optimized by weighted combination, so as to achieve the coordinated improvement of accuracy and stability.

[0101] After the terminal sends the sample magnetic field data into the initial error optimization model, as Figure 5As shown in the figure, the initial error optimization model of the Transformer architecture is used for illustration. The terminal adopts a dual-path training method. The initial error optimization model, through a dynamic error compensation mechanism (for example, estimating and correcting parameters such as the sensitivity deviation, non-orthogonal error, and zero bias of the sensor), performs data mapping and preliminary correction on the sample magnetic field data (original magnetic field measurement values) through multi-head attention mechanism's multi-dimensional subspace feature mapping, residual connection, layer normalization, and feedforward layer. The preliminarily corrected magnetic field data is further mapped into the first intermediate target magnetic gradient tensor corresponding to the first sample magnetic field data and the second intermediate target magnetic gradient tensor corresponding to the second sample magnetic field data, and finally output as the intermediate result of error optimization in the initial error optimization model of the current training batch. Furthermore, in the subsequent backpropagation of the initial error optimization model, loss calculation and model parameter update are performed through the first intermediate target magnetic gradient tensor and the second intermediate target magnetic gradient tensor. Among them, during the process of cyclic training of the initial error optimization model, the intermediate target magnetic gradient tensor obtained by model inference in each batch changes with the adjustment of model parameters.

[0102] Step 406: Determine the target loss of the initial error optimization model according to the first intermediate target magnetic gradient tensor, the second intermediate target magnetic gradient tensor, the first sample target magnetic gradient tensor, and the second sample target magnetic gradient tensor.

[0103] In the embodiments of the present application, the training of the initial error optimization model needs to satisfy data fitting constraints, physical principle constraints, and time continuity constraints. In the dual-path training strategy, the main loss is set as the magnetic gradient tensor reconstruction loss and the rotation invariance loss, and the auxiliary loss is set as the temporal smoothness constraint loss. The main path (main loss) is used to estimate the magnetic sensor error parameters; the auxiliary path (auxiliary loss) is used to establish parameter smoothness constraints for time-continuous data. The main path and the auxiliary path are jointly optimized during the training process to enhance the real-time performance and stability of the initial error optimization model. First, by optimizing the reconstruction error between the first intermediate target magnetic gradient tensor and the first sample target magnetic gradient tensor, it is ensured that the error-optimized magnetic field data output by the initial error optimization model accurately approaches its physical true value; using magnetic sensor data at different rotation angles, the corrected magnetic gradient tensor is forced to satisfy rotation invariance, so that the output of the initial error optimization model meets physical rationality; based on the second intermediate target magnetic gradient tensor of adjacent time series, the continuity of the correction parameters over time is ensured, avoiding sudden changes and improving the temporal stability of the model. Furthermore, based on the first intermediate target magnetic gradient tensor and the first sample target magnetic gradient tensor under different conditions (for example, corresponding to magnetic sensors with different rotation angles), as well as the second intermediate target magnetic gradient tensor and the second sample target magnetic gradient tensor of adjacent time series, calculating the target loss of the initial error optimization model can optimize the model parameters of the initial error optimization model in multiple dimensions.

[0104] Step 408, in the case that the target loss does not meet the preset loss condition, adjust the model parameters of the initial error optimization model, and repeat the steps of inputting the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model respectively, performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model, and obtaining the first intermediate target magnetic gradient tensor and the second intermediate target magnetic gradient tensor until the target loss meets the preset loss condition, and obtaining the trained error optimization model.

[0105] In the embodiment of the present application, the preset loss condition may be a preset loss threshold, a preset number of iterations, or a loss change threshold of the target loss. If the current target loss does not meet the preset loss threshold, or the number of iterations of the current initial error correction model does not meet the preset number of iterations, or the change degree of the current target loss does not meet the preset loss change threshold, the terminal performs backpropagation on the current initial error optimization model, updates and adjusts the model parameters of the current initial error optimization model according to the preset optimizer, and inputs the sample magnetic field data of the next batch into the initial error optimization model, and repeats the parameter optimization of the initial error optimization model until the target loss meets the preset loss condition, indicating that the current initial error optimization model is trained, and obtaining the trained error optimization model. Among them, the sample magnetic field data of the next batch is a set of data that will be input into the initial error optimization model for batch training in the complete cyclic training process. In the whole training process, the sample magnetic field data set will be divided into multiple batches (batch), and each time during training, the initial error optimization model will process the sample magnetic field data of each batch, and then continuously repeat this process according to the preset number of epochs, so that the initial error optimization model can learn the laws and characteristics in the sample magnetic field data set.

[0106] In this embodiment, through the training of the initial error optimization model, it gradually learns the non-linear mapping relationship in a complex environment, and at the same time alleviates the problem of multicollinearity through the target loss and the attention mechanism. Finally, in the error optimization application of the actual scenario, the accuracy of error compensation for magnetic field data is improved, and thus the accuracy of the target magnetic gradient tensor is improved.

[0107] In an exemplary embodiment, as Figure 6 shown, step 406 includes steps 602 to 608, where:

[0108] Step 602, determine the magnetic gradient tensor reconstruction loss of the initial error optimization model based on the first sample target magnetic gradient tensor and the first intermediate target magnetic gradient tensor.

[0109] In the embodiment of the present application, the first sample target magnetic gradient tensor serves as the true magnetic gradient tensor of the training sample label for the output result of the initial error optimization model, enabling the magnetic gradient tensor reconstruction loss to directly measure the error between the first intermediate target magnetic gradient tensor output by the initial error optimization model and the true magnetic gradient tensor in the training sample label. By optimizing the model parameters, that is, guiding the initial error optimization model to optimize for the calibration parameters and to reduce the output error of the initial error optimization model, that is, to reduce the distance between the first intermediate target magnetic gradient tensor output after model inference for the first sample magnetic field data and the first sample target magnetic gradient tensor. The magnetic gradient tensor reconstruction loss is calculated according to the following formula (6):

[0110] (6)

[0111] where is the root mean square error calculation performed on the intermediate target magnetic gradient tensor and the sample target magnetic gradient tensor. The error parameter inferred by the initial error optimization model is used to correct the sample magnetic field data, and an intermediate target magnetic gradient tensor is constructed, and then the RMSE (Root Mean Square Error) calculation is performed with the sample target magnetic gradient tensor.

[0112] Step 604: Determine the rotation invariance loss of the initial error optimization model based on the first intermediate target magnetic gradient tensor obtained by optimizing the error of the sample magnetic field data of the magnetic sensor at different rotation angles and the first sample target magnetic gradient tensor corresponding to the first sample magnetic field data.

[0113] In the embodiment of the present application, the rotation invariance loss utilizes the physical property that the magnetic sensor should maintain consistency under different rotation actions to constrain the first intermediate target magnetic gradient tensor after error correction to satisfy rotation transformation invariance. For example, when the sensor rotates around its own axis, the measured value of the magnetic field (magnetic field data) will change, but the invariants of the magnetic gradient tensor matrix and after error correction must remain constant. If the error correction of the initial error optimization model is insufficient (for example, incomplete alignment non-alignment error or bias error not eliminated), then the invariants will change with the rotation angle. Therefore, even if there are unmodeled systematic errors or noises, the initial error optimization model must satisfy the physical constraint of rotation invariance to prevent overfitting to local data. Therefore, the terminal uses the rotation invariance loss Constrain the first intermediate target magnetic gradient tensor corresponding to the magnetic sensors at different rotation angles, that is, the terminal optimizes the sample magnetic field data corresponding to the magnetic sensors at different rotation angles to obtain the first intermediate target magnetic gradient tensor, and determines the sample rotation invariant according to the first sample target magnetic gradient tensor corresponding to the sample magnetic field data and , and then calculate the rotation invariance loss , where the rotation invariance loss is shown in the following formula (7):

[0114] (7)

[0115] Step 606, determine the smoothness loss of the initial error optimization model based on the second intermediate target magnetic gradient tensor and the second sample target magnetic gradient tensor corresponding to the second sample magnetic field data of adjacent time series.

[0116] In the embodiments of the present application, the smoothness loss is a second-order difference penalty term, which makes the output parameters of the initial error optimization model change continuously in the time series, improving the temporal consistency and real-time performance of the initial error optimization model. In a continuous time series (for example, the real-time magnetic measurement scenario of an unmanned aerial vehicle or a mobile platform), the change of the error parameter should conform to physical continuity. For example, the mechanical installation error of the sensor (non-orthogonal, baseline offset) usually changes slowly rather than suddenly, and the zero-bias error caused by clock drift or temperature change usually has low-frequency characteristics. Therefore, the initial error optimization model optimizes the correction parameters and , and calculates the smoothness loss through the second intermediate target magnetic gradient tensor and the second sample target magnetic gradient tensor corresponding to the second sample magnetic field data of adjacent time series, so that the change of the second target intermediate magnetic gradient tensor in adjacent time series (t and t+1) should be smooth and reasonable. The calculation of the smoothness loss is shown in the following formula (8):

[0117] (8)

[0118] where is the total number of iterations, t is the time series of each iteration period, is the flattened error optimization parameter, that is and .

[0119] Step 608, construct the objective loss of the initial error optimization model according to the magnetic gradient tensor reconstruction loss, rotation invariance loss and smoothness loss.

[0120] In the embodiments of the present application, the terminal constructs the objective loss of the current initial error optimization model according to the magnetic gradient tensor reconstruction loss, the rotation invariance loss, and the smoothness loss, and according to the weight parameter corresponding to each loss. The main loss , the auxiliary loss and the objective loss are calculated as follows:

[0121] (9)

[0122] (10)

[0123] (11)

[0124] wherein are the weight parameters corresponding to the magnetic gradient tensor reconstruction loss, the rotation invariance loss, and the smoothness loss respectively.

[0125] In this embodiment, in the single-frame path optimization, the magnetic gradient tensor reconstruction loss and the rotation invariance loss are used as the guidance for adjusting the model parameters to train the main error correction ability of the network. At the same time, in the optimization of the continuous-frame path, the smoothness loss is used to guide the temporal continuity of the output parameters of the initial error optimization model, so that the error optimization model can adapt to both static calibration and dynamic scenarios. Under static conditions, the accuracy is guaranteed by physical constraints, and under dynamic conditions, the continuity is maintained by temporal constraints, improving the accuracy of the error optimization model when performing error optimization in various scenarios and improving the accuracy of the target magnetic gradient tensor.

[0126] In an exemplary embodiment, after step 408, the method further includes step 4081. Wherein:

[0127] Step 4081, perform knowledge distillation on the trained error optimization model according to the knowledge distillation strategy to obtain a lightweight error optimization model.

[0128] In the embodiments of the present application, the terminal can also, after the error optimization model is trained, adopt the knowledge distillation strategy to perform knowledge distillation on the trained error optimization model to obtain a lightweight error optimization model. Specifically, as Figure 7 shown, the terminal uses the trained error optimization model as the teacher network (Teacher Network), and constructs a student network (Student Network) and a distillation loss term, guiding the student network to imitate the output behavior of the teacher network while learning the physical loss, to obtain a lightweight error optimization model. The distillation loss term is shown in the following formula (12):

[0129] (12)

[0130] Among them, are the model parameters of the student network, are the model parameters of the teacher network.

[0131] In this embodiment, the knowledge distillation strategy significantly improves the expression ability and generalization performance of the lightweight error optimization model, avoids performance degradation caused by parameter reduction, and effectively supports real-time deployment in edge computing devices or embedded systems.

[0132] In an exemplary embodiment, as Figure 8 shown, step 104 includes steps 802 to 806. Among them:

[0133] Step 802: Input the magnetic field data into the error optimization model, extract features from the magnetic field data according to the error optimization model, and obtain the first feature vectors under multiple feature dimensions corresponding to the magnetic field data.

[0134] In the embodiment of the present application, the terminal inputs the magnetic field data into the error optimization model. The error optimization model first preprocesses the magnetic field data. The preprocessing includes normalizing the sensor data and splicing the environmental auxiliary information and the magnetic field data to form a unified input vector. Taking the error optimization model with the Transformer architecture as an example, the independent mapping layer of the multi-head attention mechanism of the error optimization model maps the input vector to different subspaces to obtain the first feature vectors under multiple feature dimensions.

[0135] Step 804: Assign weights to the feature dimensions according to the attention mechanism to obtain the attention weight matrix corresponding to the first feature vectors.

[0136] In the embodiment of the present application, the terminal calculates the attention scores of each subspace according to the attention mechanism of the error optimization model, quantifies the correlation between each magnetic sensor under the dimensions of each subspace, assigns weights to the feature dimensions, and obtains the attention weight matrix of the first feature vectors through normalization.

[0137] Step 806: Perform dynamic error compensation and data mapping on the first feature vectors based on the attention weight matrix and the nonlinear mapping relationship to obtain the target magnetic gradient tensor.

[0138] In the embodiment of the present application, the terminal weighted aggregates the value vectors of each subspace based on the attention weights to generate local context vectors, and splices each local context vector to obtain a global feature representation. Furthermore, the terminal performs dynamic error compensation and data mapping on the first feature vectors according to the nonlinear transformation layer and the nonlinear mapping relationship to obtain the target magnetic gradient tensor.

[0139] In this embodiment, the coupling relationship between different magnetic sensor data is modeled through the self-attention mechanism, and the correlation between magnetic sensors in each dimension is analyzed, which can alleviate the problem of multicollinearity, avoid model degradation caused by data redundancy, and map the magnetic field data to the target magnetic gradient tensor through a non-linear mapping relationship, reducing the complexity of parameter mapping in error analysis, making the target magnetic gradient tensor after error correction closer to the true value, and thus improving the accuracy of the target magnetic gradient tensor.

[0140] In an exemplary embodiment, as Figure 9 shown, step 606 includes steps 902 to 906. Among them:

[0141] Step 902, based on the attention weight matrix and the non-linear mapping relationship, determine the error parameters corresponding to the magnetic field data, and perform error compensation on the first eigenvector based on the error parameters to obtain the second eigenvector.

[0142] In the embodiment of the present application, the terminal calculates the attention weight matrix of the input magnetic field data through the error optimization model, dynamically captures the spatio-temporal correlation features between different magnetic sensor positions or time steps, and analyzes and processes the first eigenvector in combination with the attention weight matrix and non-linear mapping (for example, fully connected layer) to generate the error parameters corresponding to the current magnetic field data. Furthermore, the terminal applies the error parameters to the first eigenvector to compensate for the errors caused by the errors of the magnetic sensors themselves, the noise in the originally collected magnetic field data, the attitude change or environmental interference, realizes the error compensation of the magnetic field data, and obtains the second eigenvector corresponding to the magnetic field data after error compensation.

[0143] Step 904, perform data mapping on the second eigenvector to obtain the target eigenvector corresponding to the target magnetic gradient tensor.

[0144] In the embodiment of the present application, the terminal inputs the compensated second eigenvector into the mapping module (for example, linear transformation layer) to generate a regularized target eigenvector corresponding to the target magnetic gradient tensor. Among them, through data mapping, the second eigenvector representing the magnetic field data after error correction is mapped to the target eigenvector representing the target magnetic gradient tensor, that is, the finally generated target eigenvector is a high-order eigenvector that has undergone error compensation and physical constraint alignment and directly corresponds to the structure of the target magnetic gradient tensor.

[0145] Step 906, decode the target eigenvector to obtain the target magnetic gradient tensor.

[0146] In the embodiments of the present application, the terminal maps the aligned target feature vector into a complete magnetic gradient tensor through a decoder (e.g., a fully connected layer or an inverse transformation) in the error optimization model. In the decoding stage, by combining spatial transformation and noise suppression, the target magnetic gradient tensor is directly output, realizing the direct mapping of magnetic field data into the target magnetic gradient tensor.

[0147] In this embodiment, the error optimization model is used to accurately map the magnetic field data into the target magnetic gradient tensor. By calculating the attention weight matrix to capture the spatial and temporal correlation features, combining the non-linear mapping relationship to determine the error parameters, and compensating the error of the first feature vector to obtain the second feature vector, the errors caused by noise, attitude change or environmental interference in the original magnetic field data collected by the magnetic sensor are effectively corrected. Furthermore, the compensated second feature vector is subjected to data mapping to make it conform to the physical constraints of the magnetic gradient tensor, generating a regularized and physically constraint-aligned high-order feature vector. Finally, the decoder maps the aligned target feature vector into a complete magnetic gradient tensor. By combining spatial transformation and noise suppression, the direct mapping from magnetic field data to the target magnetic gradient tensor is finally realized, improving the accuracy and reliability of the reconstruction of the target magnetic gradient tensor.

[0148] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps do not necessarily have to be executed in the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages do not necessarily have to be executed at the same time, but can be executed at different times. The execution order of these steps or stages does not necessarily have to be sequential, but can be executed alternately or in turn with at least a part of other steps or steps in other steps.

[0149] Based on the same inventive concept, the embodiments of the present application also provide a Transformer-based array magnetic field data error correction device for implementing the above-mentioned Transformer-based array magnetic field data error correction method. The solution provided by this device for solving problems is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the Transformer-based array magnetic field data error correction device provided below can refer to the limitations on the Transformer-based array magnetic field data error correction method in the above text, and will not be repeated here.

[0150] In an exemplary embodiment, as Figure 10As shown, a Transformer-based array magnetic field data error correction device 1000 is provided, including: a first acquisition module 1001 and an error optimization module 1002, where:

[0151] The first acquisition module 1001 is used to acquire magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between magnetic field data and a target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss;

[0152] The error optimization module 1002 is used to input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism and non-linear mapping relationship of the error optimization model to obtain a target magnetic gradient tensor.

[0153] In one embodiment, the device further includes:

[0154] A second acquisition module, used to acquire a sample data set and an initial error optimization model to be trained; the sample data set includes a first sample data set and a second sample data set, the first sample data set includes first sample magnetic field data and first sample target magnetic gradient tensors under various environmental conditions; the second sample data set includes second sample magnetic field data and second sample target magnetic gradient tensors corresponding to adjacent time points;

[0155] An inference module, used to input the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model respectively, and perform dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor;

[0156] A loss calculation module, used to determine the target loss of the initial error optimization model according to the first intermediate target magnetic gradient tensor, the second intermediate target magnetic gradient tensor, the first sample target magnetic gradient tensor, and the second sample target magnetic gradient tensor;

[0157] A parameter adjustment module, used to adjust the model parameters of the initial error optimization model when the target loss does not meet the preset loss condition, and repeat the steps of inputting the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model respectively, and performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor until the target loss meets the preset loss condition, and obtain a trained error optimization model.

[0158] In one embodiment, the loss calculation module is specifically configured to determine the magnetic gradient tensor reconstruction loss of the initial error optimization model based on the first sample target magnetic gradient tensor and the first intermediate target magnetic gradient tensor;

[0159] Based on the first intermediate target magnetic gradient tensor obtained by optimizing the error of the sample magnetic field data of magnetic sensors at different rotation angles, and the first sample target magnetic gradient tensor corresponding to the first sample magnetic field data, determine the rotation invariance loss of the initial error optimization model;

[0160] Based on the second intermediate target magnetic gradient tensor and the second sample target magnetic gradient tensor corresponding to the second sample magnetic field data of adjacent time series, determine the smoothness loss of the initial error optimization model;

[0161] Construct the target loss of the initial error optimization model according to the magnetic gradient tensor reconstruction loss, rotation invariance loss and smoothness loss.

[0162] In one embodiment, the parameter adjustment module is specifically configured to perform knowledge distillation on the trained error optimization model according to the knowledge distillation strategy to obtain a lightweight error optimization model.

[0163] In one embodiment, the error optimization module 1002 is specifically configured to input the magnetic field data into the error optimization model, extract features from the magnetic field data according to the error optimization model, and obtain the first feature vector under multiple feature dimensions corresponding to the magnetic field data;

[0164] Allocate weights to the feature dimensions according to the attention mechanism to obtain the attention weight matrix corresponding to the first feature vector;

[0165] Perform dynamic error compensation and data mapping on the first feature vector based on the attention weight matrix and the nonlinear mapping relationship to obtain the target magnetic gradient tensor.

[0166] In one embodiment, the error optimization module 1002 is specifically configured to determine the error parameter corresponding to the magnetic field data based on the attention weight matrix and the nonlinear mapping relationship, and perform error compensation on the first feature vector based on the error parameter to obtain the second feature vector;

[0167] Perform data mapping on the second feature vector to obtain the target feature vector corresponding to the target magnetic gradient tensor;

[0168] Decode the target feature vector to obtain the target magnetic gradient tensor.

[0169] Each module in the above-mentioned Transformer-based array magnetic field data error correction device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above modules can be embedded in the processor of the computer device in hardware form or be independent of the processor, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.

[0170] In an exemplary embodiment, a computer device is provided. The computer device can be a terminal, and its internal structure diagram can be as Figure 11 shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used for the processor to exchange information with external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a method for correcting errors in array magnetic field data based on Transformer. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the shell of the computer device, or an external keyboard, a touchpad, or a mouse, etc.

[0171] Those skilled in the art can understand that Figure 11 the structure shown in

[0172] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0173] Obtain magnetic field data and an error optimization model; the error optimization model includes a non - linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss;

[0174] Input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism and non - linear mapping relationship of the error optimization model to obtain the target magnetic gradient tensor.

[0175] In one embodiment, when the processor executes the computer program, the following steps are also implemented:

[0176] Obtain a sample data set and an initial error optimization model to be trained; the sample data set includes a first sample data set and a second sample data set. The first sample data set includes first sample magnetic field data and first sample target magnetic gradient tensors under various environmental conditions; the second sample data set includes second sample magnetic field data and second sample target magnetic gradient tensors corresponding to adjacent time points;

[0177] Input the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model respectively, and perform dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor;

[0178] Determine the target loss of the initial error optimization model according to the first intermediate target magnetic gradient tensor, the second intermediate target magnetic gradient tensor, the first sample target magnetic gradient tensor, and the second sample target magnetic gradient tensor;

[0179] In the case that the target loss does not meet the preset loss condition, adjust the model parameters of the initial error optimization model, and repeat the steps of inputting the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model respectively, and performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor until the target loss meets the preset loss condition to obtain the trained error optimization model.

[0180] In one embodiment, when the processor executes the computer program, the following steps are also implemented:

[0181] Determine the magnetic gradient tensor reconstruction loss of the initial error optimization model based on the first sample target magnetic gradient tensor and the first intermediate target magnetic gradient tensor;

[0182] Determine the rotation invariance loss of the initial error optimization model based on the first intermediate target magnetic gradient tensor obtained by optimizing the sample magnetic field data of magnetic sensors at different rotation angles, and the first sample target magnetic gradient tensor corresponding to the first sample magnetic field data;

[0183] Determine the smoothness loss of the initial error optimization model based on the second intermediate target magnetic gradient tensor and the second sample target magnetic gradient tensor corresponding to the second sample magnetic field data of adjacent time series;

[0184] Construct the target loss of the initial error optimization model according to the magnetic gradient tensor reconstruction loss, rotation invariance loss and smoothness loss.

[0185] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0186] Perform knowledge distillation on the trained error optimization model according to the knowledge distillation strategy to obtain a lightweight error optimization model.

[0187] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0188] Input the magnetic field data into the error optimization model, extract features from the magnetic field data according to the error optimization model, and obtain the first feature vector under multiple feature dimensions corresponding to the magnetic field data;

[0189] Allocate weights to the feature dimensions according to the attention mechanism to obtain the attention weight matrix corresponding to the first feature vector;

[0190] Perform dynamic error compensation and data mapping on the first feature vector based on the attention weight matrix and the nonlinear mapping relationship to obtain the target magnetic gradient tensor.

[0191] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0192] Based on the attention weight matrix and the nonlinear mapping relationship, determine the error parameter corresponding to the magnetic field data, and perform error compensation on the first feature vector based on the error parameter to obtain the second feature vector;

[0193] Perform data mapping on the second feature vector to obtain the target feature vector corresponding to the target magnetic gradient tensor;

[0194] Decode the target feature vector to obtain the target magnetic gradient tensor.

[0195] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0196] In one embodiment, a computer program product is provided, including a computer program which, when executed by a processor, implements the steps in the above-mentioned method embodiments.

[0197] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.

[0198] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned method embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned method embodiments. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include Read-Only Memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, Resistive Random Access Memory (ReRAM), Magnetoresistive Random Access Memory (MRAM), Ferroelectric Random Access Memory (FRAM), Phase Change Memory (PCM), graphene memory, etc. Volatile memory can include Random Access Memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., and are not limited thereto. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, Artificial Intelligence (AI) processors, etc., and are not limited thereto.

[0199] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as falling within the scope described in this application.

[0200] The above-described embodiments merely represent several implementation manners of this application. The description is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of this application. It should be noted that for those of ordinary skill in the art, without departing from the concept of this application, several modifications and improvements can still be made, and these all belong to the protection scope of this application. Therefore, the protection scope of this application shall be subject to the appended claims.

Claims

1. A method for correcting errors in array magnetic field data based on Transformer, characterized in that The method includes: Obtaining magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss; Inputting the magnetic field data into the error optimization model, and performing dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism of the error optimization model and the non-linear mapping relationship to obtain the target magnetic gradient tensor.

2. The method according to claim 1, wherein Before obtaining the magnetic field data and the error optimization model, the method further includes: Obtaining a sample data set and an initial error optimization model to be trained; the sample data set includes a first sample data set and a second sample data set, the first sample data set includes first sample magnetic field data and first sample target magnetic gradient tensors under various environmental conditions; the second sample data set includes second sample magnetic field data and second sample target magnetic gradient tensors corresponding to adjacent time points; Respectively inputting the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model, and performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor; Determining the target loss of the initial error optimization model according to the first intermediate target magnetic gradient tensor, the second intermediate target magnetic gradient tensor, the first sample target magnetic gradient tensor, and the second sample target magnetic gradient tensor; In the case where the target loss does not meet the preset loss condition, adjusting the model parameters of the initial error optimization model, and repeating the step of respectively inputting the first sample magnetic field data and the second sample magnetic field data into the initial error optimization model, and performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain a first intermediate target magnetic gradient tensor and a second intermediate target magnetic gradient tensor until the target loss meets the preset loss condition to obtain a trained error optimization model.

3. The method according to claim 2, wherein The determining the target loss of the initial error optimization model according to the first intermediate target magnetic gradient tensor, the second intermediate target magnetic gradient tensor, the first sample target magnetic gradient tensor, and the second sample target magnetic gradient tensor includes: Determining the magnetic gradient tensor reconstruction loss of the initial error optimization model based on the first sample target magnetic gradient tensor and the first intermediate target magnetic gradient tensor; Determining the rotation invariance loss of the initial error optimization model based on the first intermediate target magnetic gradient tensor obtained by performing error optimization on the sample magnetic field data of magnetic sensors at different rotation angles, and the first sample target magnetic gradient tensor corresponding to the first sample magnetic field data; Determining the smoothness loss of the initial error optimization model based on the second intermediate target magnetic gradient tensor and the second sample target magnetic gradient tensor corresponding to the second sample magnetic field data of adjacent time series; Construct the objective loss of the initial error optimization model based on the magnetic gradient tensor reconstruction loss, the rotation invariance loss, and the smoothness loss.

4. The method according to claim 2, characterized in that, In the case that the objective loss does not meet the preset loss condition, adjust the model parameters of the initial error optimization model, and repeat the step of inputting the sample magnetic field data into the initial error optimization model, performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model to obtain the intermediate target magnetic gradient tensor, until the objective loss meets the preset loss condition. After obtaining the trained error optimization model, the method further includes: Perform knowledge distillation on the trained error optimization model according to the knowledge distillation strategy to obtain a lightweight error optimization model.

5. The method according to claim 1, characterized in that, The step of inputting the magnetic field data into the error optimization model, performing dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism and the non-linear mapping relationship of the error optimization model to obtain the target magnetic gradient tensor includes: Input the magnetic field data into the error optimization model, extract features from the magnetic field data according to the error optimization model to obtain a first feature vector under multiple feature dimensions corresponding to the magnetic field data; Allocate weights to the feature dimensions according to the attention mechanism to obtain an attention weight matrix corresponding to the first feature vector; Perform dynamic error compensation and data mapping on the first feature vector based on the attention weight matrix and the non-linear mapping relationship to obtain the target magnetic gradient tensor.

6. The method according to claim 5, wherein The step of performing dynamic error compensation and data mapping on the first feature vector based on the attention weight matrix and the non-linear mapping relationship to obtain the target magnetic gradient tensor includes: Based on the attention weight matrix and the non-linear mapping relationship, determine the error parameter corresponding to the magnetic field data, and perform error compensation on the first feature vector based on the error parameter to obtain a second feature vector; Perform data mapping on the second feature vector to obtain a target feature vector corresponding to the target magnetic gradient tensor; Decode the target feature vector to obtain the target magnetic gradient tensor.

7. An error correction device for array magnetic field data based on Transformer, characterized in that, The device includes: A first acquisition module, configured to acquire magnetic field data and an error optimization model; the error optimization model includes a non-linear mapping relationship between the magnetic field data and the target magnetic gradient tensor, and the error optimization model is trained based on an objective loss function composed of a magnetic gradient tensor reconstruction loss, a rotation invariance loss, and a smoothness loss; An error optimization module, configured to input the magnetic field data into the error optimization model, and perform dynamic error compensation and data mapping on the magnetic field data according to the attention mechanism and the non-linear mapping relationship of the error optimization model to obtain the target magnetic gradient tensor.

8. The device according to claim 7, characterized in that, The device further includes: A second acquisition module, configured to acquire a sample data set and an initial error optimization model to be trained; the sample data set includes sample magnetic field data and sample target magnetic gradient tensors under various environmental conditions; An inference module, configured to input the sample magnetic field data into the initial error optimization model, perform dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model, and obtain an intermediate target magnetic gradient tensor; A loss calculation module, configured to determine the target loss of the initial error optimization model according to the intermediate target magnetic gradient tensor and the sample target magnetic gradient tensor; A parameter adjustment module, configured to, when the target loss does not meet the preset loss condition, adjust the model parameters of the initial error optimization model, and repeat the step of inputting the sample magnetic field data into the initial error optimization model, performing dynamic error compensation and data mapping on the sample magnetic field data according to the initial error optimization model, and obtaining an intermediate target magnetic gradient tensor until the target loss meets the preset loss condition, and obtaining a trained error optimization model.

9. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Magnetic interference compensation method for superconducting full-tensor magnetic gradient measurement device

    CN113156355A

  • Magnetic gradient tensor field detection data error identification and labeling method

    CN118606786A