A high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism

By converting the two-phase flow conductance fluctuation signal of the gas-liquid two-phase flow conductance into a feature matrix and using the multi-head attention mechanism to build an identification network, the problem of difficult to identify the two-phase flow pattern of the gas-liquid two-phase flow pattern in the prior art is solved, and the effect of high-precision recognition and reducing calculation costs is achieved.

CN119337776BActive Publication Date: 2025-05-09HENAN NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411862573.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-05-09
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

The prior art is difficult to accurately identify the flow pattern of the gas-liquid two-phase flow of horizontal pipes, and the calculation cost is high, so it is impossible to fully capture the nonlinear relationship of the two-phase flow flow pattern signal.

Method used

The method based on data conversion and multi-head attention mechanism is adopted to convert the two-phase flow conductance fluctuation signal of the gas-liquid two-phase flow type recognition network, and the multi-head self-attention mechanism of the window and the multi-head self-attention mechanism of the shift window are used to extract the flow type characteristics and realize recognition.

Benefits of technology

It improves the accuracy of gas-liquid two-phase flow flow pattern recognition, reduces calculation costs, and can more comprehensively extract complex flow pattern features, overcoming the problem of difficult nonlinear relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119337776B_ABST
    Figure CN119337776B_ABST
Patent Text Reader

Abstract

The present invention discloses a high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism. After the gas-liquid two-phase flow dynamic experimental device is built, the conductivity fluctuation signals of five flow patterns, namely, bubble flow, bubble plug flow, plug flow, plug flow and stratified flow, are collected according to the annular conductivity sensor. By converting the normalized data into a feature matrix, the feature differences between different flow patterns are highlighted, which helps to reveal the high-level features not in the time series. A gas-liquid two-phase flow pattern recognition network is constructed, and the feature matrices of different flow patterns are input into the recognition network for feature extraction. The multi-head self-attention mechanism of the window and the multi-head self-attention mechanism of the shifted window can capture the local and global features in the feature matrix and thus realize the flow pattern recognition of the horizontal pipe gas-liquid two-phase flow. The present invention can more comprehensively extract the complex flow pattern characteristics of the horizontal pipe gas-liquid two-phase flow, improve the accuracy of flow pattern recognition, and reduce the calculation cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of gas-liquid two-phase flow pattern recognition, and specifically relates to a high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism, which is used to realize the recognition of gas-liquid two-phase flow pattern in horizontal pipes. Background Art

[0002] Currently, two-phase flow is widely found in industries such as oil pipelines, chemical reactors, and aerospace. Depending on the composition, two-phase flow can be categorized as gas-liquid, gas-solid, liquid-solid, and liquid-liquid. Accurate identification of two-phase flow patterns is fundamental to determining flow parameters and directly impacts analysis of resistance, heat, and mass transfer characteristics. Therefore, research on two-phase flow pattern identification is crucial for ensuring the efficient and safe operation of industrial production systems.

[0003] To accurately identify flow patterns, it is necessary to extract information that characterizes two-phase flow. However, the inherent geometric complexity and variability of flow structures make accurate characterization and extraction of these characteristic features difficult. In recent years, commonly used signal processing methods such as power spectral density, wavelet transform, entropy theory, and statistical methods have been used to extract characteristic information about two-phase flow. However, these methods mostly process the measurement signals based on static or statistical features, ignoring the signal's time dependence and requiring significant computational time. Alternatively, image processing can be used to identify two-phase flow patterns. For example, Shanthi et al. used a high-speed digital camera to capture images of different flow patterns and then extracted texture and shape features from the preprocessed images for flow pattern identification. However, in most industrial processes, non-transparent pipes are often used, making it difficult for cameras to capture the flow within them, limiting the application of this method. To overcome these challenges, data conversion of the measurement signals has been proposed. For example, WX Liu et al. used a recursive graph algorithm to convert the measurement signals of a conductivity sensor array. Based on the differences in the RP texture structure under different flow patterns, they distinguished three typical two-phase flow patterns. LF Zhang used a pseudo-image encoding algorithm to convert the power spectrum into a two-dimensional grayscale image to visualize the characteristic differences between different flow patterns in the frequency domain. Compared with the other two methods, data conversion of complex measurement signals helps reveal high-level features not present in the time series. Therefore, this method is a more intuitive high-dimensional feature representation method. Convolutional neural networks are commonly used for feature extraction. This is because the convolutional layer can discover some hidden features in the input features, and subsequent layers can produce correct outputs. In addition, the multi-head attention mechanism can process information in parallel and capture features of different dimensions. The parallelism of multi-head attention can improve computational efficiency. Considering the advantages of data conversion and multi-head attention mechanism, a high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism is proposed. The purpose is to more comprehensively extract the complex flow pattern characteristics of gas-liquid two-phase flow in horizontal pipes and improve the accuracy of flow pattern recognition. This method uses a ring-shaped four-electrode conductivity sensor to measure the gas-liquid two-phase flow rate. The measurement signal is then converted into a characteristic matrix. This characteristic matrix is ​​used as input to construct a gas-liquid two-phase flow pattern recognition network. The network extracts the matrix features and establishes a mapping relationship between the matrix and the flow pattern, ultimately enabling the recognition of gas-liquid two-phase flow patterns in horizontal pipes. Currently, there are no related reports on this topic. Summary of the Invention

[0004] The technical problem solved by the present invention is to provide a high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism. Compared with commonly used signal processing methods, the method proposed in the present invention shows superior performance in extracting the flow pattern characteristics of gas-liquid two-phase flow in horizontal pipes, effectively overcoming the problem of difficulty in fully capturing the nonlinear relationship of two-phase flow pattern signals, and improving the accuracy of flow pattern recognition and reducing computational costs.

[0005] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: a high-precision gas-liquid two-phase flow pattern identification method based on data conversion and a multi-head attention mechanism. The specific process is as follows: after a gas-liquid two-phase flow dynamic experimental device is constructed, gas-liquid two-phase flow conductivity fluctuation signals of five flow patterns, namely bubbly flow, plug flow, plug flow, plug-dividing flow, and stratified flow, are collected using an annular conductivity sensor. The collected gas-liquid two-phase flow conductivity fluctuation signal data is enhanced and then normalized. The normalized data is then converted into a feature matrix using polar coordinates, and then time series feature pre-extraction is performed. By highlighting the feature differences between different flow patterns, high-level features not present in the time series are revealed. A gas-liquid two-phase flow pattern identification network is constructed and initialized and trained. Feature matrix samples of different flow patterns are input into the gas-liquid two-phase flow pattern identification network for time series feature extraction. The window multi-head self-attention mechanism and the shifted window multi-head self-attention mechanism can capture local and global features in the feature matrix, thereby realizing the identification of gas-liquid two-phase flow patterns in horizontal pipes.

[0006] Furthermore, the construction process of the gas-liquid two-phase flow dynamic experimental device is as follows: a ring conductivity sensor is used to measure the gas-liquid two-phase flow. The ring conductivity sensor consists of four stainless steel ring electrodes E1, E2, M1, and M2 embedded in the inner wall of a plexiglass tube, where E1 and E2 are an excitation electrode pair, and M1 and M2 are a measuring electrode pair. The ring spacing between M1 and M2 is 60 mm, the ring spacing between E1 and M1 is 70 mm, and the ring spacing between E2 and M2 is 70 mm. The experimental process adopts a current excitation and voltage measurement working mode. By passing a sinusoidal alternating current with a frequency of 20 kHz into E1 and grounding E2 at the same time, an electrical measurement sensitive field can be formed between the excitation electrode pairs.

[0007] Furthermore, the gas-liquid two-phase flow conductivity fluctuation signal acquisition process is as follows: the two-phase flow is experimentally measured using a ring conductivity sensor. The experimental acquisition frequency is 1 kHz and the acquisition time is 20 seconds. That is, a set of measurement voltage signals obtained in one acquisition is 20,000 data points. The measurement voltage is collected three times under the same flow state to obtain three sets of measurement voltage signals. The flow state is changed and the acquisition operation is repeated to obtain measurement voltage signals under multiple flow states, thereby forming a gas-liquid two-phase flow data set. The flow types in the data set include bubbly flow, bubbly plug flow, plug flow, plug diversion and stratified flow. In order to enhance the feature representation ability of the model, sufficient training samples are required. The overlapping sampling method is used to process each set of measurement voltage signals in the gas-liquid two-phase flow data set separately, thereby increasing the number of training samples. The single sampling length is set to 4000 and the moving step size is set to 1000. The enhanced sample number calculation formula is:

[0008]

[0009] Where Num is the number of samples after data enhancement, Indicates rounding down, S t is the number of data points of a set of measured voltage signals, S is the length of a single sampling, S step is the moving step length.

[0010] Furthermore, the specific process of data normalization and polar coordinate conversion of normalized data into characteristic matrix data is as follows: for a single sampling length S (i = 1, 2, ..., s) gas-liquid two-phase flow time series U = {u1, u2, ..., u s Normalization is performed so that all data values ​​are limited to between 0 and 1, and the normalized data of the gas-liquid two-phase flow time series is obtained. The normalization formula is:

[0011]

[0012] Where, Represents the normalized value, min is the minimum value, and max is the maximum value;

[0013] Will Converted to polar coordinates, the angle θ i and radius r i The calculation process is as follows:

[0014]

[0015] Where arccos() represents the inverse cosine function, t i is the timestamp;

[0016] The time series is normalized to the interval [0,1] corresponding to θ i The angle is 0~π / 2; 0 <r i ≤1, normalized data In polar coordinates, they are represented as values ​​of different angles and radii within the unit circle.

[0017] Further definition, the specific process of time series feature pre-extraction is: in the normalized data After converting to polar coordinates, the sum or difference of the polar angles between each polar coordinate value is calculated to identify the time correlation within different time intervals. Two polar coordinate matrices are generated. The Sum matrix is ​​obtained by using the cosine function of the sum of the two angles, and the Different matrix is ​​obtained by using the sine function of the difference between the two angles. The specific calculation formula is:

[0018]

[0019] In the formula, cos() represents the cosine function, and sin() represents the sine function;

[0020] After calculation, two matrices of size s×s are obtained. Each element in the two matrices is linearly transformed and normalized to the range of [0-1]. The calculation expression of this step is:

[0021]

[0022] Where, f(x ij ) is the value after linear normalization, x ij Represents the value of any position in the matrix, min is the minimum value, max is the maximum value, Indicates rounding down, based on the segment mapping method, f(x ij ) values ​​are mapped to the X, Y, and Z three-dimensional space;

[0023] When f(x ij )<0.3, the calculation method is:

[0024] Z=0

[0025] When 0.3≤f(x ij )<0.5, the calculation method is:

[0026] X=0, Z=0

[0027] When f(x ij )≥0.5, the calculation method is:

[0028] X=0,Y=0,

[0029] The linearly transformed values ​​are then mapped to the X, Y, and Z spaces and combined into a three-dimensional array to construct and Three-dimensional data, get normalized data of The characteristic matrix constitutes the characteristic matrix sample set D1 of flow pattern recognition; the normalized data is obtained of The characteristic matrix constitutes the characteristic matrix sample set 2 D2 for flow pattern identification. The characteristic matrix sample set 1 D1 and the characteristic matrix sample set 2 D2 are collectively referred to as the characteristic matrix sample set D.

[0030] Furthermore, the specific process of constructing a gas-liquid two-phase flow pattern recognition network is as follows: the input is the feature matrix sample set D, the output of the network is the recognition accuracy of the five flow patterns, and the structure of the recognition network is as follows: first, the feature matrix sample set 1 and the feature matrix sample set 2 are input into the convolution layer 1 in sequence, and a convolution kernel with a size of 4×4 and a step size of 4 is used to perform convolution operation on the feature matrix samples. The input feature dimension is set to 3 and the output feature dimension is 48; then four processing modules are constructed: processing module 1 includes convolution layer 2 and repeatedly stacked attention modules. Convolution layer 2 uses a convolution kernel with a size of 1×1 and a step size of 1. Processing module 2, processing module 3, and processing module 4 all include a pooling layer for downsampling and a repeatedly stacked attention module. Each repeatedly stacked attention module is composed of stacked attention modules. The repeatedly stacked attention modules in processing module 1, processing module 2, processing module 3, and processing module 4 are respectively stacked by 2, 2, 6, and 2 attention modules. Each attention module contains a total of eight layers: its input layer is a normalization layer, the second The first layer is a multi-head self-attention mechanism for the window, the third layer is a normalization layer, the fourth layer is a multi-layer perceptron, which consists of multiple fully connected layers, GELU activation functions and dropout layers, the fifth layer is a normalization layer, the sixth layer is a multi-head self-attention mechanism for the displacement window, the seventh layer is a normalization layer, and the eighth layer is a multi-layer perceptron. The output feature dimensions of each processing module are 96, 192, 384 and 768 respectively; finally, after a normalization layer, a global average pooling layer, a GELU activation function and a fully connected layer, the construction of the recognition network is completed. The window refers to the non-overlapping local area divided by the convolution of the input feature matrix. The multi-head self-attention mechanism of the window means that the multi-head self-attention mechanism only performs multi-head self-attention calculations within each window. The displacement window refers to the local area originally divided by the convolution moving in a certain direction, so that there is some overlap between adjacent windows, thereby generating a new window. The multi-head self-attention mechanism of the displacement window refers to the multi-head self-attention mechanism performing multi-head self-attention calculations within the new window;

[0031] The specific calculation formula in the identification network is as follows:

[0032] Calculation method of convolution layer 1:

[0033] Conv1=D k ×W1+b1

[0034] Where Conv1 is the output of convolutional layer 1, D k is the input of convolution layer 1, W1 represents the weight of convolution layer 1, and b1 represents the bias of convolution layer 1;

[0035] Calculation method of convolution layer 2:

[0036] Conv2=Conv1×W2+b2

[0037] Where Conv2 is the output of convolutional layer 2, Conv1 is the input of convolutional layer 2, W2 is the weight of convolutional layer 2, and b2 is the bias of convolutional layer 2.

[0038] The calculation method of the normalization layer in the attention module is:

[0039]

[0040] Where LN(x) is the output of the normalization layer, x is the input of the normalization layer, γ is the scale parameter, β is the offset parameter, μ is the mean of the input feature vector, σ is the standard deviation of the input feature vector, and ε is a small number used to stabilize the calculation.

[0041] In the calculation process of the multi-head self-attention mechanism, the feature matrix is ​​first linearly projected into the qkv space, and the matrix is ​​divided into three parts, namely the Q (query), K (key), and V (value) feature matrices. The calculation of this step is expressed as:

[0042] [Q,K,V]=[z l W Q ,z l W K ,z l W V ]

[0043] Where W Q , W K and W V For three weight matrices, the self-attention mechanism within each local window can be expressed as:

[0044]

[0045] Where K T represents the transpose of K, is the scaling factor, B is the relative position deviation of the window, softmax is expressed as a normalized exponential function, and the Q, K, and V feature matrices are linearly projected h times to form the multi-head self-attention mechanism MSA. The calculation of MSA is as follows:

[0046] MSA(Q,K,V)=Concatenate(head1,head2,...,head h )W O

[0047] head i =Attention(QW i Q ,KW iK ,VW i V )

[0048] Where Wo represents the weight parameter of linear projection, Concatenate represents the concatenation function, the feature matrix size is h×w, C is the output feature dimension, and the computational complexity of MSA and WMSA is expressed as:

[0049] Ω(MSA)=4hwC 2 +2(hw) 2 C

[0050] Ω(WMSA)=4hwC 2 +2M 2 HkDJ

[0051] Where M represents the size of each window;

[0052] The overall calculation process of the attention module is:

[0053]

[0054] Where MLP is a multi-layer perceptron, LN is a normalization layer, WMSA is a multi-head self-attention mechanism for windows, and SWMSA is a multi-head self-attention mechanism for shifted windows. The output and input z of the multi-head self-attention mechanism representing the window l-1 The residual connection of The output of the multi-head self-attention mechanism representing the displacement window and z l The residual connection of z l and z l+1 is the MLP output feature;

[0055] The global average pooling layer is calculated as follows:

[0056]

[0057] Where GAP represents the output of the global average pooling layer, y kpq Denotes the kth feature matrix D i The element at (p, q) in |D k | represents the number of all elements of the kth feature matrix;

[0058] The GELU activation function is calculated as follows:

[0059]

[0060] Where G represents the GELU activation function layer input, and 0.044715 are the two adjustment coefficients of the GELU function, and the hyperbolic tangent function tanh() is expressed as:

[0061]

[0062] Where, e represents the natural logarithm, and x represents the input variable of tanh();

[0063] The calculation method of the fully connected layer is as follows:

[0064] FC=W fc ×GAP+b fc

[0065] Where FC represents the output of the global average pooling layer, W fc is the weight matrix of the fully connected layer, b fc represents the bias of the fully connected layer.

[0066] Furthermore, the specific process of initialization and training of the gas-liquid two-phase flow pattern recognition network is as follows: Network initialization usually requires initializing the weights and bias parameters of each network layer: For layer normalization, the weights are usually initialized to 1, and the biases are usually initialized to 0. For the fully connected layer, the weights and biases are usually initialized with small random values. The output of the network is a vector V of length 5, which represents the probability that the input feature matrix sample belongs to a certain flow pattern category. The classification network uses the Adam optimizer, the initial learning rate is set to 0.0001, and the network loss function is the cross entropy function, which is calculated as follows:

[0067]

[0068] In the formula, Γ represents the number of samples, Λ represents the number of categories, and y ρυ Indicates whether the ρth sample belongs to the true label of category υ, that is, if the sample ρ belongs to category υ, then y ρυ =1, otherwise y ρυ =0, The model predicts the probability that the ρth sample belongs to the sample category υ. The classification network performs backpropagation according to the Adam optimizer to update the input layer weights, the weights from the intermediate layer to the output layer, the bias of the intermediate layer, and the bias of the output layer. The input feature matrix sample set is forward propagated through the convolution layer, pooling layer, global average pooling layer, activation function, and fully connected layer in the network structure, and the cross entropy loss between the recognized feature matrix flow type category and the true feature matrix flow type category is calculated. The gradient is calculated according to the loss function and backpropagated through the network to update the network weights. The training cycle is set to 50 epochs.

[0069] The evaluation index process of the gas-liquid two-phase flow pattern recognition network is as follows: The model is evaluated using Accuracy, Recall, Precision, and F1 score as indicators to measure its performance. The formula is as follows:

[0070]

[0071] Where TP is the number of true positive examples, FN is the number of false negative examples, FP is the number of false positive examples, and TN is the number of true negative examples.

[0072] Compared with the prior art, the present invention has the following advantages and beneficial effects: The present invention proposes a high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism. This method converts the gas-liquid two-phase flow conductivity fluctuation signal into polar coordinates, performs feature pre-extraction on it, and obtains a three-dimensional feature matrix, which can highlight the characteristic differences between different flow patterns. The present invention constructs a gas-liquid two-phase flow pattern recognition network and inputs the feature matrix sample set D into the model for feature extraction. Its window multi-head self-attention mechanism and the shifted window multi-head self-attention mechanism can capture local and global features in the image, thereby realizing flow pattern recognition. Results show that the high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism proposed in the present invention can effectively overcome the problem of difficulty in fully capturing the nonlinear relationship between two-phase flow pattern signals, more comprehensively extract the complex flow pattern characteristics of horizontal pipe gas-liquid two-phase flow, and effectively improve the accuracy of horizontal pipe gas-liquid two-phase flow pattern recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] Figure 1 It is a flowchart of the overall method principle of the present invention;

[0074] Figure 2 Schematic diagram of the basic structure of the annular four-electrode conductivity sensor of the present invention;

[0075] Figure 3 Schematic diagram of the basic structure of the horizontal pipeline gas-liquid two-phase flow dynamic experimental system of the present invention;

[0076] Figure 4 Schematic diagram of the process of feature pre-extraction for gas-liquid two-phase flow time series;

[0077] Figure 5 It is the characteristic matrix diagram of five flow types;

[0078] Figure 6 This is a structural diagram of the gas-liquid two-phase flow pattern identification network constructed in the present invention;

[0079] Figure 7It is the recognition accuracy of a single flow type when using the three evaluation methods of Recall, Precision and F1 score;

[0080] Figure 8 This is the confusion matrix diagram of the gas-liquid two-phase flow pattern recognition network test results in the present invention. DETAILED DESCRIPTION

[0081] In conjunction with the accompanying drawings, the present invention provides a high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism to be described in detail.

[0082] The high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism described in the present invention demonstrates superior performance in extracting flow pattern characteristics of gas-liquid two-phase flow in horizontal pipes, effectively overcoming the problem of difficulty in fully capturing the nonlinear relationship of two-phase flow pattern signals, and improving the accuracy of flow pattern recognition and reducing computational costs.

[0083] like Figure 1 As shown in FIG, a flowchart of a high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism provided by the present invention is provided. The specific steps are as follows:

[0084] Step 1: Sensor structure design. The present invention adopts an annular conductivity sensor for measuring gas-liquid two-phase flow. The annular conductivity sensor is composed of four stainless steel annular electrodes E1, E2, M1, and M2 embedded in the inner wall of a plexiglass tube, wherein E1 and E2 are an excitation electrode pair, and M1 and M2 are a measuring electrode pair. The ring spacing between M1 and M2 is 60mm, the ring spacing between E1 and M1 is 70mm, and the ring spacing between E2 and M2 is 70mm. The experiment of the present invention adopts a current excitation and voltage measurement working mode. By passing an alternating current with a sinusoidal wave frequency of 20kHz into electrode E1 and grounding electrode E2 at the same time, an electrical measurement sensitive field can be formed between the excitation electrode pair.

[0085] Step 2: Gas-liquid two-phase flow conductivity fluctuation signal acquisition. The horizontal pipeline gas-liquid two-phase dynamic detection device mainly consists of a water tank, an air pump, a flow meter, a phase mixer, a ring conductivity sensor, and a computer. In the experiment, the liquid phase and the gas phase were tap water (density 998kg / m 3 , the dynamic viscosity is 1.01×10 -3 Pa·s) and air (density 1.2 kg / m 3 , the dynamic viscosity is 1.81×10 -5 In the dynamic experiment, in order to obtain more comprehensive data, the air flow rate was controlled at [0m 3 / h~362m 3 / h], the water flow rate is controlled within [3m3 / h~11m 3 / h] range. The method of adjusting the gas speed with a fixed water speed is adopted, that is, water at a fixed speed is first introduced into the horizontal pipe through the water tank, and then the gas phase is gradually increased through the air pump. The speeds of air and water can be set by the regulating valve, so as to match different flow states. When the flow state of the two-phase flow is stable, the measured voltage data is recorded. The two-phase flow is experimentally measured using a ring conductivity sensor. The experimental acquisition frequency is 1kHz, and the acquisition time is 20 seconds, that is, a set of measurement voltage signals obtained by one acquisition is 20,000 data points. Three sets of measurement voltage signals can be obtained by collecting the measurement voltage three times under the same flow state. By changing the flow state and repeating the acquisition operation, the measurement voltage signals under multiple flow states can be obtained, and then a gas-liquid two-phase flow data set can be formed. The flow types in the data set include bubbly flow, plug flow, plug flow, plug diversion and stratified flow.

[0086] Step 3: Data enhancement. To enhance the model's feature representation capabilities, sufficient training samples are required. Using the overlapping sampling method, each set of measured voltage signals in the gas-liquid two-phase flow dataset is processed separately to increase the number of training samples. The single sampling length is set to 4000, and the moving step is set to 1000. The formula for calculating the number of samples after enhancement is:

[0087]

[0088] Where Num is the number of samples after data enhancement, Indicates rounding down, S t is the number of data points of a set of measured voltage signals, S is the length of a single sampling, S step is the moving step length.

[0089] Step 4: Data normalization. For a single sampling length S (i = 1, 2, ..., s) of the gas-liquid two-phase flow time series U = {u1, u2, ..., u s Normalization is performed so that all data values ​​are limited to between 0 and 1, and the normalized data of the gas-liquid two-phase flow time series is obtained. The normalization formula is:

[0090]

[0091] Where, Represents the normalized value, min is the minimum value, and max is the maximum value.

[0092] Step 5: Convert to polar coordinates. Angle θ i and radius r i The transformation process is as follows:

[0093]

[0094]

[0095] Where, t i is the timestamp.

[0096] When the time series is mapped to [0,1], θ i is mapped to [0,π / 2]. Therefore, as time increases, It can be expressed as polar coordinates at different angles and radii within the unit circle.

[0097] Step 6: Pre-extraction of time series features. After converting to polar coordinates, the sum or difference of the polar angles between each polar coordinate value is calculated to identify the time correlation within different time intervals. Two polar coordinate matrices can be generated. The Sum matrix is ​​obtained by using the cosine function of the sum of the two angles, and the Different matrix is ​​obtained by using the sine function of the difference between the two angles. The specific calculation formula is:

[0098]

[0099] Where cos() represents the cosine function, and sin() represents the sine function.

[0100] After calculation, we can get two matrices of size s×s. Each element in the two matrices is linearly transformed and normalized to the range of [0-1]. The calculation expression of this step is

[0101]

[0102] Where, f(x ij ) is the value after linear normalization, x ij Represents the value of any position in the matrix, min is the minimum value, max is the maximum value, Indicates rounding down. Based on the segment mapping method, f(x ij ) values ​​are mapped to the X, Y, and Z three-dimensional space.

[0103] When f(x ij )<0.3, the calculation method is

[0104] Z=0

[0105] When 0.3≤f(x ij )<0.5, the calculation method is:

[0106] X=0, Z=0

[0107] When f(xij )≥0.5, the calculation method is:

[0108] X=0,Y=0,

[0109] The linearly transformed values ​​are then mapped to the X, Y, and Z spaces and combined into a three-dimensional array. and Three-dimensional data, get normalized data of The characteristic matrix can constitute the characteristic matrix sample set D1 for flow pattern recognition; obtain normalized data of The characteristic matrix can constitute the characteristic matrix sample set D2 for flow pattern recognition. The characteristic matrix sample set D1 and the characteristic matrix sample set D2 are collectively referred to as the characteristic matrix sample set D.

[0110] Step 7: Construct a gas-liquid two-phase flow pattern recognition network. The input is the feature matrix sample set D. The network output is the recognition accuracy of the five flow patterns. The recognition network structure is as follows: First, feature matrix sample set 1 and feature matrix sample set 2 are sequentially input into convolutional layer 1. A convolution operation is performed on the feature matrix samples using a 4×4 convolution kernel with a stride of 4. The input feature dimension is set to 3, and the output feature dimension is set to 48. Then, four processing modules are constructed: Processing module 1 includes convolutional layer 2 and repeatedly stacked attention modules. Convolutional layer 2 uses a 1×1 convolution kernel with a stride of 1, and a repeatedly stacked attention module. Processing modules 2, 3, and 4 each include a pooling layer for downsampling and a repeatedly stacked attention module. Each repeatedly stacked attention module is composed of stacked attention modules. The repeatedly stacked attention modules in processing modules 1, 2, 6, and 4 are respectively composed of stacked attention modules. Each attention module consists of eight layers: the input layer is a normalization layer, the second layer is a windowed multi-head self-attention mechanism, the third layer is a normalization layer, and the fourth layer is a multi-layer perceptron (MLP), which consists of multiple fully connected layers, GELU activation functions, and dropout layers. The fifth layer is a normalization layer, the sixth layer is a shifted windowed multi-head self-attention mechanism, the seventh layer is a normalization layer, and the eighth layer is a MLP. The output feature dimensions after each processing module are 96, 192, 384, and 768, respectively. Finally, after a normalization layer, a global average pooling layer, a GELU activation function, and a fully connected layer, the recognition network is constructed. A window is a non-overlapping local region created by convolution of the input feature matrix. The windowed multi-head self-attention mechanism performs multi-head self-attention calculations only within each window. A shifted window is a new window generated by shifting the local region created by convolution in a certain direction, resulting in partial overlap between adjacent windows. The multi-head self-attention mechanism of the shifted window refers to the multi-head self-attention mechanism performing multi-head self-attention calculations within the new window.

[0111] In the identification network, the specific calculation formula is as follows:

[0112] Calculation method of convolution layer 1:

[0113] Conv1=D k ×W1+b1

[0114] Where Conv1 is the output of convolutional layer 1, D k is the input of convolution layer 1, W1 represents the weight of convolution layer 1, and b1 represents the bias of convolution layer 1.

[0115] Calculation method of convolution layer 2:

[0116] Conv2=Conv1×W2+b2

[0117] Where Conv2 is the output of convolutional layer 2, Conv1 is the input of convolutional layer 2, W2 represents the weight of convolutional layer 2, and b2 represents the bias of convolutional layer 2.

[0118] In the attention module, the calculation method of the normalization layer is:

[0119]

[0120] Where LN(x) is the output of the normalization layer, x is the input of the normalization layer, γ is the scale parameter, β is the offset parameter, μ is the mean of the input feature vector, σ is the standard deviation of the input feature vector, and ε is a very small number used to stabilize the calculation.

[0121] In the calculation process of the multi-head self-attention mechanism, the feature matrix is ​​first linearly projected into the qkv space, and the matrix is ​​divided into three parts, namely the Q (query), K (key), and V (value) feature matrices. The calculation of this step can be expressed as:

[0122] [Q,K,V]=[z l W Q ,z l W K ,z l W V ]

[0123] Where W Q , W K and W V are three weight matrices. The self-attention mechanism within each local window can be expressed as:

[0124]

[0125] Where K T represents the transpose of K, is the scaling factor, B is the relative position deviation of the window, and softmax is expressed as a normalized exponential function. The multi-head self-attention mechanism MSA is constructed by linearly projecting the Q, K, and V feature matrices h times. The calculation of MSA is as follows:

[0126] MSA(Q,K,V)=Concatenate(head1,head2,...,head h )W O

[0127] head i =Attention(QW i Q ,KW iK ,VW i V )

[0128] Where W o Denotes the weight parameter of linear projection, Concatenate denotes the concatenation function. The feature matrix size is h×w, C is the output feature dimension, and the computational complexity of MSA and WMSA is expressed as:

[0129] Ω(MSA)=4hwC 2 +2(hw) 2 C

[0130] Ω(WMSA)=4hwC 2 +2M 2 HkDJ

[0131] Where M represents the size of each window.

[0132] The overall calculation process of the attention module is:

[0133]

[0134]

[0135] Where MLP is a multi-layer perceptron, LN is a normalization layer, WMSA is a multi-head self-attention mechanism for windows, and SWMSA is a multi-head self-attention mechanism for shifted windows. The output and input z of the multi-head self-attention mechanism representing the window l-1 The residual connection of The output of the multi-head self-attention mechanism representing the displacement window and z l The residual connection of z l and z l+1 is the MLP output feature.

[0136] The global average pooling layer is calculated as follows:

[0137]

[0138] Where GAP represents the output of the global average pooling layer, y kpq Denotes the kth feature matrix D i The element at (p, q) in |D k | represents the number of all elements in the kth feature matrix.

[0139] The GELU activation function is calculated as follows:

[0140]

[0141] Where G represents the GELU activation function layer input, and 0.044715 are the two adjustment coefficients of the GELU function, and the hyperbolic tangent function tanh() is expressed as:

[0142]

[0143] Where e represents the natural logarithm, and x represents the input variable of tanh().

[0144] The calculation method of the fully connected layer is as follows:

[0145] FC=W fc ×GAP+b fc

[0146] Where FC represents the output of the global average pooling layer, W fc is the weight matrix of the fully connected layer, b fc represents the bias of the fully connected layer.

[0147] Step 8: Initialization and training of the gas-liquid two-phase flow pattern recognition network. Network initialization usually requires initializing the weights and bias parameters of each layer of the network: for layer normalization, the weights are usually initialized to 1, and the biases are usually initialized to 0. For the fully connected layer, the weights and biases are usually initialized with small random values. The output of the network is a vector V of length 5, which represents the probability that the input feature matrix sample belongs to a certain flow pattern category. The classification network uses the Adam optimizer, and the initial learning rate is set to 0.0001. The network loss function is the cross entropy function, which is calculated as follows:

[0148]

[0149] In the formula, Γ represents the number of samples, Λ represents the number of categories, and y ρυ Indicates whether the ρth sample belongs to the true label of category υ, that is, if the sample ρ belongs to category υ, then y ρυ =1, otherwise y ρυ =0. is the model's prediction of the probability that the ρth sample belongs to sample category υ. The classification network performs backpropagation using the Adam optimizer, updating the input layer weights, the weights from the intermediate layers to the output layer, the biases of the intermediate layers, and the bias of the output layer. The input feature matrix sample set is forward propagated through the convolutional layers, pooling layers, global average pooling layers, activation functions, and fully connected layers in the network structure. The cross-entropy loss between the recognized feature matrix flow type category and the true feature matrix flow type category is calculated. The gradient is calculated based on the loss function and backpropagated through the network to update the network weights. The training cycle is set to 50 epochs.

[0150] Step 9: Evaluation indicators of the gas-liquid two-phase flow pattern recognition network. The model is evaluated using Accuracy, Recall, Precision, and F1 score as indicators to measure its performance. The formula is as follows:

[0151]

[0152] Where TP is the number of true positive examples, FN is the number of false negative examples, FP is the number of false positive examples, and TN is the number of true negative examples.

[0153] Finally, the characteristic matrix samples of the gas-liquid two-phase flow are input into the trained and tested gas-liquid two-phase flow pattern recognition network to identify five flow patterns: bubbly flow, bubbly plug flow, plug flow, plug split flow and stratified flow.

[0154] like Figure 2 Figure 2 shows the basic structure of the sensor. This invention uses an annular conductivity sensor for measuring gas-liquid two-phase flow. The annular conductivity sensor consists of four stainless steel annular electrodes, E1, E2, M1, and M2, embedded in the inner wall of a plexiglass tube. E1 and E2 form the excitation electrode pair, while M1 and M2 form the measuring electrode pair. The spacing between the rings of M1 and M2 is 60 mm, the spacing between the rings of E1 and M1 is 70 mm, and the spacing between the rings of E2 and M2 is 70 mm.

[0155] like Figure 3 The figure shows the basic structure of the horizontal pipeline gas-liquid two-phase flow dynamic experimental system. The basic structure of the gas-liquid two-phase flow dynamic experimental system mainly consists of a ring electrode sensor, a water tank, an air pump, a phase mixer, a horizontal pipe test unit and a data acquisition system.

[0156] like Figure 4 As shown in FIG, it is a schematic diagram of the process of feature pre-extraction of gas-liquid two-phase flow time series. Figure 4 (a) is a schematic diagram of data normalization. Figure 4 (b) is a schematic diagram of the normalized data converted to the polar coordinate system. Figure 4 (c) is generated and The result diagram of the feature matrix. Figure 6 Shown is the structural diagram of the gas-liquid two-phase flow pattern identification network. Figure 5 It is the characteristic matrix diagram of five flow types.

[0157] like Figure 7 As shown in the figure, the recognition accuracy of a single flow type under the three evaluation methods of Recall, Precision and F1 score is as follows. and The four data conversion methods are represented by different colors. The evaluation results of different flow patterns are connected to form polygons. The closer the polygon is to the black polygon, the higher the recognition rate. Different feature matrices are input into the gas-liquid two-phase flow pattern recognition network. The recall, precision and F1 score accuracy of bubbly flow, plug flow and stratified flow tend to 100%. and The evaluation results of the plug flow and plug splitting under the condition of are better than those of the Markov transition field and recursive graph. and The data conversion method has a higher accuracy in flow pattern identification.

[0158] like Figure 8 As shown in Figure 1, the confusion matrix diagram of the gas-liquid two-phase flow pattern recognition network test results. Figure 8 As can be seen from (a), the input is When the characteristic matrix is ​​used, the accuracy rates of bubbly flow, plug flow, plug flow, plug flow and stratified flow are 100%, 97.8%, 100%, 96.7% and 100% respectively. Figure 8 As can be seen from (b), the input is When the characteristic matrix is ​​used, the accuracy rates for the five flow types are 100%, 98.9%, 100%, 97.5%, and 100%, respectively. The results show that the recognition of bubbly, slug, and stratified flows is relatively accurate. In contrast, the accuracy of bubbly and slug flows is slightly lower due to their transitional nature.

[0159] Table 1 shows the flow pattern recognition results of the gas-liquid two-phase flow pattern recognition network proposed in the present invention and four other models using feature matrix sample sets D1 and D2. As can be seen from the table, the recognition accuracy of the gas-liquid two-phase flow pattern recognition network proposed in the present invention is superior to that of the four networks: VGG-16, Google LeNe, DenseNet, and Vision Transformer (ViT). When input with feature matrix sample D1 and feature matrix sample D2, the flow pattern recognition rates displayed by the gas-liquid two-phase flow pattern recognition network proposed in the present invention are 98.6% and 99.1%, respectively.

[0160] Table 1 Comparison of different recognition networks

[0161]

[0162] It can be seen that the feature pre-extraction method proposed in this invention is better than the Markov transition field and recursive graph. and The feature matrix can extract more effective flow pattern features. The gas-liquid two-phase flow pattern recognition network constructed by this invention has a higher recognition accuracy than four networks: VGG-16, Google LeNe, DenseNet, and Vision Transformer (ViT). This further confirms that the proposed method can more comprehensively extract the complex flow pattern features of gas-liquid two-phase flow in horizontal pipes, improving the accuracy of flow pattern recognition.

[0163] 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 scope of protection of the present invention.

Claims

1. A high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism, characterized in that The specific process is as follows: after the gas-liquid two-phase flow dynamic experimental device is built, the gas-liquid two-phase flow conductivity fluctuation signals of five flow types, namely bubbly flow, bubbly plug flow, plug flow, plug diversion and stratified flow, are collected according to the annular conductivity sensor. The collected gas-liquid two-phase flow conductivity fluctuation signal data is enhanced and then normalized. The normalized data is converted into a feature matrix by polar coordinates, and then time series feature pre-extraction is performed. By highlighting the feature differences between different flow types, it is helpful to reveal high-level features that are not in the time series. A gas-liquid two-phase flow pattern recognition network is constructed and initialized and trained. The feature matrix samples of different flow types are input into the gas-liquid two-phase flow pattern recognition network for time series feature extraction. The multi-head self-attention mechanism of the window and the multi-head self-attention mechanism of the shifted window can capture the local and global features in the feature matrix and thus realize the recognition of the horizontal tube gas-liquid two-phase flow pattern.

2. The high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism according to claim 1 is characterized in that The construction process of the gas-liquid two-phase flow dynamic experimental device is as follows: an annular conductivity sensor is used to measure the gas-liquid two-phase flow. The annular conductivity sensor consists of four stainless steel annular electrodes E1, E2, M1, and M2 embedded in the inner wall of a plexiglass tube, where E1 and E2 are an excitation electrode pair, M1 and M2 are a measuring electrode pair, the ring spacing between M1 and M2 is 60mm, the ring spacing between E1 and M1 is 70mm, and the ring spacing between E2 and M2 is 70mm. The experimental process adopts a current excitation and voltage measurement working mode. By passing a sinusoidal alternating current with a frequency of 20kHz into E1 and grounding E2 at the same time, an electrical measurement sensitive field can be formed between the excitation electrode pairs.

3. The high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism according to claim 1 is characterized in that The acquisition process of the conductivity fluctuation signal of the gas-liquid two-phase flow is as follows: the two-phase flow is experimentally measured using a ring conductivity sensor. The experimental acquisition frequency is 1kHz and the acquisition time is 20 seconds, that is, a set of measured voltage signals obtained in one acquisition is 20,000 data points. The measured voltage is collected three times under the same flow state to obtain three sets of measured voltage signals. The flow state is changed and the acquisition operation is repeated to obtain the measured voltage signals under multiple flow states, thereby forming a gas-liquid two-phase flow data set. The flow types in the data set include bubbly flow, bubbly plug flow, plug flow, plug flow and stratified flow. In order to enhance the feature representation ability of the model, sufficient training samples are required. The overlapping sampling method is used to process each set of measured voltage signals in the gas-liquid two-phase flow data set respectively, thereby increasing the number of training samples. The single sampling length is set to 4000 and the moving step is set to 1000. The calculation formula for the number of samples after enhancement is: In the formula, Num is the number of samples after data enhancement, Indicates rounding down, S t is the number of data points of a set of measured voltage signals, S is the length of a single sampling, S step is the moving step length.

4. The high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism according to claim 1 is characterized in that The specific process of data normalization and polar coordinate conversion of normalized data into characteristic matrix data is as follows: for a single sampling length S (i = 1, 2, ..., s) gas-liquid two-phase flow time series U = {u1, u2, ..., u s }Perform normalization processing so that all data values ​​are limited to between 0 and 1, and obtain the normalized data of the gas-liquid two-phase flow time series The normalization formula is: In the formula, Represents the normalized value, min is the minimum value, and max is the maximum value; Will Converted to polar coordinates, the angle θ i and radius r i The calculation process is as follows: In the formula, arccos() represents the inverse cosine function, t i is the timestamp; The time series is normalized to the interval [0,1] corresponding to θ i The angle is 0~π / 2; 0 <r i ≤1, normalized data In polar coordinates, they are represented as values ​​of different angles and radii within the unit circle.

5. The high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism according to claim 1 is characterized in that The specific process of time series feature pre-extraction is as follows: After conversion to polar coordinates, the sum or difference of the polar angles between each polar coordinate value is calculated to identify the time correlation in different time intervals. Two polar coordinate matrices are generated. The Sum matrix is ​​obtained by using the cosine function of the sum of the two angles, and the Different matrix is ​​obtained by using the sine function of the difference of the two angles. The specific calculation formula is: In the formula, cos() represents the cosine function, and sin() represents the sine function; After calculation, two matrices of size s×s are obtained. Each element in the two matrices is linearly transformed and normalized to the range of [0-1]. The calculation expression of this step is: In the formula, f(x ij ) is the value after linear normalization, x ij Represents the value of any position in the matrix, min is the minimum value, max is the maximum value, Indicates rounding down, based on the segment mapping method, f(x ij ) values ​​are mapped to the three-dimensional space of X, Y, and Z; When f(x ij )<0.3, the calculation method is: When 0.3≤f(x ij )<0.5, the calculation method is: When f(x ij )≥0.5, the calculation method is: The linearly transformed values ​​are then mapped to the X, Y, and Z spaces and combined into a three-dimensional array to construct and Three-dimensional data, get normalized data of The characteristic matrix is ​​the characteristic matrix sample set D1 that constitutes flow pattern recognition; the normalized data is obtained of The characteristic matrix constitutes the characteristic matrix sample set 2 D2 for flow pattern recognition. The characteristic matrix sample set 1 D1 and the characteristic matrix sample set 2 D2 are collectively referred to as the characteristic matrix sample set D.

6. The high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism according to claim 1 is characterized in that The specific process of constructing a gas-liquid two-phase flow pattern recognition network is as follows: the input is the feature matrix sample set D, the output of the network is the recognition accuracy of the five flow patterns, and the structure of the recognition network is as follows: first, the feature matrix sample set 1 and the feature matrix sample set 2 are input into the convolution layer 1 in sequence, and a convolution kernel with a size of 4×4 and a step size of 4 is used to perform convolution operations on the feature matrix samples. The input feature dimension is set to 3, and the output feature dimension is 48; then four processing modules are constructed: processing module 1 includes convolution layer 2 and repeatedly stacked attention modules. Convolution layer 2 uses a convolution kernel with a size of 1×1 and a step size of 1. Processing modules 2, 3, and 4 all include a pooling layer for downsampling and a repeatedly stacked attention module. Each repeatedly stacked attention module is composed of stacked attention modules. The repeatedly stacked attention modules in processing modules 1, 2, 3, and 4 are respectively composed of 2, 2, 6, and 2 attention modules stacked together. Each attention module contains a total of eight layers: its input layer is a normalization layer, the second layer is a window The multi-head self-attention mechanism of the mouth, the third layer is the normalization layer, the fourth layer is the multi-layer perceptron, the multi-layer perceptron consists of multiple fully connected layers, GELU activation functions and dropout layers, the fifth layer is the normalization layer, the sixth layer is the multi-head self-attention mechanism of the displacement window, the seventh layer is the normalization layer, and the eighth layer is the multi-layer perceptron. The output feature dimensions of each processing module are 96, 192, 384 and 768 respectively; finally, after a normalization layer, a global average pooling layer, a GELU activation function and a fully connected layer, the construction of the recognition network is completed. The window refers to the non-overlapping local area divided by the convolution of the input feature matrix. The multi-head self-attention mechanism of the window refers to the multi-head self-attention mechanism that only performs multi-head self-attention calculations inside each window. The displacement window refers to the local area originally divided by the convolution moving in a certain direction, so that there are some overlapping parts between adjacent windows, thereby generating a new window. The multi-head self-attention mechanism of the displacement window refers to the multi-head self-attention mechanism that performs multi-head self-attention calculations inside the new window; The specific calculation formula in the identification network is as follows: The calculation method of convolution layer 1 is: Conv1=D k ×W1+b1 Where Conv1 is the output of convolutional layer 1, D k is the input of convolution layer 1, W1 represents the weight of convolution layer 1, and b1 represents the bias of convolution layer 1; The calculation method of convolution layer 2 is: Conv2=Conv1×W2+b2 Where Conv2 is the output of convolutional layer 2, Conv1 is the input of convolutional layer 2, W2 is the weight of convolutional layer 2, and b2 is the bias of convolutional layer 2. The calculation method of the normalization layer in the attention module is: Where LN(x) is the output of the normalization layer, x is the input of the normalization layer, γ represents the scale parameter, β represents the offset parameter, μ represents the mean of the input feature vector, σ represents the standard deviation of the input feature vector, and ε is a very small number used to stabilize the calculation; In the calculation process of the multi-head self-attention mechanism, the feature matrix is ​​first linearly projected into the qkv space, and the matrix is ​​divided into three parts, namely the Q (query), K (key), and V (value) feature matrices. The calculation of this step is expressed as: [Q,K,V]=[z l W Q ,z l W K ,z l W V ] Where W Q , W K and W V For three weight matrices, the self-attention mechanism in each local window can be expressed as: In the formula, K T represents the transpose of K, is the scaling factor, B is the relative position deviation of the window, softmax is expressed as a normalized exponential function, and the Q, K, and V feature matrices are linearly projected h times to form a multi-head self-attention mechanism MSA. The calculation of MSA is as follows: MSA(Q,K,V)=Concatenate(head1,head2,...,head h )W O head i =Attention(QW i Q ,KW i K ,VW i V ) In the formula, Wo represents the weight parameter of linear projection, Concatenate represents the concatenation function, the feature matrix size is h×w, C is the output feature dimension, and the computational complexity of MSA and WMSA is expressed as: Ω(MSA)=4hwC 2 +2(hw) 2 C Ω(WMSA)=4hwC 2 +2M 2 hwC In the formula, M represents the size of each window; The overall calculation process of the attention module is: In the formula, MLP represents a multi-layer perceptron, LN represents a normalization layer, WMSA represents a multi-head self-attention mechanism for a window, and SWMSA represents a multi-head self-attention mechanism for a displacement window. The output and input z of the multi-head self-attention mechanism representing the window l-1 The residual connection of The output of the multi-head self-attention mechanism representing the displacement window and z l The residual connection of z l and z l+1 is the MLP output feature; The global average pooling layer is calculated as follows: Where GAP represents the output of the global average pooling layer, ykpq represents the element at (p, q) in the k-th feature matrix Di, and |Dk| represents the number of all elements in the k-th feature matrix; The calculation method of GELU activation function is as follows: In the formula, G represents the GELU activation function layer input, and 0.044715 are the two adjustment coefficients of the GELU function. The hyperbolic tangent function tanh() is expressed as: In the formula, e represents the natural logarithm, and x represents the input variable of tanh(); The calculation method of the fully connected layer is as follows: FC=W fc ×GAP+b fc Where FC represents the output of the global average pooling layer, W fc is the weight matrix of the fully connected layer, b fc represents the bias of the fully connected layer.

7. The high-precision gas-liquid two-phase flow pattern recognition method based on data conversion and multi-head attention mechanism according to claim 1 is characterized in that The specific process of initialization and training of the gas-liquid two-phase flow pattern recognition network is as follows: Network initialization usually requires initializing the weights and bias parameters of each layer of the network: For layer normalization, the weights are usually initialized to 1, and the biases are usually initialized to 0. For the fully connected layer, the weights and biases are usually initialized with small random values. The output of the network is a vector V of length 5, which represents the probability that the input feature matrix sample belongs to a certain flow pattern category. The classification network uses the Adam optimizer, the initial learning rate is set to 0.0001, and the network loss function is the cross entropy function, which is calculated as follows: In the formula, Γ represents the number of samples, Λ represents the number of categories, and y ρυ Indicates whether the ρth sample belongs to the true label of category υ, that is, if the sample ρ belongs to category υ, then y ρυ =1, otherwise y ρυ =0, is the probability that the model predicts that the ρth sample belongs to the sample category υ. The classification network performs back propagation according to the Adam optimizer to update the input layer weights, the weights from the intermediate layer to the output layer, the bias of the intermediate layer, and the bias of the output layer. The input feature matrix sample set is forward propagated through the convolution layer, pooling layer, global average pooling layer, activation function, and fully connected layer in the network structure, and the cross entropy loss between the recognized feature matrix flow type category and the true feature matrix flow type category is calculated. The gradient is calculated according to the loss function and back propagated through the network to update the network weights. The training cycle is set to 50 epochs; The evaluation index process of the gas-liquid two-phase flow pattern recognition network is as follows: The evaluation of the model uses Accuracy, Recall, Precision and F1 score as indicators to measure its performance. The formula is as follows: Where TP is the number of true positive examples, FN is the number of false negative examples, FP is the number of false positive examples, and TN is the number of true negative examples.

Citation Information

Patent Citations

  • Two-phase flow pattern recognition method and device based on attention mechanism and convolutional neural network, computer equipment and storage medium

    CN118072069A

  • Encrypted network application identification method based on self-attention mechanism

    CN118590262A