Industrial low-flow virtual detection method based on semi-supervised variational auto-encoder
Through the semi-supervised variational autoencoder model, the problem of low flow detection in industrial processes is solved, accurate estimation of fluids in different flow ranges is achieved, the cost of virtual sensors is reduced, and the stable operation and data support of the system are ensured.
Patent Information
- Application Number
- CN202410742465.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-24
AI Technical Summary
In industrial processes, under low flow conditions, traditional vortex flowmeters cannot effectively detect flow, and the high price of mass flow meters limits their widespread application, making low flow monitoring problems difficult to solve.
An industrial low-flow virtual detection method based on semi-supervised variational autoencoders is adopted. By constructing a variational autoencoder model and using unlabeled and labeled data for iterative training, virtual sensors are generated to achieve reliable detection of fluids in different flow ranges. Accurate estimate.
This method not only reduces the cost of virtual sensors, but also enables accurate estimation of flow data in industrial environments, fills gaps in low flow data, ensures safe and stable operation of the system, and improves data support for process monitoring and optimal control.
Smart Images

Figure CN118690337A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of flow detection, and in particular to an industrial low-flow virtual detection method based on a semi-supervised variational autoencoder. Background Art
[0002] In modern industrial processes, it is very important to monitor key sensor variables to ensure that the industrial process system is in a safe and stable operating condition. However, due to the harsh working environment and expensive analysis costs, it is quite difficult to monitor or measure key sensor variables online. Therefore, virtual sensors are developed by researchers to establish mathematical models through easy-to-measure process variables to estimate sensor variables that are difficult to measure in real time.
[0003] In recent years, with the continuous improvement of data collection, data transmission and data storage capabilities, data-driven virtual sensor modeling methods have become more and more popular. For example, principal component regression, partial least squares regression, artificial neural network and support vector regression are widely used in the field of virtual sensor modeling. However, most of these models can be considered as shallow neural networks with only one or no hidden layer, which do not have the ability to automatically extract features. Therefore, the models built using shallow neural network models are often not accurate. Compared with traditional shallow neural networks, deep neural networks have a deeper network structure and can automatically abstract the underlying features into high-level features for the network to learn, thereby improving the modeling accuracy of virtual sensors. Common modeling methods based on deep neural networks include deep belief networks, convolutional neural networks, recurrent neural networks and autoencoders.
[0004] In industrial process systems, real-time monitoring of low flow is a major challenge in the field of process control. At present, vortex flowmeters are widely used in industrial process systems. Vortex flowmeter is a flow detection device based on the Karman vortex effect. Its working principle is based on the alternating vortices caused by the vortex body on the cross section of the pipeline when the fluid flows through it. The existence of the vortex body causes the fluid to produce regular vortex vibrations, thereby forming a regular pulse pressure signal. The built-in sensor calculates the flow rate by detecting these pressure pulsations. When the flow rate in the pipeline is low, the vortex vibration caused by the fluid passing through the vortex body is relatively small, which further leads to a weak amplitude of the pulse pressure signal. The sensor cannot detect and analyze these weak signals, resulting in the flow sensor reading directly returning to zero under low flow conditions. Therefore, the vortex flowmeter cannot effectively detect low flow. Although another mass flowmeter can detect low flow sensitively and accurately, its high price limits its widespread use in industrial process systems. Summary of the invention
[0005] In view of this, the present invention provides an industrial low-flow virtual detection method based on a semi-supervised variational autoencoder. Compared with traditional flow sensors, the flow virtual sensor model is not only inexpensive, but also can achieve reliable and accurate virtual estimation of fluids within different flow ranges, and also provides effective data support for downstream process monitoring and optimization control.
[0006] The technical purpose of the present invention is achieved in this way:
[0007] The present invention provides an industrial low-flow virtual detection method based on a semi-supervised variational autoencoder, comprising the following steps:
[0008] S1 collects flow data through sensors on the industrial process test platform, constructs a data set, and divides the data set into a training set, a validation set, and a test set in proportion;
[0009] S2 uses a screening method to divide the training set into a first subset and a second subset, retains the label of the first subset as labeled data, and deletes the label of the second subset as unlabeled data;
[0010] S3 builds a variational autoencoder model, and iteratively trains and tests the variational autoencoder model using unlabeled data, labeled data, validation sets, and test sets to obtain a trained variational autoencoder model;
[0011] S4 uses the trained variational autoencoder model as a virtual sensor and uses the virtual sensor to predict traffic data to obtain prediction results.
[0012] Based on the above technical solution, preferably, step S2 includes:
[0013] S21 sets the flow threshold T flow , and define the label assignment function L, and denote the training set as X = {x i}, where x i is the i-th flow data in the training set;
[0014] S22 selects a flow data x in the training set X i , whose label is F i ;
[0015] S23 Judgement F i With flow threshold T flow If F i >T flow , then x i Tags F i Substitute the label assignment function L and set L(x i )=1, let it be x i The label value of i ≤Tflow , then x i Tags F i Substitute the label assignment function L and set L(x i )=0, let it be x i The label value of
[0016] S24 repeats steps S22-S23 to obtain label values of all traffic data in the training set X;
[0017] S25 divides the training set X into the first subset X based on the label value of each traffic data in the training set X l and the second subset X u , where the first subset X l The label value of the second subset X u The label value of x is 0. l ={x i |L(x i )=1,x i ∈X},X u ={x i |L(x i )=0,x i ∈X};
[0018] S26 For the first subset X l The traffic data in retains its label as labeled data; for the second subset X u The traffic data in , sets its label to empty, as unlabeled data.
[0019] Based on the above technical solution, preferably, step S3 includes:
[0020] S31 builds a variational autoencoder model, including an encoder network, a regression block, and a decoder network;
[0021] S32 uses unlabeled data to perform unsupervised pre-training on the variational autoencoder model, optimizes the parameters of the variational autoencoder model by minimizing the variational lower bound of the unlabeled data, and obtains a pre-trained variational autoencoder model;
[0022] S33 uses labeled data to perform supervised fine-tuning on the pre-trained variational autoencoder model. By minimizing the variational lower bound of labeled data and introducing label reconstruction loss and pseudo-variational loss, the parameters of the variational autoencoder model are optimized to obtain the fine-tuned variational autoencoder model.
[0023] S34 repeats steps S32-S33, and after each training round, introduces a dynamic adaptive adjustment strategy, and uses the verification set to verify the fine-tuned variational autoencoder model to obtain the optimal variational autoencoder model;
[0024] S35 uses the optimal variational autoencoder model to perform performance evaluation on the test set. If the performance evaluation fails, return to step S32 for retraining; if the performance evaluation passes, output the optimal variational autoencoder model as the trained variational autoencoder model.
[0025] Based on the above technical solution, preferably, step S32 includes:
[0026] S321 samples a batch of unlabeled data samples from the second subset, and inputs the sampled unlabeled data samples into the encoder network to obtain a prior distribution of the latent variables;
[0027] S322 samples latent variables from the prior distribution, and inputs the sampled latent variables into a decoder network to obtain a reconstructed sample;
[0028] S323 calculates the first reconstruction error of the variational autoencoder model and the first KL divergence error of the latent variable based on the unlabeled data sample and the reconstructed sample, and constructs a variational lower bound of the unlabeled data;
[0029] S324 uses the gradient descent algorithm to minimize the variational lower bound of unlabeled data and updates the parameters of the encoder network and decoder network according to the error back propagation;
[0030] S325 repeats steps S321-S324 until a preset training round is reached or an early stopping condition is met, thereby obtaining a pre-trained variational autoencoder model.
[0031] Based on the above technical solution, preferably, in step S323, the calculation formula of the variational lower bound of unlabeled data is:
[0032]
[0033] In the formula, Rec.loss1 represents the variational lower bound of unlabeled data; Rec.loss1 represents the first reconstruction error, which is used to measure the difference between the unlabeled data sample reconstructed by the decoder network and the original data sample; KL.loss1 represents the first KL divergence error of the latent variable, which is used to measure the difference between the prior distribution and the posterior distribution; It represents the entropy of the variational distribution of the target variable, which is used to replace the label error of unlabeled data; PVloss1 represents the first pseudo variational loss, which is used to replace the KL divergence loss of directly calculating the increment of the target variable.
[0034] On the basis of the above technical solution, preferably, the calculation formula of the first reconstruction error Rec.loss1 is:
[0035]
[0036] In the formula, represents the encoder network, φ z are the parameters of the encoder network, z|x represents the conditional probability distribution that maps the input data x to the latent variable z; represents the decoder network, θ x are the parameters of the decoder network, x|z represents the conditional probability distribution that maps the latent variable z back to the data x; Based on the encoder network The expectation of the latent variable z; Based on the decoder network Log-likelihood of input data x;
[0037] The calculation formula of the first KL divergence error KL.loss1 of the latent variable is:
[0038]
[0039] Where D KL is the KL divergence; Based on regression block The expectation of the target variable y; is the prior distribution, z|y represents the probability distribution of the latent variable z given the target variable y, θ z is the parameter of the prior distribution; φ y are the parameters of the regression block;
[0040] Entropy of the variational distribution of the target variable The calculation formula is:
[0041]
[0042] In the formula, Represents a Gaussian distribution The expectation of the target variable y; f(x u ; φ y ) and g(x u ; φ y ) are two mapping functions, which transform the unlabeled data samples x u Mapped to the mean and variance of a Gaussian distribution;
[0043] The calculation formula of the first pseudo-variation loss PVloss1 is:
[0044]
[0045] In the formula, z t+1 |x t+1 Indicates that the input data x at time step t+1 t+1Mapped to the latent variable z at time step t+1 t+1 The conditional probability distribution of y t +Δy t |Δy t+1 represents the target variable y at time step t t Plus the target variable increment Δy at time step t t , the target variable increment Δy at a given time step t+1 t+1 The probability distribution under the condition of .
[0046] Based on the above technical solution, preferably, step S33 includes:
[0047] S331 extracts a batch of labeled data samples from the first subset, each labeled data sample includes an input process variable and a corresponding target variable true value;
[0048] S332 inputs the process variables in the labeled data sample into the encoder network, and calculates the latent variables corresponding to each process variable and the mean and variance of the Gaussian distribution obeyed by the latent variables through the encoder network;
[0049] S333 inputs the process variables in the labeled data sample into the regression block, and calculates the target variable prediction value corresponding to each process variable and the mean and variance of the Gaussian distribution obeyed by the target variable prediction value through the regression block;
[0050] S334 calculates the increment of the target variable between the current time step and the next time step based on the regression block and constructs a pseudo variational distribution;
[0051] S335 combines the target variable prediction value of the current time step with the target variable increment to calculate the potential variable corresponding to the current time step; combines the target variable prediction value of the current time step, the target variable increment of the current time step and the target variable increment of the next time step to approximately calculate the potential variable corresponding to the next time step;
[0052] S336 Construct variational lower bounds for labeled data;
[0053] S337 uses the stochastic gradient descent algorithm to minimize the variational lower bound of labeled data and updates the parameters of the encoder network, decoder network, and regression block through back propagation of errors;
[0054] S338 repeats steps S331-S337 until the preset training round is reached or the early termination condition is met, and the fine-tuned variational autoencoder model is output.
[0055] Based on the above technical solution, preferably, in step S336, the calculation formula of the variational lower bound of labeled data is:
[0056]
[0057] In the formula, Rec.loss2 represents the variational lower bound of labeled data; Rec.loss2 represents the second reconstruction error, which is used to measure the difference between the process variables reconstructed by the decoder network based on the latent variables and the original process variables; KL.loss2 represents the second KL divergence error of the latent variable, which is used to measure the difference between the variational posterior distribution of the latent variable and its prior distribution; Label.loss represents the label error, which is measured by calculating the KL divergence between the variational posterior distribution of the predicted value of the target variable and the empirical distribution of the true value of the target variable in the labeled data; PVloss2 represents the second pseudo-variational loss, which is used instead of directly calculating the KL divergence of the target variable increment.
[0058] On the basis of the above technical solution, preferably, the calculation formula of the second reconstruction error Rec.loss2 is:
[0059]
[0060] In the formula, Representation based on encoder network Calculate expectations; is the decoder network, which reconstructs x with the latent variable z as input; x is the input process variable; z is the latent variable; φ z are the parameters of the encoder network; θ x are the parameters of the decoder network;
[0061] The calculation formula of the second KL divergence error KL.loss2 of the latent variable is:
[0062]
[0063] In the formula, Represents a regression block Calculate expectation; D KL represents KL divergence; is the encoder network, which maps the input x to the latent variable z; represents the prior distribution of the latent variable conditioned on the target variable y; y is the true value of the target variable; φ y is the parameter of the regression block; θ z Parameters representing the prior distribution of the latent variable;
[0064] The calculation formula of label error Label.loss is:
[0065]
[0066] In the formula, represents a regression block that predicts the approximate posterior distribution of the target variable y, conditioned on the input x, φ y is the parameter of the regression block; p(y) represents the prior distribution of the target variable y;
[0067] The calculation formula of the second pseudo-variation loss PVloss2 is:
[0068]
[0069] In the formula, z t+1 |x t+1 Indicates that the input data x at time step t+1 t+1 Mapped to the latent variable z at time step t+1 t+1 The conditional probability distribution of y t +Δy t |Δy t+1 represents the target variable y at time step t t Plus the target variable increment Δy at time step t t , the target variable increment Δy at a given time step t+1 t+1 The probability distribution under the condition of .
[0070] Based on the above technical solution, preferably, the total loss function of the variational autoencoder model is:
[0071]
[0072] In the formula, is the total loss function; x t represents the input data at time step t; x t+1 Represents the input data at time step t+1; represents the variational lower bound of labeled data at time step t; represents the variational lower bound of unlabeled data at time step t and time step t+1; represents an encoder network that maps input data x to a probability distribution of latent variables z; is the decoder network, which represents the latent variable z y Reconstruct the data x at time step t t The probability distribution of It represents the expectation of the probability distribution of the latent variables output by the encoder network.
[0073] The method of the present invention has the following beneficial effects compared with the prior art:
[0074] (1) The present invention uses a virtual sensor modeling method to fill the gap in the low-flow data part to further ensure the safe and stable operation of the industrial system;
[0075] (2) The present invention regards small flow data that cannot be monitored in industrial environments and has erroneous label data as unlabeled data, and uses the probability inference of the variational autoencoder to express the potential spatial distribution of the flow data in the form of probability. At the same time, using high flow data with normal label data, additional flow-related features are learned to reflect the mapping relationship between flow and other process variables, thereby improving the accuracy of flow prediction;
[0076] (3) The present invention adopts a semi-supervised pre-training strategy. The entire pre-training process is unsupervised, which can ensure that the model can fully capture the changes in sample data during the training process and automatically adjust the training strategy to adapt to the characteristics of traffic data in industrial environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0078] Figure 1 is a flow chart of a method according to an embodiment of the present invention;
[0079] Figure 2 This is a model training diagram of an embodiment of the present invention;
[0080] Figure 3 This is a diagram of prediction results according to an embodiment of the present invention. DETAILED DESCRIPTION
[0081] The following will be combined with the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0082] like Figure 1 As shown, the present invention provides an industrial low-flow virtual detection method based on a semi-supervised variational autoencoder, comprising the following steps:
[0083] S1 collects flow data through sensors on the industrial process test platform, constructs a data set, and divides the data set into a training set, a validation set, and a test set in proportion;
[0084] S2 uses a screening method to divide the training set into a first subset and a second subset, retains the label of the first subset as labeled data, and deletes the label of the second subset as unlabeled data;
[0085] S3 builds a variational autoencoder model, and iteratively trains and tests the variational autoencoder model using unlabeled data, labeled data, validation sets, and test sets to obtain a trained variational autoencoder model;
[0086] S4 uses the trained variational autoencoder model as a virtual sensor and uses the virtual sensor to predict traffic data to obtain prediction results.
[0087] Specifically, in one embodiment of the present invention, step S1 includes:
[0088] S11 Data Collection: For a certain industrial production process, collect flow data over a period of time. The collected data should include various process variables related to flow (such as temperature, pressure, liquid level, etc.) as model inputs, and the corresponding flow values as model outputs.
[0089] S12 Data preprocessing: Clean and preprocess the collected data.
[0090] Remove outliers: Use statistical methods or expert knowledge to determine data anomalies and remove or replace abnormal data.
[0091] Missing value processing: interpolation to fill missing data or delete samples with too many missing values.
[0092] Data normalization: Normalize the data of each dimension to make its mean 0 and variance 1 to ensure the comparability of features of different dimensions.
[0093] S13 Dataset construction: The preprocessed data is constructed into a data set in a time series manner. Each data sample includes the process variable at time t (model input) and the corresponding flow value at time t (model output).
[0094] S14 Dataset division: Divide the dataset into three parts: training set, validation set and test set according to a certain ratio.
[0095] In a specific embodiment of the present invention:
[0096] The inlet and outlet temperatures of the chiller, the outlet temperature of the steam generator, the liquid level pressure of the regulator, etc. collected by sensors on the industrial process test platform are used as characteristic signals as the input of the model, and the coolant flow rate is used as the output of the model to construct the virtual sensor model training and test data sets. The training data set includes 2500 samples, and the test data set includes 885 samples.
[0097] Specifically, in one embodiment of the present invention, step S2 includes:
[0098] S21 sets the flow threshold T flow , and define the label assignment function L, and denote the training set as X = {x i}, where x i is the i-th flow data in the training set;
[0099] S22 selects a flow data x in the training set X i , whose label is F i ;
[0100] S23 Judgement F i With flow threshold T flow If F i >T flow , then x i Tags F i Substitute the label assignment function L and set L(x i )=1, let it be x i The label value of i ≤T flow , then x i Tags F i Substitute the label assignment function L and set L(x i )=0, let it be x i The label value of
[0101] S24 repeats steps S22-S23 to obtain label values of all traffic data in the training set X;
[0102] S25 divides the training set X into the first subset X based on the label value of each traffic data in the training set X l and the second subset X u , where the first subset X l The label value of the second subset X u The label value of X is 0. l ={x i |L(x i )=1,x i ∈X},X u ={x i |L(x i )=0,x i ∈X};
[0103] S26 For the first subset X l The traffic data in retains its label as labeled data; for the second subset X u The traffic data in , sets its label to empty, as unlabeled data.
[0104] Specifically, in this embodiment, according to the flow threshold T flow The training set is divided into two parts: high traffic (first subset) and low traffic (second subset). The high traffic subset retains label information as labeled data, while the label information of the low traffic subset is deleted as unlabeled data. This division method makes full use of the label information of some samples, while also considering the feature information of a large number of unlabeled samples, laying the foundation for subsequent semi-supervised learning.
[0105] In this embodiment, the flow threshold T flow Set to 10L / min. That is, when the actual flow data measured by the flow sensor is greater than 10L / min, the data measured by the flow sensor is considered correct and can be used as label data for model training; when the flow data measured by the flow sensor is between 0 and 10L / min, the test data at this time is often directly reset to zero. For these erroneous low flow data, the erroneous label data is deleted and marked as unlabeled data for model training.
[0106] Specifically, in one embodiment of the present invention, step S3 includes:
[0107] S31 builds a variational autoencoder model, including an encoder network, a regression block, and a decoder network;
[0108] S32 uses unlabeled data to perform unsupervised pre-training on the variational autoencoder model, optimizes the parameters of the variational autoencoder model by minimizing the variational lower bound of the unlabeled data, and obtains a pre-trained variational autoencoder model;
[0109] S33 uses labeled data to perform supervised fine-tuning on the pre-trained variational autoencoder model. By minimizing the variational lower bound of labeled data and introducing label reconstruction loss and pseudo-variational loss, the parameters of the variational autoencoder model are optimized to obtain the fine-tuned variational autoencoder model.
[0110] S34 repeats steps S32-S33, and after each training round, introduces a dynamic adaptive adjustment strategy, and uses the verification set to verify the fine-tuned variational autoencoder model to obtain the optimal variational autoencoder model;
[0111] S35 uses the optimal variational autoencoder model to perform performance evaluation on the test set. If the performance evaluation fails, return to step S32 for retraining; if the performance evaluation passes, output the optimal variational autoencoder model as the trained variational autoencoder model.
[0112] Specifically, a multi-level semi-supervised variational autoencoder model is first constructed, which includes an encoder network and a decoder network, and a regression block is introduced to construct a nonlinear mapping relationship between the target variable and the latent space.
[0113] In the embodiment of the present invention, unsupervised training and supervised fine-tuning of the model are performed using unlabeled and labeled traffic training data, respectively. In this process, the model training process and the fine-tuning process can be further summarized as follows:
[0114] (1) Based on the input process variable x t Compute the latent space representation z t ,
[0115]
[0116] Among them, f(·) and g(·) represent two mapping functions.
[0117] (2) Based on the input process variable x t Calculate the target variable y t ,
[0118]
[0119] (3) Calculate the pseudo-variation of the regression block to facilitate the subsequent calculation of the pseudo-variation loss;
[0120] Δy t =f(x t ; φ Δy ), Δy t+1 =f(x t+1 ; φ Δy )
[0121] (4) Generate a latent expression for time step t;
[0122]
[0123] (5) Approximately calculate the potential expression at time step t+1;
[0124]
[0125] (6) Calculate the loss function, i.e., the variational lower bound;
[0126] The loss functions of the semi-supervised variational autoencoder include reconstruction error (Rec.loss), KL divergence error (KL.loss), label error (Label.loss), etc. Their respective definitions are as follows:
[0127]
[0128]
[0129]
[0130]
[0131] Among them, q(z|x) represents the encoding network of the variational autoencoder, and p(x|z) represents the decoding network. Therefore, for labeled data, the loss function can be defined as:
[0132]
[0133] However, for practical industrial systems, the predicted distribution of Δy The true distribution p(Δy) may be in a high-dimensional space. Using KL divergence to calculate the difference between the two distributions may make the model calculation very expensive. Therefore, it is unrealistic to directly calculate Δy.loss. This embodiment uses pseudo-variational loss PVloss to replace Δy.loss. The calculation formula of PVloss is as follows:
[0134]
[0135] Therefore, the loss function for labeled data is modified as follows:
[0136] For unlabeled data, use To replace Label.loss, is the entropy of the variational distribution of the target variable, that is: Therefore, the loss function for unlabeled data can be expressed as:
[0137] The overall loss function is:
[0138] Specifically, in one embodiment of the present invention, step S32 includes:
[0139] S321 samples a batch of unlabeled data samples from the second subset, and inputs the sampled unlabeled data samples into the encoder network to obtain a prior distribution of the latent variables;
[0140] S322 samples latent variables from the prior distribution, and inputs the sampled latent variables into a decoder network to obtain a reconstructed sample;
[0141] S323 calculates the first reconstruction error of the variational autoencoder model and the first KL divergence error of the latent variable based on the unlabeled data sample and the reconstructed sample, and constructs a variational lower bound of the unlabeled data;
[0142] S324 uses the gradient descent algorithm to minimize the variational lower bound of unlabeled data and updates the parameters of the encoder network and decoder network according to the error back propagation;
[0143] S325 repeats steps S321-S324 until a preset training round is reached or an early stopping condition is met, thereby obtaining a pre-trained variational autoencoder model.
[0144] In the variational autoencoder model, the loss function is also called the variational lower bound. During pre-training, it is used as the variational lower bound for unlabeled data. The calculation formula is as follows:
[0145]
[0146] In the formula, Rec.loss1 represents the variational lower bound of unlabeled data; Rec.loss1 represents the first reconstruction error, which is used to measure the difference between the unlabeled data sample reconstructed by the decoder network and the original data sample; KL.loss1 represents the first KL divergence error of the latent variable, which is used to measure the difference between the prior distribution and the posterior distribution; It represents the entropy of the variational distribution of the target variable, which is used to replace the label error of unlabeled data; PVloss1 represents the first pseudo variational loss, which is used to replace the KL divergence loss of directly calculating the increment of the target variable.
[0147] The calculation formula of the first reconstruction error Rec.loss1 is:
[0148]
[0149] In the formula, represents the encoder network, φ z are the parameters of the encoder network, z|x represents the conditional probability distribution that maps the input data x to the latent variable z; represents the decoder network, θ x are the parameters of the decoder network, x|z represents the conditional probability distribution that maps the latent variable z back to the data x; Based on the encoder network The expectation of the latent variable z; Based on the decoder network Log-likelihood of input data x;
[0150] The calculation formula of the first KL divergence error KL.loss1 of the latent variable is:
[0151]
[0152] Where D KL is the KL divergence; Based on regression block The expectation of the target variable y; is the prior distribution, z|y represents the probability distribution of the latent variable z given the target variable y, θ z is the parameter of the prior distribution; φ y are the parameters of the regression block;
[0153] Entropy of the variational distribution of the target variable The calculation formula is:
[0154]
[0155] In the formula, Represents a Gaussian distribution The expectation of the target variable y; f(x u ; φ y ) and g(x u ; φ y ) are two mapping functions, which transform the unlabeled data samples x u Mapped to the mean and variance of a Gaussian distribution;
[0156] The calculation formula of the first pseudo-variation loss PVloss1 is:
[0157]
[0158] In the formula, z t+1 |x t+1 Indicates that the input data x at time step t+1 t+1 Mapped to the latent variable z at time step t+1 t+1 The conditional probability distribution of y t +Δy t |Δy t+1 represents the target variable y at time step t t Plus the target variable increment Δy at time step t t , the target variable increment Δy at a given time step t+1 t+1 The probability distribution under the condition of .
[0159] Through the above steps, the variational autoencoder model is unsupervised pre-trained using unlabeled data. The parameters of the encoder network and the decoder network are optimized by minimizing the reconstruction error, KL divergence error, variational distribution entropy of the target variable, and the variational lower bound constructed by the pseudo-variational loss. This enables the model to learn the potential feature representation of the data, laying a good initialization foundation for subsequent supervised fine-tuning.
[0160] Specifically, in one embodiment of the present invention, step S33 includes:
[0161] S331 extracts a batch of labeled data samples from the first subset, each labeled data sample includes an input process variable and a corresponding target variable true value;
[0162] S332 inputs the process variables in the labeled data sample into the encoder network, and calculates the latent variables corresponding to each process variable and the mean and variance of the Gaussian distribution obeyed by the latent variables through the encoder network;
[0163] S333 inputs the process variables in the labeled data sample into the regression block, and calculates the target variable prediction value corresponding to each process variable and the mean and variance of the Gaussian distribution obeyed by the target variable prediction value through the regression block;
[0164] S334 calculates the increment of the target variable between the current time step and the next time step based on the regression block and constructs a pseudo variational distribution;
[0165] S335 combines the target variable prediction value of the current time step with the target variable increment to calculate the potential variable corresponding to the current time step; combines the target variable prediction value of the current time step, the target variable increment of the current time step and the target variable increment of the next time step to approximately calculate the potential variable corresponding to the next time step;
[0166] S336 Construct variational lower bounds for labeled data;
[0167] S337 uses the stochastic gradient descent algorithm to minimize the variational lower bound of labeled data and updates the parameters of the encoder network, decoder network, and regression block through back propagation of errors;
[0168] S338 repeats steps S331-S337 until the preset training round is reached or the early termination condition is met, and the fine-tuned variational autoencoder model is output.
[0169] During fine-tuning, the variational lower bound is specifically the variational lower bound of labeled data, and its calculation formula is:
[0170]
[0171] In the formula, Rec.loss2 represents the variational lower bound of labeled data; Rec.loss2 represents the second reconstruction error, which is used to measure the difference between the process variables reconstructed by the decoder network based on the latent variables and the original process variables; KL.loss2 represents the second KL divergence error of the latent variable, which is used to measure the difference between the variational posterior distribution of the latent variable and its prior distribution; Label.loss represents the label error, which is measured by calculating the KL divergence between the variational posterior distribution of the predicted value of the target variable and the empirical distribution of the true value of the target variable in the labeled data; PVloss2 represents the second pseudo-variational loss, which is used instead of directly calculating the KL divergence of the target variable increment.
[0172] The calculation formula of the second reconstruction error Rec.loss2 is:
[0173]
[0174] In the formula, Representation based on encoder network Calculate expectations; is the decoder network, which reconstructs x with the latent variable z as input; x is the input process variable; z is the latent variable; φ z are the parameters of the encoder network; θ x are the parameters of the decoder network;
[0175] The calculation formula of the second KL divergence error KL.loss2 of the latent variable is:
[0176]
[0177] In the formula, Represents a regression block Calculate expectation; D KL represents KL divergence; is the encoder network, which maps the input x to the latent variable z; represents the prior distribution of the latent variable conditioned on the target variable y; y is the true value of the target variable; φ y is the parameter of the regression block; θ z Parameters representing the prior distribution of the latent variable;
[0178] The calculation formula of label error Label.loss is:
[0179]
[0180] In the formula, represents a regression block that predicts the approximate posterior distribution of the target variable y, conditioned on the input x, φ y is the parameter of the regression block; p(y) represents the prior distribution of the target variable y;
[0181] The calculation formula of the second pseudo-variation loss PVloss2 is:
[0182]
[0183] In the formula, z t+1 |x t+1 Indicates that the input data x at time step t+1 t+1 Mapped to the latent variable z at time step t+1 t+1 The conditional probability distribution of y t +Δy t |Δy t+1 represents the target variable y at time step t t Plus the target variable increment Δy at time step t t , the target variable increment Δy at a given time step t+1 t+1 The probability distribution under the condition of .
[0184] Through the above steps, labeled data is introduced on the basis of the pre-trained model for supervised fine-tuning, integrating the advantages of unsupervised and supervised learning, improving the model's prediction performance, generalization ability and training efficiency, and enabling the variational autoencoder model to better adapt to the needs of industrial low-flow virtual detection tasks.
[0185] Specifically, in one embodiment of the present invention, the dynamic adaptive adjustment strategy of step S34 includes:
[0186] a. Learning rate adjustment: Dynamically adjust the learning rate of the optimization algorithm according to the performance of the model on the validation set. When the model performance improvement is small or fluctuates, appropriately reduce the learning rate; when the model performance continues to improve, maintain or appropriately increase the learning rate. b. Early stopping strategy: Set early termination conditions. When the performance of the model on the validation set has not improved for several consecutive rounds, stop training to avoid overfitting. c. Weight decay: Introduce weight decay terms, and control model complexity and improve generalization ability by adding L1 or L2 regularization terms of model weights to the loss function. d. Batch size adjustment: Dynamically adjust the number of samples in each training batch according to the performance of the model on the validation set. When the model performance improves slowly, appropriately increase the batch size; when the model performance fluctuates greatly, appropriately reduce the batch size.
[0187] Model validation: After each training round, use the trained variational autoencoder model to predict the validation set. Calculate the evaluation indicators of the model on the validation set, such as the mean absolute error (MAE). Record the validation set performance of each round.
[0188] Iterative process: set the maximum number of training rounds max_epochs and the number of early termination patience; in each training round, execute step S32 to perform unsupervised pre-training on the model, and then execute step S33 to perform supervised fine-tuning on the model; after each training round, use the dynamic adaptive adjustment strategy to update the model hyperparameters, and evaluate the model performance on the validation set; if the validation set performance of the current round is better than the previous optimal performance, update the optimal performance and the corresponding optimal model; if the validation set performance has not improved for consecutive patience times, trigger the early stopping condition and stop training; repeat the above steps until the maximum number of training rounds max_epochs is reached or the early stopping condition is triggered.
[0189] Finally, the variational autoencoder model with the best performance on the validation set among all training rounds is output.
[0190] Specifically, in an embodiment of the present invention, the performance evaluation index of step S35 adopts MAE, i.e., mean absolute error. The test set is predicted using the optimal variational autoencoder model, the prediction result is compared with the true value of the test set, the evaluation index is calculated, and the evaluation threshold is set to MAE≤0.1. If the evaluation threshold is met, the optimal variational autoencoder model is considered to have excellent performance and is output as the final training model. If the threshold is not met, return to step S32 for retraining. During retraining, a dynamic adaptive adjustment strategy can still be used until the model meets the requirements.
[0191] In one embodiment of the present invention, the variational autoencoder model constructed and trained in the above manner has a prediction result on the sample set as follows: Figure 3 As shown. It can be seen that the variational autoencoder model provided by the present invention can effectively predict high flow data and estimate low flow data.
[0192] In one embodiment of the present invention, the trained variational autoencoder model is used as a virtual sensor model, and the virtual sensor model is used to accurately predict high flow data and effectively estimate undetectable low flow data, thereby solving the problem that vortex flowmeters in industrial process systems cannot monitor low flows.
[0193] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. An industrial low-flow virtual detection method based on semi-supervised variational autoencoder, characterized in that: The steps include: S1 collects flow data through sensors on the industrial process test platform, constructs a data set, and divides the data set into a training set, a validation set, and a test set in proportion; S2 uses a screening method to divide the training set into a first subset and a second subset, retains the label of the first subset as labeled data, and deletes the label of the second subset as unlabeled data; S3 builds a variational autoencoder model, and iteratively trains and tests the variational autoencoder model using unlabeled data, labeled data, validation sets, and test sets to obtain a trained variational autoencoder model; S4 uses the trained variational autoencoder model as a virtual sensor and uses the virtual sensor to predict traffic data to obtain prediction results.
2. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 1 is characterized in that: Step S2 includes: S21 sets the flow threshold T flow , and define the label assignment function L, and denote the training set as X = {x i }, where x i is the i-th flow data in the training set; S22 selects a flow data x in the training set X i , whose label is F i ; S23 Judgement F i With flow threshold T flow If F i >T flow , then x i Tags F i Substitute the label assignment function L and set L(x i )=1, let it be x i The label value of i ≤T flow , then x i Tags F i Substitute the label assignment function L and set L(x i )=0, let it be x i The label value of S24 repeats steps S22-S23 to obtain label values of all traffic data in the training set X; S25 divides the training set X into the first subset X based on the label value of each traffic data in the training set X l and the second subset X u , where the first subset X l The label value of the second subset X u The label value of X is 0. l ={x i |L(x i )=1,x i ∈X},X u ={x i |L(x i )=0,x i ∈X}; S26 For the first subset X l The traffic data in retains its label as labeled data; for the second subset X u The traffic data in , sets its label to empty, as unlabeled data.
3. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 1 is characterized in that: Step S3 includes: S31 builds a variational autoencoder model, including an encoder network, a regression block, and a decoder network; S32 uses unlabeled data to perform unsupervised pre-training on the variational autoencoder model, optimizes the parameters of the variational autoencoder model by minimizing the variational lower bound of the unlabeled data, and obtains a pre-trained variational autoencoder model; S33 uses labeled data to perform supervised fine-tuning on the pre-trained variational autoencoder model. By minimizing the variational lower bound of labeled data and introducing label reconstruction loss and pseudo-variational loss, the parameters of the variational autoencoder model are optimized to obtain the fine-tuned variational autoencoder model. S34 repeats steps S32-S33, and after each training round, introduces a dynamic adaptive adjustment strategy, and uses the verification set to verify the fine-tuned variational autoencoder model to obtain the optimal variational autoencoder model; S35 uses the optimal variational autoencoder model to perform performance evaluation on the test set. If the performance evaluation fails, return to step S32 for retraining; if the performance evaluation passes, output the optimal variational autoencoder model as the trained variational autoencoder model.
4. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 3 is characterized in that: Step S32 includes: S321 samples a batch of unlabeled data samples from the second subset, and inputs the sampled unlabeled data samples into the encoder network to obtain a prior distribution of the latent variables; S322 samples latent variables from the prior distribution, and inputs the sampled latent variables into a decoder network to obtain a reconstructed sample; S323 calculates the first reconstruction error of the variational autoencoder model and the first KL divergence error of the latent variable based on the unlabeled data sample and the reconstructed sample, and constructs a variational lower bound of the unlabeled data; S324 uses the gradient descent algorithm to minimize the variational lower bound of unlabeled data and updates the parameters of the encoder network and decoder network according to the error back propagation; S325 repeats steps S321-S324 until a preset training round is reached or an early stopping condition is met, thereby obtaining a pre-trained variational autoencoder model.
5. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 4 is characterized in that: In step S323, the calculation formula of the variational lower bound of unlabeled data is: In the formula, Rec.loss1 represents the variational lower bound of unlabeled data; Rec.loss1 represents the first reconstruction error, which is used to measure the difference between the unlabeled data sample reconstructed by the decoder network and the original data sample; KL.loss1 represents the first KL divergence error of the latent variable, which is used to measure the difference between the prior distribution and the posterior distribution; It represents the entropy of the variational distribution of the target variable, which is used to replace the label error of unlabeled data; PVloss1 represents the first pseudo variational loss, which is used to replace the KL divergence loss of directly calculating the increment of the target variable.
6. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 5, characterized in that: The calculation formula of the first reconstruction error Rec.loss1 is: In the formula, represents the encoder network, φ z are the parameters of the encoder network, z|x represents the conditional probability distribution that maps the input data x to the latent variable z; represents the decoder network, θ x are the parameters of the decoder network, x|z represents the conditional probability distribution that maps the latent variable z back to the data x; Based on the encoder network The expectation of the latent variable z; Based on the decoder network Log-likelihood of input data x; The calculation formula of the first KL divergence error KL.loss1 of the latent variable is: Where D KL is the KL divergence; Based on regression block The expectation of the target variable y; is the prior distribution, z|y represents the probability distribution of the latent variable z given the target variable y, θ z is the parameter of the prior distribution; φ y are the parameters of the regression block; Entropy of the variational distribution of the target variable The calculation formula is: In the formula, Represents a Gaussian distribution The expectation of the target variable y; f(x u ; φ y ) and g(x u ; φ y ) are two mapping functions, which transform the unlabeled data samples x u Mapped to the mean and variance of a Gaussian distribution; The calculation formula of the first pseudo-variation loss PVloss1 is: In the formula, z t+1 |x t+1 Indicates that the input data x at time step t+1 t+1 Mapped to the latent variable z at time step t+1 t+1 The conditional probability distribution of y t +Δy t |Δy t+1 represents the target variable y at time step t t Plus the target variable increment Δy at time step t t , the target variable increment Δy at a given time step t+1 t+1 The probability distribution under the condition of .
7. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 5, characterized in that: Step S33 includes: S331 extracts a batch of labeled data samples from the first subset, each labeled data sample includes an input process variable and a corresponding target variable true value; S332 inputs the process variables in the labeled data sample into the encoder network, and calculates the latent variables corresponding to each process variable and the mean and variance of the Gaussian distribution obeyed by the latent variables through the encoder network; S333 inputs the process variables in the labeled data sample into the regression block, and calculates the target variable prediction value corresponding to each process variable and the mean and variance of the Gaussian distribution obeyed by the target variable prediction value through the regression block; S334 calculates the increment of the target variable between the current time step and the next time step based on the regression block and constructs a pseudo variational distribution; S335 combines the target variable prediction value of the current time step with the target variable increment to calculate the potential variable corresponding to the current time step; combines the target variable prediction value of the current time step, the target variable increment of the current time step and the target variable increment of the next time step to approximately calculate the potential variable corresponding to the next time step; S336 Construct variational lower bounds for labeled data; S337 uses the stochastic gradient descent algorithm to minimize the variational lower bound of labeled data and updates the parameters of the encoder network, decoder network, and regression block through back propagation of errors; S338 repeats steps S331-S337 until the preset training round is reached or the early termination condition is met, and the fine-tuned variational autoencoder model is output.
8. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 7, characterized in that: In step S336, the calculation formula for the variational lower bound of labeled data is: In the formula, Rec.loss2 represents the variational lower bound of labeled data; Rec.loss2 represents the second reconstruction error, which is used to measure the difference between the process variables reconstructed by the decoder network based on the latent variables and the original process variables; KL.loss2 represents the second KL divergence error of the latent variable, which is used to measure the difference between the variational posterior distribution of the latent variable and its prior distribution; Label.loss represents the label error, which is measured by calculating the KL divergence between the variational posterior distribution of the predicted value of the target variable and the empirical distribution of the true value of the target variable in the labeled data; PVloss2 represents the second pseudo variational loss, which is used instead of directly calculating the KL divergence of the target variable increment.
9. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 8, characterized in that: The calculation formula of the second reconstruction error Rec.loss2 is: In the formula, Representation based on encoder network Calculate expectations; is the decoder network, which reconstructs x with the latent variable z as input; x is the input process variable; z is the latent variable; φ z are the parameters of the encoder network; θ x are the parameters of the decoder network; The calculation formula of the second KL divergence error KL.loss2 of the latent variable is: In the formula, Represents a regression block Calculate expectation; D KL represents KL divergence; is the encoder network, which maps the input x to the latent variable z; represents the prior distribution of the latent variable conditioned on the target variable y; y is the true value of the target variable; φ y is the parameter of the regression block; θ z Parameters representing the prior distribution of the latent variable; The calculation formula of label error Label.loss is: In the formula, represents a regression block that predicts the approximate posterior distribution of the target variable y, conditioned on the input x, φ y is the parameter of the regression block; p(y) represents the prior distribution of the target variable y; The calculation formula of the second pseudo-variation loss PVloss2 is: In the formula, z t+1 |x t+1 Indicates that the input data x at time step t+1 t+1 Mapped to the latent variable z at time step t+1 t+1 The conditional probability distribution of y t +Δy t |Δy t+1 represents the target variable y at time step t t Plus the target variable increment Δy at time step t t , the target variable increment Δy at a given time step t+1 t+1 The probability distribution under the condition of .
10. The industrial low-flow virtual detection method based on semi-supervised variational autoencoder according to claim 8, characterized in that: The total loss function of the variational autoencoder model is: In the formula, is the total loss function; x t represents the input data at time step t; x t+1 Represents the input data at time step t+1; represents the variational lower bound of labeled data at time step t; represents the variational lower bound of unlabeled data at time step t and time step t+1; represents an encoder network that maps input data x to a probability distribution of latent variables z; is the decoder network, which represents the latent variable z y Reconstruct the data x at time step t t The probability distribution of It represents the expectation of the probability distribution of the latent variables output by the encoder network.
Citation Information
Cited By
Underground water flow and solute transport prediction method based on potential diffusion model
CN119294142A
A groundwater flow and solute transport prediction method based on a latent diffusion model
CN119294142B
