Ultrasonic gas meter fault prediction method based on recurrent neural network ensemble
Through the RNN integrated model of time prediction based on recurrent neural network, the problem of large long-term prediction error of gas meter is solved, efficient and accurate prediction of gas failures is achieved, and gas accidents are prevented early, which is suitable for long-term prediction and situations with large external changes.
Patent Information
- Application Number
- CN202211104623.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-09-09
AI Technical Summary
The existing gas meter fault prediction methods have large errors in long-term prediction and large external changes, and traditional models are difficult to apply, so they cannot effectively prevent gas accidents.
The time prediction RNN ensemble model based on recurrent neural network is adopted to train and predict the time series data of the downstream and countercurrent of the ultrasonic gas meter, and optimize the model parameters in combination with the loss function, efficient and accurate prediction of gas failures is achieved.
It achieves efficient and accurate prediction of gas failures, prevents gas accidents as early as possible, reduces safety hazards, and is suitable for long-term predictions and situations with large external changes.
Smart Images

Figure CN115660141B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an ultrasonic gas meter fault prediction method based on recurrent neural network integration. Background Art
[0002] With the continued development and utilization of natural gas and the gradual liberalization of urban gas utilities, the scale of gas use in China is expanding. The call to build a resource-saving and environmentally friendly society, the country's opening up to the gas sector, and the expansion of pipeline construction have created a favorable environment for gas development.
[0003] Gas failures are inevitable during gas use due to factors such as aging pipes, dust accumulation, water corrosion, and thermal expansion. These accidents can seriously endanger people's lives and property, and harm public safety and the public interest. To this end, numerous studies have designed a series of fault prediction methods focused on ultrasonic gas meter fault detection. While existing gray prediction models can generate a highly regular sequence from irregular raw data after processing relatively few eigenvalues, these models are only suitable for short- to medium-term forecasts and only for forecasts approximating exponential growth. Forecasts based on differential equation models suffer from large errors when used for long-term forecasts, and solutions to the differential equations are difficult to obtain. Time series prediction methods, however, are not suitable for forecasting large external changes.
[0004] Compared to the gray prediction model, the time series model has a wider range of applications. Furthermore, to address the large errors in long-term forecasts and the difficulty in predicting when significant external changes occur, recurrent neural networks are introduced. Recurrent neural networks are a type of recursive neural network with the characteristics of memory and parameter sharing, offering advantages in learning nonlinear features of sequences.
[0005] To this end, the present invention proposes an ultrasonic gas meter fault prediction method based on a recurrent neural network integration. This method can predict gas faults, prevent them early, and effectively avoid the safety hazards associated with gas faults. The advantage of neural networks lies in their powerful fitting capabilities. They can approximate any complex function, and the dimensionality of neural networks can approach infinite dimensions, thus achieving powerful data fitting capabilities. Traditional machine learning methods are, to a certain extent, special cases of neural networks. For example, functions such as support vector machines (SVMs) and logistic regression can be performed by neural networks. Neural networks contain many hidden layers, each with many hidden nodes, giving them excellent expressive power. Furthermore, RNN neural networks further improve the performance of neural networks by enabling the neurons in the hidden layers to communicate with each other, which has the advantage of short-term memory and achieves data prediction with powerful fitting capabilities. Based on the time series data processing capabilities of RNN networks, the present invention can achieve high-efficiency and high-precision prediction functions within a certain time range. Ultrasonic gas meters can collect real-time time series of ultrasonic waves propagating in the fluid, both upstream and downstream. By processing the time series of ultrasonic waves propagating in the fluid along and against the flow collected by the ultrasonic gas meter, it is used as a data set to train the invented time prediction RNN integration model. After the training is completed, the fault prediction goal of ultrasonic gas can be achieved. Summary of the Invention
[0006] In order to overcome the problem of sudden failure of ultrasonic gas meters, the present invention provides an ultrasonic gas meter failure prediction method based on a recurrent neural network, which can realize the failure prediction of ultrasonic gas meters.
[0007] The present invention provides a method for predicting ultrasonic gas meter faults based on a recurrent neural network, comprising the following steps:
[0008] 1) Pre-train the time prediction RNN ensemble model. This model includes a downstream time prediction RNN model and a downstream time prediction RNN model. This model is pre-trained using a dataset of normal ultrasonic wave propagation times in a fluid, both upstream and downstream. Each model is trained for 10 epochs.
[0009] 2) Collect ultrasonic gas related historical data. Monitor and sample relevant time data of ultrasonic gas meter. Take the initial downstream propagation time t of each ultrasonic wave in the fluid. i_up , the initial countercurrent propagation time of ultrasonic wave in the fluid t i_down After that, the ultrasonic gas is sampled continuously for a period of time, and the real-time sampling and recording of the gas real-time downstream propagation time t m_up , real-time countercurrent propagation time tm_down , a sample point is taken every 20 seconds.
[0010] 3) Preprocess the real-time downstream gas historical data collected in step 2). m_up Data, according to the ratio of training set: test set = 8:2, the first 80% of the data is used as the training set data, and the remaining 20% of the data is used as the test set data. m_up The data is segmented with overlap, that is, 32 sample points are taken every other sample point. In this way, the following time series array can be obtained for the collected samples:
[0011] array i_up ={t i ,t i+1 ,......t i+32}(i∈[1,n])
[0012] Among them, i represents the i-th group of data, and n is the last group of data in the training set.
[0013] 4) Input the preprocessed training set data into the downstream time prediction RNN model to obtain the output result.
[0014] Real-time downstream propagation time t m_up Make predictions.
[0015] Use the downstream time prediction RNN model. The input of this model is the time series array in the training set:
[0016] array i_up
[0017] Where i represents the i-th time series array, i∈[1,n].
[0018] The output is the next data to be predicted. Each time a set of data is input, the next data of this set of data will be output. These output numbers are recorded as F={f1,f2,……f n}. The corresponding true value sequence is T={t 33 ,t 34, ……,t n+32}, where n represents the last digit of the training set prediction.
[0019] 5) Output data F = {f1, f2, ... f n}Perform the following preprocessing:
[0020] f o_i = softmax(f i )(i∈[1,n]) (1)
[0021] F O ={f o_1 ,f o_2 ,……f o_n} (2)
[0022]
[0023] Among them, f o_i is the preprocessed prediction data, i represents the i-th data; F O is the preprocessed prediction dataset; f in i Represents the predicted data output by the model, and i represents the i-th data; f in j It represents the predicted data output by the model, and j represents the jth data.
[0024] For real data T={t 33 ,t 34, ……,t n+32} for preprocessing,
[0025] t o_i =softmax(t i+33 ) (i∈[1,n]) (4)
[0026] T O ={t o_1 ,t o_2 ,……t o_n} (5)
[0027]
[0028] Among them, t o_i is the preprocessed real data, i represents the i-th data; T O It is a preprocessed real data set; t in i+33 Represents real data, i represents the i-th data; t in j+33 Represents the real data, and j represents the jth data.
[0029] The loss function is used to calculate the error between the predicted value and the true value:
[0030]
[0031] By continuously training the model and adjusting the parameters in the downstream time prediction RNN model, the loss function L i The value of continues to approach 0.
[0032] 6) Test the model using the test set. Input the test set data into the trained downstream time prediction RNN model. The output is the predicted downstream time. A loss function is applied to calculate the error between the predicted downstream time and the true value. Determine whether the loss function result is within a reasonable range. If it is, model training is complete. If not, return to step 4) to retrain the model.
[0033] 7) Preprocess the real-time gas counterflow historical data collected in step 2). The real-time counterflow propagation time t m_down Data, according to the ratio of training set: test set = 8:2, the first 80% of the data is used as the training set data, and the remaining 20% of the data is used as the test set data. m_down The data is segmented with overlap, i.e. 32 sample points are taken every 1, so that the collected samples can be used to obtain the following time series array:
[0034] array i_down ={t i ,t i+1 ,.....t i+32}
[0035] Among them, i represents the i-th group of data, and n is the last group of data in the training set.
[0036] 8) Input the preprocessed training set data into the reverse flow time prediction RNN model to obtain the output result.
[0037] Real-time countercurrent propagation time t m_down Make predictions.
[0038] Use the reverse time prediction RNN model. The input of this model is the time series array in the training set:
[0039] array i_down
[0040] Where i represents the i-th time series array.
[0041] The output is the next data to be predicted. Every time a set of data is input, the next data of this set of data will be output. These output numbers are recorded as P = {p1, p2, ... p n}. The corresponding real value sequence is R={r 33 ,r 34, ……,r n+32}, where n represents the last digit of the training set prediction.
[0042] 9) Output data P = {p1, p2, ... p n} for preprocessing,
[0043] p o_i =softmax(p i ) (i∈[1,n]) (9)
[0044] P O ={p o_1 ,p o_2 ,……p o_n} (10)
[0045]
[0046] Among them, p o_i is the preprocessed prediction data, i represents the i-th data; p o is the preprocessed prediction dataset; p in i Represents the predicted data output by the model, and i represents the i-th data; p in j It represents the predicted data output by the model, and j represents the jth data.
[0047] For real data R={r 33 ,r 34, ……,r n+32} for preprocessing,
[0048] r o_i =softmax(r i+33 ) (i∈[1,n]) (12)
[0049] R O ={r o_1 ,r o_2 ,……r o_n} (13)
[0050]
[0051] Among them, r o_i is the preprocessed real data, i represents the i-th data; R O It is a preprocessed real data set; r in i+33 Represents real data, i represents the i-th data; r in j+33 Represents the real data, and j represents the jth data.
[0052] The loss function is used to calculate the error between the predicted value and the true value:
[0053]
[0054] By continuously training the model and adjusting the parameters in the reverse time prediction RNN model, the loss function L i The value of continues to approach 0.
[0055] 10) Test the RNN model for predicting backflow time using the test set. Input the test set data into the trained RNN model, which outputs the predicted backflow time. A loss function is used to calculate the error between the predicted backflow time and the true value, and determine whether the loss function result is within a reasonable range. If so, model training is complete. If not, return to step 2) and retrain the model.
[0056] 11) The downstream time prediction RNN model and the downstream time prediction RNN model are simply combined together to form a time prediction RNN integration model. The time prediction RNN integration model samples the real-time upstream and downstream time of the gas in real time according to the sampling method in step 2) at regular intervals, predicts the upstream and downstream time of the gas, and realizes the model prediction function.
[0057] 12) For the predicted data, when the gas flow rate v m = 0, when the predicted data t m1_up =t m1_down and the initially recorded forward and reverse flow time data t i1_up =t i1_down When the difference between the two reaches the lower limit of the time threshold, a security warning will be issued to the remote terminal.
[0058] During the use of the gas meter, as time goes by, dust accumulates more and more, forming a certain thickness, which reduces the propagation path of ultrasonic waves in the gas. The reduction in the propagation path of ultrasonic waves is directly reflected in the real-time forward and reverse flow time difference, so when the predicted data t m1_up =t m1_down and the initially recorded forward and reverse flow time data t i1_up =t i1_down When the difference between them reaches the lower limit of the time threshold, a fault may occur. The time prediction RNN model can thus achieve the prediction function.
[0059] The present invention is based on a time prediction RNN integrated model, which can realize the prediction of ultrasonic gas. At the same time, the model is continuously corrected according to the deviation value between the predicted data and the actual data, and the model is continuously improved to obtain a good prediction effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 This is the working principle diagram of the time difference gas meter.
[0061] Figure 2 Schematic diagram of the RNN model for downstream time prediction.
[0062] Figure 3 Schematic diagram of the RNN model for reverse time prediction.
[0063] Figure 4 is the real-time downstream propagation time t m_up Schematic diagram of data with overlapping segments.
[0064] Figure 5 is the real-time downstream propagation time t m_down Schematic diagram of data with overlapping segments. DETAILED DESCRIPTION
[0065] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0066] The structure of the downstream time prediction RNN model is as follows Figure 2 As shown in the figure, the structure includes: the size of the original input signal is 32*1, after using LSTM, a feature layer with a dimension of 32*16 is obtained, a dropout operation is used to obtain a new feature layer with a dimension of 32*16, a feature layer with a dimension of 32 is obtained by using LSTM, a new feature layer with a dimension of 32 is obtained by using dropout, a feature layer with a dimension of 1 is obtained by using full connection, and the loss function is used to calculate the gap between the predicted next data and the actual data.
[0067] The structure of the reverse time prediction RNN model is as follows Figure 3 As shown in the figure, the structure includes: the size of the original input signal is 32*1, after using LSTM, a feature layer with a dimension of 32*16 is obtained, a dropout operation is used to obtain a new feature layer with a dimension of 32*16, a feature layer with a dimension of 32 is obtained by using LSTM, a new feature layer with a dimension of 32 is obtained by using dropout, a feature layer with a dimension of 1 is obtained by using full connection, and the loss function is used to calculate the gap between the predicted next data and the actual data.
[0068] A method for predicting ultrasonic gas meter faults based on a recurrent neural network comprises the following steps:
[0069] 1) Pre-train the model using a dataset of normal ultrasonic wave propagation time in the fluid, both upstream and downstream, to pre-train the time prediction RNN ensemble model. The downstream time prediction RNN model and the upstream time prediction RNN model were trained for 10 epochs respectively.
[0070] 2) Monitor and sample the relevant time data of the ultrasonic gas meter. Take the initial downstream propagation time t of each ultrasonic wave in the fluidi_up , the initial countercurrent propagation time of ultrasonic wave in the fluid t i_down After that, the ultrasonic gas was sampled continuously for 12 hours, and the real-time sampling and recording of the real-time downstream propagation time of the gas was recorded. m_up , real-time countercurrent propagation time t m_down , a sample point is taken every 20 seconds.
[0071] 3) From step 2), we can obtain the real-time downstream propagation time t m_up There are 2160 data sets. According to the ratio of training set: test set = 8:2, the first 1728 data sets are used as training set data, and the 1729th to 2160th data sets are used as test set data. m_up The data is segmented with overlap, and the segmentation method is as follows Figure 4 As shown, 32 sample points are taken every other sample point, so a total of 1697 time series arrays can be obtained for the collected samples:
[0072] array 1_up ={t1,t2,......t 32}
[0073] array 2_up ={t 33 ,t 34 ,......t 64}
[0074] array 3_up ={t 65 ,t 66 ,......t 96}
[0075] …
[0076] array 1697_up ={t 1697 ,t 1698 ,......t 1728}
[0077] 4) Real-time downstream propagation time t m_up Make predictions.
[0078] Use the downstream time prediction RNN model. The input of this model is the time series array in the training set:
[0079] array i_up
[0080] Where i represents the i-th time series array, i∈[1,1697].
[0081] The output is the next data to be predicted. Each time a set of data is input, the next data of this set of data will be output. These output numbers are recorded as F={f1,f2,……f 1697}. The corresponding true value sequence is T={t 33 ,t 34, ……,t 1728}
[0082] 5) Output data F = {f1, f2, ... f 1697} for preprocessing,
[0083]
[0084] F O ={f o_1 ,f o_2 ,……f o_1697} (2)
[0085]
[0086] Among them, f o_i is the preprocessed prediction data, i represents the i-th data; F O is the preprocessed prediction dataset; f in i Represents the predicted data output by the model, and i represents the i-th data; f in j It represents the predicted data output by the model, and j represents the jth data.
[0087] For real data T={t 33 ,t 34, ……,t 1728} for preprocessing,
[0088] t o_i =softmax(t i+33 )i∈[1,1697] (4)
[0089] T O ={t o_1 ,t o_2 ,……t o_1697} (5)
[0090]
[0091] Among them, t o_i is the preprocessed real data, i represents the i-th data; T O It is a preprocessed real data set; t in i+33 Represents real data, i represents the i-th data; t in j+33 Represents the real data, and j represents the jth data.
[0092] The loss function is used to calculate the error between the predicted value and the true value:
[0093]
[0094] By continuously training the model and adjusting the parameters in the downstream time prediction RNN model, the loss function L i The value of continues to approach 0.
[0095] 6) Test with the test set. Input the test set data into the trained downstream time prediction RNN model. The output is the predicted downstream time. A loss function is applied to the predicted downstream time and the error is calculated between the predicted downstream time and the true value. The error is determined to determine if the loss function result is within a reasonable range. If so, model training is complete. If not, return to step 4) and retrain the model.
[0096] 7) From step 2), we can obtain the real-time countercurrent propagation time t m_down There are 2160 data sets. According to the ratio of training set: test set = 8:2, the first 1728 data sets are used as training set data, and the 1729th to 2160th data sets are used as test set data. m_down The data is segmented with overlap, and the segmentation method is as follows Figure 5 As shown, 32 sample points are taken every 1, so a total of 71 time series arrays can be obtained for the collected samples:
[0097] array 1_down ={t1,t2,.....t 32},
[0098] array 2_down ={t 33 ,t 34 ,.....t 64}
[0099] array 3_down ={t 65 ,t 66 ,.....t 96}
[0100] …
[0101] array 1697_down ={t 1697 ,t 1698 ,…t 1728}
[0102] 8) Real-time countercurrent propagation time t m_down Make predictions.
[0103] Use the reverse time prediction RNN model. The input of this model is the time series array in the training set:
[0104] array i_down
[0105] Where i represents the i-th time series array, i∈[1,1697].
[0106] The output is the next data to be predicted. Every time a set of data is input, the next data of this set of data will be output. These output numbers are recorded as P = {p1, p2, ... p 1697}. The corresponding real value sequence is R={r 33 ,r 34, ……,r 1728}
[0107] 9) Output data P = {p1, p2, ... p 1697} for preprocessing,
[0108] p o_i =softmax(p i ) (8)
[0109] P O ={p o_1 ,p o_2 ,……p o_1697} (9)
[0110]
[0111] Among them, p o_i is the preprocessed prediction data, i represents the i-th data; P O is the preprocessed prediction dataset; p in i Represents the predicted data output by the model, and i represents the i-th data; p in j It represents the predicted data output by the model, and j represents the jth data.
[0112] For real data R={r 33 ,r 34, ……,r 1728} for preprocessing,
[0113] r o_i =softmax(r i+33 )i∈[1,1697] (11)
[0114] R O ={r o_1 ,r o_2 ,……r o_1697} (12)
[0115]
[0116] Among them, r o_i is the preprocessed real data, i represents the i-th data; R O It is a preprocessed real data set; r in i+33 Represents real data, i represents the i-th data; r in j+33 Represents the real data, and j represents the jth data.
[0117] The loss function is used to calculate the error between the predicted value and the true value:
[0118]
[0119] By continuously training the model and adjusting the parameters in the reverse time prediction RNN model, the loss function L i The value of continues to approach 0.
[0120] 10) Test with the test set. Input the test set data into the trained RNN model for predicting backflow time. The output is the predicted backflow time. A loss function is applied to the predicted backflow time and the error is calculated between the predicted backflow time and the true value. Determine whether the loss function result is within a reasonable range. If it is, model training is complete. If not, return to step 8) and retrain the model.
[0121] 11) Then, the downstream time prediction RNN model and the downstream time prediction RNN model are simply combined together to form a time prediction RNN integration model. The time prediction RNN integration model samples the real-time upstream and downstream time of the gas in real time according to the sampling method in step 2), predicts the upstream and downstream time of the gas, and realizes the model prediction function.
[0122] The purpose of periodically sampling the real-time forward and reverse flow times of the gas according to the sampling method in step 2) and predicting the next forward and reverse flow times based on the newly sampled data is to prevent large deviations in the model's prediction results. The data predicted by the model at the beginning has higher accuracy.
[0123] 12) For the data predicted by the time prediction RNN integrated model, when the gas flow rate v m = 0, when the predicted data t m1_up =t m1_down and the initial sampled data t i1_up =ti1_down When the difference between the two reaches the lower limit of the time threshold, a security warning will be issued to the remote terminal.
[0124] During the use of the gas meter, as time goes by, dust accumulates more and more, forming a certain thickness, which reduces the propagation path of ultrasonic waves in the gas. The reduction in the propagation path of ultrasonic waves is directly reflected in the real-time forward and reverse flow time difference, so when the predicted data t m1_up =t m1_down and the initial sampled data t i1_up =t i1_down When the difference between them reaches the lower limit of the time threshold, a fault will occur. The time prediction RNN model can thus realize the prediction function.
[0125] Because gas flow in closed pipes affects ultrasonic propagation, there is a time difference between the downstream and upstream propagation of ultrasonic waves. A gas meter is a velocity-based instrument that records this time difference. The real-time upstream and downstream propagation velocities of ultrasonic waves in gas are determined by the propagation velocity of the ultrasonic wave in the gas at rest and the axial velocity component of the fluid along the direction of ultrasonic wave propagation. The downstream propagation velocity of ultrasonic waves in gas is greater than the upstream propagation velocity. Figure 1 This is a diagram showing the specific working principle of a time-difference gas meter. The gas flow rate can be derived using the relationship between the time difference between the downstream propagation time and the upstream propagation time and the propagation distance.
[0126]
[0127]
[0128]
[0129] Where: t m_up Indicates the real-time downstream propagation time of ultrasonic waves in the fluid; t m_down represents the real-time countercurrent propagation time of ultrasonic waves in the fluid; L represents the length of the sound channel; c s represents the time it takes for the sound wave to propagate in the fluid; v m Indicates the average axial velocity of the gas; Indicates the channel angle.
[0130] This invention utilizes a time-prediction RNN integrated model to predict ultrasonic gas meter faults. The time difference between the real-time forward and reverse flow of ultrasonic waves in the gas is used to determine whether a time threshold has been reached, serving as a criterion for determining whether a fault has occurred. This integrated model can predict the occurrence of faults, thereby mitigating potential safety hazards.
[0131] Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for ultrasonic gas meter fault prediction based on recurrent neural network, comprising the following steps: 1) Pre-train the time prediction RNN ensemble model; the time prediction RNN ensemble model includes a downstream time prediction RNN model and a downstream time prediction RNN model. The time prediction RNN ensemble model is pre-trained using a normal ultrasonic wave propagation time dataset in the downstream and downstream directions of the fluid. The downstream time prediction RNN model and the downstream time prediction RNN model are trained for 10 epochs respectively. The structure of the downstream time prediction RNN model and the downstream time prediction RNN model is as follows: the original input signal size is 32*1, and after using LSTM, a feature layer with a dimension of 32*16 is obtained. A dropout operation is used to obtain a new feature layer with a dimension of 32*16. A feature layer with a dimension of 32 is obtained by using LSTM, and a new feature layer with a dimension of 32 is obtained by using dropout. A feature layer with a dimension of 1 is obtained by using full connection. The loss function is used to calculate the difference between the predicted next data and the actual data. 2) Collect ultrasonic gas related historical data; monitor and sample relevant time data of ultrasonic gas meter; take the initial downstream propagation time t of each ultrasonic wave in the fluid i_up , the initial countercurrent propagation time of ultrasonic wave in the fluid t i_down ; Then, the ultrasonic gas is sampled continuously for a period of time, and the real-time sampling and recording of the real-time downstream propagation time of the gas t m_up , real-time countercurrent propagation time t m_down , take a sample point every 20 seconds; 3) Preprocess the real-time downstream gas historical data collected in step 2); convert the obtained real-time downstream propagation time t m_up Data, according to the ratio of training set: test set = 8:2, the first 80% of the data is used as the training set data, and the remaining 20% of the data is used as the test set data; the real-time downstream propagation time t collected in the training set m_up The data is segmented with overlap, that is, 32 sample points are taken every other sample point. In this way, the following time series array can be obtained for the collected samples: array i_up ={t i ,t i+1 ,......t i+32 },i∈[1,n] in, i represents the i-th group of data, and n is the last group of data in the training set; 4) Input the preprocessed training set data into the downstream time prediction RNN model to obtain the output result; Real-time downstream propagation time t m_up Make predictions; Use the downstream time prediction RNN model; the input of this model is the time series array in the training set: array i_up Where i represents the i-th time series array, i∈[1,n]; The output is the next data to be predicted; each time a set of data is input, the next data of this set of data will be output; these output numbers are recorded as F = {f1, f2, ... f n }; the corresponding true value sequence is T={t 33 ,t 34, ……,t n+32 }, where n represents the last digit of the training set prediction; 5) Output data F = {f1, f2, ... f n }Perform the following preprocessing: f o_i =softmax(f i ),i∈[1,n] (1) F O ={f o_1 ,f o_2 ,……f o_n } (2) Among them, f o_i is the preprocessed prediction data, i represents the i-th data; F O is the preprocessed prediction dataset; f in i Represents the predicted data output by the model, and i represents the i-th data; f in j It represents the predicted data output by the model, and j represents the jth data; For real data T={t 33 ,t 34, ……,t n+32 } for preprocessing, t o_i =softmax(t i+33 ),i∈[1,n] (4) T O ={t o_1 ,t o_2 ,……t o_n } (5) Among them, t o_i is the preprocessed real data, i represents the i-th data; T O It is a preprocessed real data set; t in i+33 Represents real data, i represents the i-th data; t in j+33 Represents the real data, j represents the jth data; The loss function is used to calculate the error between the predicted value and the true value: By continuously training the model and adjusting the parameters in the downstream time prediction RNN model, the loss function L i The value of continues to approach 0; 6) Test the model using the test set; input the test set data into the trained downstream time prediction RNN model, output the predicted downstream time, and use the loss function to calculate the error between the predicted downstream time and the true value to determine whether the loss function result is within a reasonable range; if it is within a reasonable range, the model training is complete; if not, return to step 4) to retrain the model; 7) Preprocess the real-time gas counterflow historical data collected in step 2); obtain the real-time counterflow propagation time t m_down Data, according to the ratio of training set: test set = 8:2, the first 80% of the data is used as the training set data, and the remaining 20% of the data is used as the test set data; the real-time countercurrent propagation time t collected in the training set is m_down The data is segmented with overlap, i.e. 32 sample points are taken every 1, so that the collected samples can be used to obtain the following time series array: array i_down ={t i ,t i+1 ,.....t i+32 } Among them, i represents the i-th group of data, and n is the last group of data in the training set; 8) Input the pre-processed training set data into the reverse flow time prediction RNN model to obtain the output result; Real-time countercurrent propagation time t m_down Make predictions; Use the reverse time prediction RNN model; the input of this model is the time series array in the training set: array i_down Where i represents the i-th time series array; The output is the next data to be predicted; each time a set of data is input, the next data of this set of data will be output; these output numbers are recorded as P = {p1, p2, ... p n }; the corresponding real value sequence is R = {r 33 ,r 34, ……,r n+32 }, where n represents the last digit of the training set prediction; 9) Output data P = {p1, p2, ... p n } for preprocessing, p o_i =softmax(p i ),i∈[1,n] (9) P O ={p o_1 ,p o_2 ,……p o_n } (10) Among them, p o_i is the preprocessed prediction data, i represents the i-th data; P O is the preprocessed prediction dataset; p in i Represents the predicted data output by the model, and i represents the i-th data; p in j It represents the predicted data output by the model, and j represents the jth data; For real data R={r 33 ,r 34, ……,r n+32 } for preprocessing, r o_i =softmax(r i+33 ),i∈[1,n] (12) R O ={r o_1 ,r o_2 ,……r o_n} (13) Among them, r o_i is the preprocessed real data, i represents the i-th data; R O It is a preprocessed real data set; r in i+33 Represents real data, i represents the i-th data; r in j+33 Represents the real data, j represents the jth data; The loss function is used to calculate the error between the predicted value and the true value: By continuously training the model and adjusting the parameters in the reverse time prediction RNN model, the loss function L i The value of continues to approach 0; 10) Testing the RNN model for backflow time prediction using the test set; inputting the data from the test set into the trained RNN model for backflow time prediction, outputting the predicted backflow time, and applying a loss function to calculate the error between the predicted backflow time and the true value to determine whether the result of the loss function is within a reasonable range; if it is within a reasonable range, the model training is complete; if not, returning to step 2) to retrain the model; 11) The downstream time prediction RNN model and the downstream time prediction RNN model are simply combined to form a time prediction RNN integrated model. The time prediction RNN integrated model samples the real-time upstream and downstream time of the gas in real time according to the sampling method in step 2) at regular intervals, predicts the upstream and downstream time of the gas, and realizes the model prediction function; 12) For the predicted data, when the gas flow rate v m = 0, when the predicted data t m1_up =t m1_down and the initially recorded forward and reverse flow time data t i1_up =t i1_down When the difference between the two reaches the lower limit of the time threshold, a security warning will be issued to the remote terminal.
Citation Information
Patent Citations
Ultrasonic gas meter fault diagnosis system and method
CN111323100A
Ultrasonic water meter data restoration method based on deep learning model
CN112132324A