Mass flowmeter measurement error compensation method based on deep learning
By combining an improved TabPFN network and a residual correction network, the measurement stability and accuracy issues of mass flow meters under complex operating conditions are solved, achieving high-precision, adaptive error compensation and ensuring the reliability and engineering adaptability of the measurement results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TIANJIN CHANGHE MEASUREMENT & CONTROL TECHNOLOGY CO LTD
- Filing Date
- 2026-04-01
- Publication Date
- 2026-04-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing mass flow meters lack measurement stability and accuracy under complex operating conditions such as drastic temperature fluctuations, increased pipeline vibration, and frequent changes in medium density. Traditional error compensation methods are difficult to adapt to multivariable and high-dimensional operating conditions, and existing methods ignore the temporal characteristics and uncertainties of errors, resulting in large fluctuations and significant deviations in compensation results at different operating conditions.
An improved TabPFN network is used for error modeling. Combined with residual correction network and compensation correction technology, it introduces short-term and long-term residual modeling branches and uncertainty guidance module through low-rank attention modeling under working conditions, cross-channel cross fusion and error prediction, to perform dynamic error compensation. Physical boundary and rate of change constraints are introduced at the output end.
It improves the accuracy and stability of measurement error compensation, enhances robustness to sudden disturbances and time drift, ensures that the compensation results are within the physical range, and improves the accuracy and engineering usability of the measurement.
Smart Images

Figure CN121935852A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial measurement and intelligent instrument technology, and in particular to a method for compensating for measurement errors in a mass flow meter based on deep learning. Background Technology
[0002] With the continuous improvement of industrial automation and the increasing demand for high-precision measurement, mass flow meters, as key fluid measurement devices, are widely used in various process industries such as petrochemicals, metallurgy, and energy. However, under conditions of drastic temperature fluctuations, increased pipeline vibration, and frequent changes in medium density, the measurement stability and accuracy of mass flow meters still face many challenges. Existing error compensation methods still have the following problems: Traditional static calibration methods rely on manual experimental measurement point fitting or empirical formula construction, which is difficult to adapt to multivariate and high-dimensional working conditions, resulting in poor generalization ability and weak adaptability of compensation models. Some methods introduce shallow models such as linear regression or support vector machines to model errors, but they are not capable of modeling the strong nonlinearity and cross-channel coupling relationship between errors and working variables under complex working conditions, and cannot accurately characterize the error evolution mechanism. Existing methods generally ignore the temporal characteristics and uncertainty of errors, and fail to establish dynamic compensation strategies for time-varying disturbances and distribution differences, which easily leads to large fluctuations and significant deviations in compensation results at different working condition stages.
[0003] Therefore, how to provide a method for compensating for measurement errors in mass flow meters based on deep learning is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0004] One objective of this invention is to propose a method for compensating for measurement errors in mass flow meters based on deep learning. This invention describes in detail the modeling, residual correction, and dynamic compensation of flow measurement errors under complex operating conditions through an improved TabPFN network, a residual correction network, and compensation correction modeling technology. It has the advantages of high compensation accuracy, strong adaptability, and high compensation stability.
[0005] A method for compensating for measurement errors of a mass flow meter based on deep learning according to an embodiment of the present invention includes the following steps: Step 1: Collect the raw mass flow rate value sequence and operating parameter sequence of the mass flow meter to construct the raw measurement sample set; Step 2: Preprocess the original measurement sample set to generate a standard error sample set; Step 3: Embed and encode the various operating condition parameters in the standard error sample set to obtain the operating condition embedding vector set; Step 4: Input the working condition embedding vector set into the improved TabPFN network, perform working condition low-rank attention modeling, cross-channel cross-fusion and error prediction to obtain the prediction error value vector; the improved TabPFN network includes an error modeling backbone network and an error distribution prediction module; Step 5: Input the predicted error value vector and the working condition embedding vector set into the residual correction network for residual correction fusion to generate an error compensation sequence; the residual correction network includes a short-term residual modeling branch, a long-term residual modeling branch, and an uncertainty guidance module; Step 6: Based on the error compensation sequence, perform compensation correction and engineering constraints on the original mass flow rate value sequence to obtain the corrected mass flow rate value sequence; Step 7: Based on the standard error sample set, prediction error value vector, and mass flow correction value sequence, construct the supervised loss function and the incremental feedback loss function, and perform training optimization and incremental update on the improved TabPFN network respectively.
[0006] Optionally, step one specifically includes: The raw mass flow rate value sequence is acquired step-by-step by a mass flow meter installed on the measuring pipe; The operating condition parameter sequence is collected synchronously. The operating condition parameter sequence includes the temperature sequence of the medium to be measured, the pressure sequence of the measuring pipe where the mass flow meter is located, the density sequence of the medium to be measured, the vibration signal intensity sequence of the measuring pipe where the mass flow meter is located, and the flow state identification parameter sequence used to identify the flow state. The original mass flow rate value sequence is synchronized and paired with the operating condition parameter sequence to construct the original measurement sample set; The original mass flow rate value and operating parameters at each time step in the original measurement sample set constitute an original measurement sample.
[0007] Optionally, step two specifically includes: The preprocessing includes constructing true error labels, data cleaning, removing outlier samples, and normalization. Obtain the mass flow rate reference calibration value, and at each time step, calculate the difference between the original mass flow rate value and the mass flow rate reference calibration value to obtain the measurement error value, and use the measurement error value as the true error label; The actual error label of each time step is paired with the operating parameters to construct an initial error sample set; The operating condition parameter sequences in the initial error sample set are cleaned to obtain a cleaned error sample set. Specifically, the initial error samples containing missing items are removed, and the operating condition parameter sequences are formatted and converted according to the set data standards and specifications. The Z-Score method is used to identify and remove abnormal samples from the cleaning error sample set to obtain the effective error sample set; The minimum-maximum normalization method is used to map the values in the effective error sample set to the interval [0,1] to obtain the standard error sample set.
[0008] Optionally, step three specifically includes: The standard temperature parameter, standard pressure parameter, standard density parameter, standard vibration signal intensity parameter, and standard flow state identification parameter for each time step are respectively input into an independent embedding encoding channel for feature mapping to obtain temperature embedding vector, pressure embedding vector, density embedding vector, vibration signal intensity embedding vector, and flow state identification embedding vector; The embedded coding channel consists of a multilayer perceptron structure and a batch normalization structure. The multilayer perceptron structure includes two fully connected neural networks, with each fully connected neural network followed by a ReLU activation function. The temperature embedding vector, pressure embedding vector, density embedding vector, vibration signal intensity embedding vector, and flow state identification embedding vector of each time step are concatenated to obtain the working condition embedding vector, and the working condition embedding vector is arranged into a working condition embedding vector set according to the time step.
[0009] Optionally, the error modeling backbone network includes a working condition injection module, a Linformer modeling module, and a cross-channel cross-fusion module. This module performs low-rank attention modeling and cross-channel cross-fusion on the working condition embedded vector set to generate a working condition fusion feature matrix, specifically including: Define a feature space and a projection space, which are used to standardize the mapping feature dimensions; In the operating condition injection module, the operating condition weight matrix is constructed based on the operating condition embedding vector set, specifically as follows: Each working condition embedding vector is mapped to the projection space through a set of fully connected layers with shared parameters to obtain working condition factor vectors, and the working condition factor vectors are arranged into a working condition factor matrix according to the time step order. The working condition weight matrix is obtained by normalizing each column of the working condition factor matrix using the Softmax function. In the Linformer modeling module, a load case weight matrix is introduced to perform low-rank attention operations on the load case embedding vector set, specifically: The working condition embedding vector set is mapped to the feature space through three sets of trainable query mapping matrices, key mapping matrices and value mapping matrices, respectively, to obtain the working condition query matrix, working condition key matrix and working condition value matrix; Based on the projection space, the projection matrix is initialized, and the low-rank linear projection is used to perform low-rank linear projection on the condition key matrix and condition value matrix respectively to obtain the compressed key matrix and compressed value matrix. The low-rank linear projection is used to compress the time step dimension. Multiply the working condition query matrix by the transpose of the compressed key matrix and divide by the square root of the mapping feature dimension of the feature space to obtain the initial attention score matrix. The initial attention score matrix is multiplied element-wise with the working condition weight matrix, and then normalized row-wise using the Softmax function to obtain the attention weight matrix. The working condition attention weight matrix is obtained by matrix multiplication with the compression value matrix; In the cross-channel fusion module, the working condition attention matrix is divided into two sub-matrices along the mapping feature dimension, and the interaction features of the two sub-matrices are extracted by one-dimensional convolution and GELU activation function respectively to obtain two cross-channel feature matrices. The two cross-channel feature matrices are concatenated along the mapping feature dimension to obtain the cross-fusion feature matrix; The working condition attention matrix and the cross-fusion feature matrix are residually connected and then subjected to layer normalization to obtain the working condition fusion feature matrix.
[0010] Optionally, the error distribution prediction module includes an error statistics unit and an error gating fusion unit, which performs error prediction based on the working condition fusion feature matrix and generates a predicted error value vector, specifically including: Based on the working condition fusion feature matrix, obtain the working condition fusion feature vector for each time step; In the error statistics unit, the working condition fusion feature vector of each time step is input into the error prediction mean network, and a mean hidden vector is generated through a linear mapping and ReLU activation. The mean hidden vector is then used to generate the error prediction mean through a linear mapping, and the error prediction mean vector is formed according to the time steps. The condition fusion feature vector at each time step is input into the error prediction standard deviation network, and a variance hidden vector is generated through a linear mapping and ReLU activation. The variance hidden vector is used to generate the error prediction variance through a linear mapping layer and Softplus activation. The square root of the error prediction variance is calculated to obtain the error prediction standard deviation, and the error prediction standard deviation vector is formed according to the time step. In the error-gated fusion unit, the error prediction mean vector and the error prediction standard deviation vector are concatenated to obtain the error statistics vector. The error statistics vector is transformed into an error fusion gating vector by passing a linear mapping layer and Sigmoid activation. Based on the error fusion gating vector, the error prediction mean vector and the error prediction standard deviation vector are gating and fused to obtain the prediction error value vector.
[0011] Optionally, step five specifically includes: In the short-term residual modeling branch, the working condition embedding vector at each time step is used to extract local perturbation features through one-dimensional convolution to obtain a short-term perturbation residual vector sequence. In the long-term residual modeling branch, a sliding window is set, and the working condition embedding vector within the sliding window is used to extract cross-time step evolution features through a gated recurrent unit to obtain a long-term trend residual vector sequence. The short-term perturbation residual vector sequence and the long-term trend residual vector sequence are further aligned in dimension, and the short-term perturbation residual vector and the long-term trend residual vector are concatenated at each time step to obtain the residual fusion feature vector. The residual fusion feature vector is converted into residual correction values through a single linear mapping layer; In the uncertainty-guided module, the standard deviation vector of the prediction error at each time step is generated into confidence weights by passing a linear mapping layer and a Sigmoid activation layer. Based on the confidence weight, the prediction error value and the residual correction value at each time step are weighted and fused to obtain the error compensation amount; The error compensation amounts are arranged into an error compensation amount sequence according to the time steps.
[0012] Optionally, step six specifically includes: Align the original mass flow rate sequence with the error compensation sequence by time step; At each time step, the error compensation amount is subtracted from the original mass flow rate value to obtain the median mass flow rate value; By applying physical boundary constraints and rate of change constraints to the intermediate mass flow rate, a corrected mass flow rate value is obtained. The physical boundary constraints specifically refer to: obtaining the minimum and maximum measurable values of the mass flow meter; the intermediate mass flow rate value needs to be greater than or equal to the minimum measurable value and less than or equal to the maximum measurable value; The rate of change constraint is specifically defined as follows: a change threshold is set, and the difference between the median values of mass flow rates of two adjacent time steps must be less than or equal to the change threshold. If the intermediate mass flow rate does not meet the physical boundary constraints, a mass flow rate correction value is generated through constraint compensation. Specifically, if the intermediate mass flow rate is less than the minimum measurable value, the mass flow rate correction value is set to be equal to the minimum measurable value; if the intermediate mass flow rate is greater than the maximum measurable value, the mass flow rate correction value is set to be equal to the maximum measurable value. If the median mass flow rate does not meet the rate of change constraint, a corrected mass flow rate value is generated through trimming compensation. Specifically, the trimming compensation involves: Calculate the difference between the median values of mass flow rate at two adjacent time steps to obtain the change in mass flow rate; The minimum value between the change in mass flow rate and the change threshold is used as the change compensation value. The sign of the change in mass flow rate is extracted using the sign function to obtain the direction factor of change. Multiply the change direction factor by the change amount compensation value to obtain the change amount constraint value; Add the median mass flow rate of the previous time step to the change constraint value to obtain the mass flow rate correction value for the current time step; The mass flow rate correction values are arranged into a mass flow rate correction value sequence according to the time step.
[0013] Optionally, step seven specifically includes: Based on the standard error sample set, the true error label for each time step is obtained, and a true error label vector is constructed. Align the predicted error value vector with the true error label vector at the time step, and calculate the mean square error between the predicted error value vector and the true error label vector to obtain the supervised loss function; The improved TabPFN network is trained and optimized based on the supervised loss function. Calculate the sum of squares of the differences between the mass flow correction value and the mass flow reference calibration value to obtain the residual feedback loss function; Set a weighting factor, multiply the weighting factor by the residual feedback loss function, and add it to the supervision loss function to obtain the incremental feedback loss function; Incremental updates are performed on the improved TabPFN network based on the incremental feedback loss function.
[0014] The beneficial effects of this invention are: (1) The improved TabPFN network proposed in this invention includes an error modeling backbone network and an error distribution prediction module. The error modeling backbone network further integrates a working condition injection module, a Linformer modeling module, and a cross-channel cross-fusion module, which can perform low-rank attention modeling and cross-channel cross-feature fusion processing on the working condition embedded vector set, effectively improving the compression expression capability and interactive modeling efficiency of working condition information in the spatial dimension. The error distribution prediction module adds an error gating fusion unit on the basis of the original prediction mean and standard deviation output, realizing the fusion of prediction error values based on confidence statistics, enhancing the adaptability of the error distribution prediction module to different error distribution characteristics, thereby improving the stability and accuracy of error prediction.
[0015] (2) In the error compensation stage, the present invention introduces a residual correction network, which includes a short-term residual modeling branch, a long-term residual modeling branch and an uncertainty guidance module. The short-term branch extracts local perturbation features through one-dimensional convolution, the long-term branch extracts residual trend information across time steps through gated recurrent units, and the uncertainty guidance module uses the error prediction standard deviation to generate confidence weights and completes the weighted fusion of prediction error value and residual correction value. This structure realizes dynamic adjustment of error compensation amount and enhanced dual-scale fitting ability, which significantly improves the robustness of the present invention to sudden perturbations and time drift.
[0016] (3) In the process of compensating the measured value output, the present invention further introduces physical boundary constraints and rate of change constraints to perform constraint trimming and compensation control on the intermediate value of mass flow after error compensation, so as to ensure that the compensation result meets the measurement physical range and dynamic response capability of the mass flow meter, improve the engineering availability and safety of the compensation result, avoid the spread of measurement deviation caused by abnormal compensation, and ensure the stable operation and reliability of the present invention under actual working conditions. Attached Figure Description
[0017] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a schematic diagram of a mass flow meter measurement error compensation method based on deep learning proposed in this invention; Figure 2 This is a flowchart of the improved TabPFN network structure in a deep learning-based mass flow meter measurement error compensation method proposed in this invention. Figure 3 This is a flowchart of the compensation correction and engineering constraint process in a mass flow meter measurement error compensation method based on deep learning proposed in this invention. Detailed Implementation
[0018] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0019] refer to Figures 1-3 A method for compensating for measurement errors in a mass flow meter based on deep learning includes the following steps: Step 1: Collect the raw mass flow rate value sequence and operating parameter sequence of the mass flow meter to construct the raw measurement sample set; Step 2: Preprocess the original measurement sample set to generate a standard error sample set; Step 3: Embed and encode the various operating condition parameters in the standard error sample set to obtain the operating condition embedding vector set; Step 4: Input the working condition embedding vector set into the improved TabPFN network, perform working condition low-rank attention modeling, cross-channel cross-fusion and error prediction to obtain the prediction error value vector; the improved TabPFN network includes an error modeling backbone network and an error distribution prediction module; Step 5: Input the predicted error value vector and the working condition embedding vector set into the residual correction network for residual correction fusion to generate an error compensation sequence; the residual correction network includes a short-term residual modeling branch, a long-term residual modeling branch, and an uncertainty guidance module; Step 6: Based on the error compensation sequence, perform compensation correction and engineering constraints on the original mass flow rate value sequence to obtain the corrected mass flow rate value sequence; Step 7: Based on the standard error sample set, prediction error value vector, and mass flow correction value sequence, construct the supervised loss function and the incremental feedback loss function, and perform training optimization and incremental update on the improved TabPFN network respectively.
[0020] In this embodiment, step one specifically includes: The raw mass flow rate value sequence is acquired step-by-step by a mass flow meter installed on the measuring pipe; The operating condition parameter sequence is collected synchronously. The operating condition parameter sequence includes the temperature sequence of the medium to be measured, the pressure sequence of the measuring pipe where the mass flow meter is located, the density sequence of the medium to be measured, the vibration signal intensity sequence of the measuring pipe where the mass flow meter is located, and the flow state identification parameter sequence used to identify the flow state. The original mass flow rate value sequence is synchronized and paired with the operating condition parameter sequence to construct the original measurement sample set; The original mass flow rate value and operating parameters at each time step in the original measurement sample set constitute an original measurement sample.
[0021] In this embodiment, step two specifically includes: The preprocessing includes constructing true error labels, data cleaning, removing outlier samples, and normalization. Obtain the mass flow rate reference calibration value, and at each time step, calculate the difference between the original mass flow rate value and the mass flow rate reference calibration value to obtain the measurement error value, and use the measurement error value as the true error label; The actual error label of each time step is paired with the operating parameters to construct an initial error sample set; The operating condition parameter sequences in the initial error sample set are cleaned to obtain a cleaned error sample set. Specifically, the initial error samples containing missing items are removed, and the operating condition parameter sequences are formatted and converted according to the set data standards and specifications. In this invention, temperature units are standardized to degrees Celsius (e.g., 212°F Fahrenheit is converted to 100°C); pressure units are standardized to kilopascals (e.g., 1 atm is converted to 101.325 kPa); density units are standardized to kilograms per cubic meter (e.g., 0.8 g / cm³ is converted to 800 kg / m³); and non-standard time format timestamps, such as the string format "2023-11-01 08:30:15.234" or the millisecond value "1698802215234", are converted to second-level UNIX timestamps "1698802215", thus forming a cleaned sample set with consistent field structure, unified physical units, and aligned time dimensions. The Z-Score method is used to identify and remove outliers from the cleaning error sample set to obtain the effective error sample set. For example, for the temperature field sequence {75,76,77,200,74,76}, with a mean of 96.3 and a standard deviation of 48.0, the Z-Score corresponding to the 4th sample 200 is: When the threshold for the Z-Score method is set to 2.0, because... If the value is greater than 2.0, the sample at time step 200 is considered an anomalous and needs to be removed.
[0022] The minimum-maximum normalization method is used to map the values in the effective error sample set to the [0,1] interval to obtain the standard error sample set; The standard error sample set includes standard error samples for several time steps. Each standard error sample consists of a true error label, standard temperature parameter, standard pressure parameter, standard density parameter, standard vibration signal intensity parameter, and standard flow state identification parameter.
[0023] For example, for a pressure field sequence {98.5, 101.3, 100.0, 103.0}, the minimum value is 98.5 and the maximum value is 103.0. The normalized value of the original value 100.0 is then... .
[0024] In this embodiment, step three specifically includes: The standard temperature parameter, standard pressure parameter, standard density parameter, standard vibration signal intensity parameter, and standard flow state identification parameter for each time step are respectively input into an independent embedding encoding channel for feature mapping to obtain temperature embedding vector, pressure embedding vector, density embedding vector, vibration signal intensity embedding vector, and flow state identification embedding vector; The embedding encoding channel consists of a multilayer perceptron structure and a batch normalization structure. The multilayer perceptron structure includes two fully connected neural networks, each followed by a ReLU activation function. The fully connected neural network performs a linear weighted transformation on the input parameter vector to generate an intermediate feature vector. The ReLU activation function performs a nonlinear mapping on the intermediate feature vector to obtain the embedding feature vector of the corresponding working condition parameter. The batch normalization structure then performs numerical normalization processing. The temperature embedding vector, pressure embedding vector, density embedding vector, vibration signal intensity embedding vector, and flow state identification embedding vector of each time step are concatenated to obtain the working condition embedding vector, and the working condition embedding vector is arranged into a working condition embedding vector set according to the time step.
[0025] In this embodiment, the error modeling backbone network includes a working condition injection module, a Linformer modeling module, and a cross-channel fusion module. It performs low-rank attention modeling and cross-channel fusion on the working condition embedded vector set to generate a working condition fusion feature matrix, specifically including: Define a feature space and a projection space, which are used to standardize the mapping feature dimensions; In the operating condition injection module, the operating condition weight matrix is constructed based on the operating condition embedding vector set, specifically as follows: Each working condition embedding vector is mapped to the projection space through a set of fully connected layers with shared parameters to obtain a working condition factor vector. The working condition factor vectors are then arranged into a working condition factor matrix according to the time step order. Each row of the working condition factor matrix corresponds to a working condition factor vector, and each column corresponds to the working condition factor features of all time steps. The working condition weight matrix is obtained by normalizing each column of the working condition factor matrix using the Softmax function. In the Linformer modeling module, a load case weight matrix is introduced to perform low-rank attention operations on the load case embedding vector set, specifically: The working condition embedding vector set is mapped to the feature space through three sets of trainable query mapping matrices, key mapping matrices and value mapping matrices, respectively, to obtain the working condition query matrix, working condition key matrix and working condition value matrix; Based on the projection space, the projection matrix is initialized, and the low-rank linear projection is used to perform low-rank linear projection on the condition key matrix and condition value matrix respectively to obtain the compressed key matrix and compressed value matrix. The low-rank linear projection is used to compress the time step dimension. Multiply the working condition query matrix by the transpose of the compressed key matrix and divide by the square root of the mapping feature dimension of the feature space to obtain the initial attention score matrix. The initial attention score matrix is multiplied element-wise with the working condition weight matrix, and then normalized row-wise using the Softmax function to obtain the attention weight matrix. The working condition attention weight matrix is obtained by matrix multiplication with the compression value matrix; In the cross-channel fusion module, the working condition attention matrix is divided into two sub-matrices along the mapping feature dimension, and the interaction features of the two sub-matrices are extracted by one-dimensional convolution and GELU activation function respectively to obtain two cross-channel feature matrices. The two cross-channel feature matrices are concatenated along the mapping feature dimension to obtain the cross-fusion feature matrix; The working condition attention matrix and the cross-fusion feature matrix are residually connected and then subjected to layer normalization to obtain the working condition fusion feature matrix.
[0026] In this invention, the original structure of the error modeling backbone network adopts a fully connected network or a standard Transformer structure, directly modeling the embedded vector set of operating conditions. This lacks the ability to model the differences in the importance of operating condition features and is prone to high computational overhead and ineffective redundant attention when processing long-step sequences. The improved TabPFN network proposed in this invention introduces an operating condition injection module and a Linformer modeling module into its error modeling backbone network. It generates an operating condition weight matrix by constructing an operating condition factor matrix, guiding attention calculation to focus on operating condition features. Simultaneously, it uses low-rank linear projection to compress the key and value matrices in the attention calculation, significantly reducing computational complexity in the time-step dimension. Furthermore, in the cross-channel fusion module, one-dimensional convolution is used to extract nonlinear interaction features between channels, enhancing the diversity and robustness of feature representation. Through these improvements, the improved TabPFN network effectively enhances the modeling accuracy and generalization ability of measurement errors under complex operating conditions, while reducing computational resource consumption.
[0027] In this embodiment, the error distribution prediction module includes an error statistics unit and an error gating fusion unit. It performs error prediction based on the working condition fusion feature matrix and generates a prediction error value vector, specifically including: Based on the working condition fusion feature matrix, obtain the working condition fusion feature vector for each time step; In the error statistics unit, the working condition fusion feature vector of each time step is input into the error prediction mean network, and a mean hidden vector is generated through a linear mapping and ReLU activation. The mean hidden vector is then used to generate the error prediction mean through a linear mapping, and the error prediction mean vector is formed according to the time steps. The condition fusion feature vector at each time step is input into the error prediction standard deviation network, and a variance hidden vector is generated through a linear mapping and ReLU activation. The variance hidden vector is used to generate the error prediction variance through a linear mapping layer and Softplus activation. The square root of the error prediction variance is calculated to obtain the error prediction standard deviation, and the error prediction standard deviation vector is formed according to the time step. In the error-gated fusion unit, the error prediction mean vector and the error prediction standard deviation vector are concatenated to obtain the error statistics vector. The error statistics vector is transformed into an error fusion gating vector by passing a linear mapping layer and Sigmoid activation. Based on the error fusion gating vector, the error prediction mean vector and the error prediction standard deviation vector are gating and fused to obtain the prediction error value vector.
[0028] In this embodiment, step five specifically includes: In the short-term residual modeling branch, the working condition embedding vector at each time step is used to extract local perturbation features through one-dimensional convolution to obtain a short-term perturbation residual vector sequence. In the long-term residual modeling branch, a sliding window is set, and the working condition embedding vector within the sliding window is used to extract cross-time step evolution features through a gated recurrent unit to obtain a long-term trend residual vector sequence. The short-term perturbation residual vector sequence and the long-term trend residual vector sequence are further aligned in dimension, and the short-term perturbation residual vector and the long-term trend residual vector are concatenated at each time step to obtain the residual fusion feature vector. The residual fusion feature vector is converted into residual correction values through a single linear mapping layer; In the uncertainty-guided module, the standard deviation vector of the prediction error at each time step is generated into confidence weights by passing a linear mapping layer and a Sigmoid activation layer. Based on the confidence weight, the prediction error value and the residual correction value at each time step are weighted and fused to obtain the error compensation amount; The error compensation amounts are arranged into an error compensation amount sequence according to the time steps.
[0029] In this embodiment, step six specifically includes: Align the original mass flow rate sequence with the error compensation sequence by time step; At each time step, the error compensation amount is subtracted from the original mass flow rate value to obtain the median mass flow rate value; By applying physical boundary constraints and rate of change constraints to the intermediate mass flow rate, a corrected mass flow rate value is obtained. The physical boundary constraints specifically refer to: obtaining the minimum and maximum measurable values of the mass flow meter; the intermediate mass flow rate value needs to be greater than or equal to the minimum measurable value and less than or equal to the maximum measurable value; The rate of change constraint is specifically defined as follows: a change threshold is set, and the difference between the median values of mass flow rates of two adjacent time steps must be less than or equal to the change threshold. If the intermediate mass flow rate does not meet the physical boundary constraints, a mass flow rate correction value is generated through constraint compensation. Specifically, if the intermediate mass flow rate is less than the minimum measurable value, the mass flow rate correction value is set to be equal to the minimum measurable value; if the intermediate mass flow rate is greater than the maximum measurable value, the mass flow rate correction value is set to be equal to the maximum measurable value. If the median mass flow rate does not meet the rate of change constraint, a corrected mass flow rate value is generated through trimming compensation. Specifically, the trimming compensation involves: Calculate the difference between the median values of mass flow rate at two adjacent time steps to obtain the change in mass flow rate; The minimum value between the change in mass flow rate and the change threshold is used as the change compensation value. The change in mass flow rate is sign-extracted using the sign function to obtain the direction factor of change. Specifically: when the change in mass flow rate is greater than 0, the direction factor is +1, indicating that the mass flow rate is increasing; when the change in mass flow rate is less than 0, the direction factor is -1, indicating that the mass flow rate is decreasing; when the change in mass flow rate is equal to 0, the direction factor is 0, indicating that the mass flow rate has no significant change.
[0030] Multiply the change direction factor by the change amount compensation value to obtain the change amount constraint value; Add the median mass flow rate of the previous time step to the change constraint value to obtain the mass flow rate correction value for the current time step; The mass flow rate correction values are arranged into a mass flow rate correction value sequence according to the time step.
[0031] In this invention, the intermediate mass flow rate may exceed the instrument's physical measurable range due to model prediction bias, transient disturbances, or abnormal operating conditions, or abrupt changes that do not conform to actual operating conditions may occur between adjacent time steps. Therefore, physical boundary constraints and rate of change constraints must be introduced for engineering feasibility verification. Physical boundary constraints ensure that the corrected mass flow rate value always falls within the minimum and maximum measurable range of the mass flow meter, avoiding meaningless negative values or over-range outputs. Rate of change constraints limit the magnitude of mass flow rate changes between adjacent time steps, preventing drastic jumps caused by local prediction errors, thereby maintaining the continuity and stability of the measurement sequence. By using constraint compensation, the out-of-bounds intermediate mass flow rate value is clipped to the physical boundary, achieving effective backtracking of unmeasurable values. Clipping compensation limits the amplitude of out-of-bounds changes while maintaining the direction of change, ensuring that the corrected value strictly meets the maximum rate of change requirement. Combining constraint compensation and clipping compensation allows the compensation result to be mapped to a physically feasible and engineering-usable numerical domain without disrupting the error compensation trend, thereby achieving stable and reliable correction of the mass flow rate measurement results.
[0032] In this embodiment, step seven specifically includes: Based on the standard error sample set, the true error label for each time step is obtained, and a true error label vector is constructed. Align the predicted error value vector with the true error label vector at the time step, and calculate the mean square error between the predicted error value vector and the true error label vector to obtain the supervised loss function; The improved TabPFN network is trained and optimized based on the supervised loss function. Calculate the sum of squares of the differences between the mass flow correction value and the mass flow reference calibration value to obtain the residual feedback loss function; Set a weighting factor, multiply the weighting factor by the residual feedback loss function, and add it to the supervision loss function to obtain the incremental feedback loss function; Incremental updates are performed on the improved TabPFN network based on the incremental feedback loss function.
[0033] In this invention, a supervised loss function is used to constrain the predicted error value by leveraging the known true error labels in the standard error sample set. This allows the improved TabPFN network to fully learn the stable mapping relationship between operating parameters and measurement errors during the training phase, thereby ensuring reliable basic modeling accuracy. By introducing residual feedback between the mass flow correction value and the actual calibration value and adjusting it with weighting factors, an incremental feedback loss function is constructed. This function performs small-amplitude, targeted incremental updates to the parameters of the improved TabPFN network, enabling it to continuously absorb differences caused by new operating conditions, new equipment characteristics, or long-term drift without compromising its original modeling capabilities. This achieves online adaptive optimization and long-term stable operation of the error compensation model.
[0034] Example To verify the feasibility of this invention in practice, the method was applied to a high-pressure fluid transport system in a chemical plant. This system uses Coriolis mass flow meters to monitor and control the mass flow rate of different media under various operating conditions in real time. The plant experiences problems such as pipeline pressure fluctuations, media density changes, equipment vibration interference, and frequent temperature fluctuations during production, which severely affect the measurement accuracy of the mass flow meters. Traditional error compensation methods based on fixed models or single calibration points are ill-suited to these complex conditions, resulting in flow measurement errors exceeding ±3% in certain time periods, impacting subsequent batching and energy consumption optimization.
[0035] In the implementation scenario, industrial field data was collected over 12 consecutive hours, including raw mass flow rate sequences, medium temperature, pipeline pressure, fluid density, vibration signal intensity, and flow state indicators. Reference mass flow rates measured by a high-precision standard device under ideal operating conditions were used as the calibration basis to construct measurement error labels. After preprocessing, the standard error sample set was input into an improved TabPFN network for training and inference. To further improve compensation accuracy, a residual correction network was introduced to perform secondary correction of the prediction error. Simultaneously, at the output end, physical boundary and rate of change constraint strategies ensured the engineering controllability of the compensation results.
[0036] To further evaluate the effectiveness of the method of this invention, a comparative experiment was conducted with the traditional static calibration method and the error modeling method based on support vector regression. The mean error, standard deviation of error, maximum error amplitude, stability of error rate of change, model generalization error, and average delay of a single inference were selected for comparative testing. The comparison results are shown in Table 1.
[0037] Table 1. Performance Comparison of Different Methods in Error Compensation of Industrial Mass Flow Meters
[0038] As shown in Table 1, the method of this invention exhibits significant performance advantages in mass flow error compensation tasks. Regarding the mean error, the method reduces the average error to 0.47 kg / h, a reduction of 82.8% compared to the traditional static calibration method and 68.9% compared to the error modeling method based on support vector regression, significantly improving the accuracy of the measurement results. In terms of the standard deviation of the error, the method of this invention is only 0.29 kg / h, far lower than the comparative methods, indicating that its prediction results are more stable and less volatile. Regarding the control of the maximum error amplitude, the method of this invention controls the maximum error to within 1.65 kg / h, far superior to the 6.12 kg / h of the traditional static calibration method, demonstrating the robustness of the method under extreme operating conditions.
[0039] Furthermore, the standard deviation of the error rate of change of the method of this invention is only 0.21, indicating that the method of this invention fits the error change trend more smoothly and avoids drastic fluctuations in measurement results under dynamic operating conditions. Regarding the evaluation of model generalization ability, the generalization error of the method of this invention on unseen data is 0.53 kg / h, significantly better than the 1.29 kg / h of the error modeling method based on support vector regression, verifying that the method of this invention can maintain good versatility under complex operating conditions. In edge deployment scenarios, the average latency of a single inference of the method of this invention is 9.2 milliseconds, lower than the 13.6 milliseconds of the error modeling method based on support vector regression, further demonstrating that the method of this invention has stronger engineering adaptability in meeting the requirements of high-frequency real-time compensation.
[0040] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for compensating for measurement errors in a mass flow meter based on deep learning, characterized in that, Includes the following steps: Step 1: Collect the raw mass flow rate value sequence and operating parameter sequence of the mass flow meter to construct the raw measurement sample set; Step 2: Preprocess the original measurement sample set to generate a standard error sample set; Step 3: Embed and encode the various operating condition parameters in the standard error sample set to obtain the operating condition embedding vector set; Step 4: Input the working condition embedding vector set into the improved TabPFN network, perform working condition low-rank attention modeling, cross-channel cross-fusion and error prediction to obtain the prediction error value vector; the improved TabPFN network includes an error modeling backbone network and an error distribution prediction module; Step 5: Input the predicted error value vector and the working condition embedding vector set into the residual correction network for residual correction fusion to generate an error compensation sequence; the residual correction network includes a short-term residual modeling branch, a long-term residual modeling branch, and an uncertainty guidance module; Step 6: Based on the error compensation sequence, perform compensation correction and engineering constraints on the original mass flow rate value sequence to obtain the corrected mass flow rate value sequence; Step 7: Based on the standard error sample set, prediction error value vector, and mass flow correction value sequence, construct the supervised loss function and the incremental feedback loss function, and perform training optimization and incremental update on the improved TabPFN network respectively.
2. The method for compensating for measurement errors of a mass flow meter based on deep learning according to claim 1, characterized in that, Step one specifically includes: The raw mass flow rate value sequence is acquired step-by-step by a mass flow meter installed on the measuring pipe; The operating condition parameter sequence is collected synchronously. The operating condition parameter sequence includes the temperature sequence of the medium to be measured, the pressure sequence of the measuring pipe where the mass flow meter is located, the density sequence of the medium to be measured, the vibration signal intensity sequence of the measuring pipe where the mass flow meter is located, and the flow state identification parameter sequence used to identify the flow state. The original mass flow rate value sequence is synchronized and paired with the operating condition parameter sequence to construct the original measurement sample set; The original mass flow rate value and operating parameters at each time step in the original measurement sample set constitute an original measurement sample.
3. The method for compensating for measurement errors of a mass flow meter based on deep learning according to claim 1, characterized in that, Step two specifically includes: The preprocessing includes constructing true error labels, data cleaning, removing outlier samples, and normalization. Obtain the mass flow rate reference calibration value, and at each time step, calculate the difference between the original mass flow rate value and the mass flow rate reference calibration value to obtain the measurement error value, and use the measurement error value as the true error label; The actual error label of each time step is paired with the operating parameters to construct an initial error sample set; The operating condition parameter sequences in the initial error sample set are cleaned to obtain a cleaned error sample set. Specifically, the initial error samples containing missing items are removed, and the operating condition parameter sequences are formatted and converted according to the set data standards and specifications. The Z-Score method is used to identify and remove abnormal samples from the cleaning error sample set to obtain the effective error sample set; The minimum-maximum normalization method is used to map the values in the effective error sample set to the interval [0,1] to obtain the standard error sample set.
4. The method for compensating for measurement errors of a mass flow meter based on deep learning according to claim 1, characterized in that, Step three specifically includes: The standard temperature parameter, standard pressure parameter, standard density parameter, standard vibration signal intensity parameter, and standard flow state identification parameter for each time step are respectively input into an independent embedding encoding channel for feature mapping to obtain temperature embedding vector, pressure embedding vector, density embedding vector, vibration signal intensity embedding vector, and flow state identification embedding vector; The embedded coding channel consists of a multilayer perceptron structure and a batch normalization structure. The multilayer perceptron structure includes two fully connected neural networks, with each fully connected neural network followed by a ReLU activation function. The temperature embedding vector, pressure embedding vector, density embedding vector, vibration signal intensity embedding vector, and flow state identification embedding vector of each time step are concatenated to obtain the working condition embedding vector, and the working condition embedding vector is arranged into a working condition embedding vector set according to the time step.
5. The method for compensating for measurement errors of a mass flow meter based on deep learning according to claim 1, characterized in that, The error modeling backbone network includes a working condition injection module, a Linformer modeling module, and a cross-channel fusion module. It performs low-rank attention modeling and cross-channel fusion on the working condition embedded vector set to generate a working condition fusion feature matrix. Specifically, it includes: Define a feature space and a projection space, which are used to standardize the mapping feature dimensions; In the operating condition injection module, the operating condition weight matrix is constructed based on the operating condition embedding vector set, specifically as follows: Each working condition embedding vector is mapped to the projection space through a set of fully connected layers with shared parameters to obtain working condition factor vectors, and the working condition factor vectors are arranged into a working condition factor matrix according to the time step order. The working condition weight matrix is obtained by normalizing each column of the working condition factor matrix using the Softmax function. In the Linformer modeling module, a load case weight matrix is introduced to perform low-rank attention operations on the load case embedding vector set, specifically: The working condition embedding vector set is mapped to the feature space through three sets of trainable query mapping matrices, key mapping matrices and value mapping matrices, respectively, to obtain the working condition query matrix, working condition key matrix and working condition value matrix; Based on the projection space, the projection matrix is initialized, and the low-rank linear projection is used to perform low-rank linear projection on the condition key matrix and condition value matrix respectively to obtain the compressed key matrix and compressed value matrix. The low-rank linear projection is used to compress the time step dimension. Multiply the working condition query matrix by the transpose of the compressed key matrix and divide by the square root of the mapping feature dimension of the feature space to obtain the initial attention score matrix. The initial attention score matrix is multiplied element-wise with the working condition weight matrix, and then normalized row-wise using the Softmax function to obtain the attention weight matrix. The working condition attention weight matrix is obtained by matrix multiplication with the compression value matrix; In the cross-channel fusion module, the working condition attention matrix is divided into two sub-matrices along the mapping feature dimension, and the interaction features of the two sub-matrices are extracted by one-dimensional convolution and GELU activation function respectively to obtain two cross-channel feature matrices. The two cross-channel feature matrices are concatenated along the mapping feature dimension to obtain the cross-fusion feature matrix; The working condition attention matrix and the cross-fusion feature matrix are residually connected and then subjected to layer normalization to obtain the working condition fusion feature matrix.
6. The method for compensating for measurement errors of a mass flow meter based on deep learning according to claim 1, characterized in that, The error distribution prediction module includes an error statistics unit and an error gating fusion unit. It performs error prediction based on the operating condition fusion feature matrix, generating a predicted error value vector. Specifically, it includes: Based on the working condition fusion feature matrix, obtain the working condition fusion feature vector for each time step; In the error statistics unit, the working condition fusion feature vector of each time step is input into the error prediction mean network, and a mean hidden vector is generated through a linear mapping and ReLU activation. The mean hidden vector is then used to generate the error prediction mean through a linear mapping, and the error prediction mean vector is formed according to the time steps. The condition fusion feature vector at each time step is input into the error prediction standard deviation network, and a variance hidden vector is generated through a linear mapping and ReLU activation. The variance hidden vector is used to generate the error prediction variance through a linear mapping layer and Softplus activation. The square root of the error prediction variance is calculated to obtain the error prediction standard deviation, and the error prediction standard deviation vector is formed according to the time step. In the error-gated fusion unit, the error prediction mean vector and the error prediction standard deviation vector are concatenated to obtain the error statistics vector. The error statistics vector is transformed into an error fusion gating vector by passing a linear mapping layer and Sigmoid activation. Based on the error fusion gating vector, the error prediction mean vector and the error prediction standard deviation vector are gating and fused to obtain the prediction error value vector.
7. The method for compensating for measurement errors of a mass flow meter based on deep learning according to claim 1, characterized in that, Step five specifically includes: In the short-term residual modeling branch, the working condition embedding vector at each time step is used to extract local perturbation features through one-dimensional convolution to obtain a short-term perturbation residual vector sequence. In the long-term residual modeling branch, a sliding window is set, and the working condition embedding vector within the sliding window is used to extract cross-time step evolution features through a gated recurrent unit to obtain a long-term trend residual vector sequence. The short-term perturbation residual vector sequence and the long-term trend residual vector sequence are further aligned in dimension, and the short-term perturbation residual vector and the long-term trend residual vector are concatenated at each time step to obtain the residual fusion feature vector. The residual fusion feature vector is converted into residual correction values through a single linear mapping layer; In the uncertainty-guided module, the standard deviation vector of the prediction error at each time step is generated into confidence weights by passing a linear mapping layer and a Sigmoid activation layer. Based on the confidence weight, the prediction error value and the residual correction value at each time step are weighted and fused to obtain the error compensation amount; The error compensation amounts are arranged into an error compensation amount sequence according to the time steps.
8. The method for compensating for measurement errors of a mass flow meter based on deep learning according to claim 1, characterized in that, Step six specifically includes: Align the original mass flow rate sequence with the error compensation sequence by time step; At each time step, the error compensation amount is subtracted from the original mass flow rate value to obtain the median mass flow rate value; By applying physical boundary constraints and rate of change constraints to the intermediate mass flow rate, a corrected mass flow rate value is obtained. The physical boundary constraints specifically refer to: obtaining the minimum and maximum measurable values of the mass flow meter; the intermediate mass flow rate value needs to be greater than or equal to the minimum measurable value and less than or equal to the maximum measurable value; The rate of change constraint is specifically defined as follows: a change threshold is set, and the difference between the median values of mass flow rates of two adjacent time steps must be less than or equal to the change threshold. If the intermediate mass flow rate does not meet the physical boundary constraints, a mass flow rate correction value is generated through constraint compensation. Specifically, if the intermediate mass flow rate is less than the minimum measurable value, the mass flow rate correction value is set to be equal to the minimum measurable value; if the intermediate mass flow rate is greater than the maximum measurable value, the mass flow rate correction value is set to be equal to the maximum measurable value. If the median mass flow rate does not meet the rate of change constraint, a corrected mass flow rate value is generated through trimming compensation. Specifically, the trimming compensation involves: Calculate the difference between the median values of mass flow rate at two adjacent time steps to obtain the change in mass flow rate; The minimum value between the change in mass flow rate and the change threshold is used as the change compensation value. The sign of the change in mass flow rate is extracted using the sign function to obtain the direction factor of change. Multiply the change direction factor by the change amount compensation value to obtain the change amount constraint value; Add the median mass flow rate of the previous time step to the change constraint value to obtain the mass flow rate correction value for the current time step; The mass flow rate correction values are arranged into a mass flow rate correction value sequence according to the time step.
9. The method for compensating for measurement errors of a mass flow meter based on deep learning according to claim 1, characterized in that, Step seven specifically includes: Based on the standard error sample set, the true error label for each time step is obtained, and a true error label vector is constructed. Align the predicted error value vector with the true error label vector at the time step, and calculate the mean square error between the predicted error value vector and the true error label vector to obtain the supervised loss function; The improved TabPFN network is trained and optimized based on the supervised loss function. Calculate the sum of squares of the differences between the mass flow correction value and the mass flow reference calibration value to obtain the residual feedback loss function; Set a weighting factor, multiply the weighting factor by the residual feedback loss function, and add it to the supervision loss function to obtain the incremental feedback loss function; Incremental updates are performed on the improved TabPFN network based on the incremental feedback loss function.