Piezoelectric rainfall measurement method based on optimized depth time sequence prediction network
By applying deep learning technology and multi-sensor fusion in piezoelectric rain meter, the CNN-LSTM-Attention neural network is constructed, which solves the nonlinear signal characteristics and external interference problems of piezoelectric rain meter in rainfall measurement, significantly improving measurement accuracy and real-time performance.
Patent Information
- Application Number
- CN202411459769.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-25
AI Technical Summary
The existing piezoelectric rain meter has nonlinear signal characteristics and external interference problems in rainfall measurement, resulting in insufficient measurement accuracy and real-time performance.
A method based on optimized deep timing prediction network is adopted, combined with deep learning technology and multi-sensor fusion technology, a CNN-LSTM-Attention neural network is built to automatically learn the complex nonlinear relationship between the turntable rain meter and the piezoelectric sensor, and to eliminate external interference using wind speed data.
It effectively compensates for the nonlinear error in the output rainfall value of the piezoelectric sensor, improves the noise resistance of the system, and significantly improves the calibration accuracy and the accuracy of rainfall measurement.
Smart Images

Figure CN119511414A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical fields of meteorological monitoring and rainfall measurement, and specifically relates to a high-precision piezoelectric rainfall measurement method based on an optimized deep time series prediction network. Background Art
[0002] In meteorological observation, rainfall is an extremely important indicator, which is directly related to human life and property safety. Natural disasters such as floods and landslides are often closely related to rainfall, so real-time monitoring of rainfall has important economic significance.
[0003] At present, the commonly used ground rainfall measurement equipment in meteorological stations include tipping bucket rain gauges, siphon rain gauges and weighing rain gauges. However, there are many problems with the existing rainfall measurement methods, which limit their accuracy and practicality. For example, the most commonly used tipping bucket rain gauge in meteorological stations uses mechanical moving parts, which are easy to age, and its water inlet is easily blocked by debris. In addition, the tipping bucket rain gauge is based on the principle of rainfall measurement, which is to dump the tipping bucket after it is filled with rain, and trigger a measurement at the same time. In the case of small rainfall, the tipping bucket rain gauge will complete a full dumping only after a period of rainfall, and the record of the start time of rainfall is seriously delayed. At the same time, it is not sensitive to the collection of weak rainfall data information such as drizzle. In addition, the measurement accuracy of the tipping bucket rain gauge is limited by the volume of the tipping bucket, which makes its measurement range under high rainfall intensity relatively narrow, and the measurement error gradually increases with the increase of rainfall intensity. The siphon rain gauge relies on manual operation, and staff need to frequently go to the site to record data and replace recording paper, which makes it difficult to achieve real-time monitoring. Weighing rain gauges often have large errors during heavy rainfall due to the influence of drainage and other links.
[0004] The piezoelectric rain gauge uses piezoelectric ceramics as a sensing element. According to the force of the raindrop hitting the sensor, the size of each raindrop is identified, and the total rainfall is calculated by accumulating and summing the raindrop values. Compared with the tipping bucket rain gauge, the piezoelectric rain gauge has a larger rainfall measurement range and better real-time performance. The principle of the piezoelectric rain gauge is that when raindrops hit the surface of the piezoelectric ceramic, vibrations are caused and a gradually decaying voltage waveform is generated in the circuit, and the intensity of the initial signal is proportional to the mass of the raindrop. The existing piezoelectric rain gauge is based on an adaptive calibration method of a tipping bucket rain gauge and a piezoelectric sensor, which specifically refers to: in a simulated rainfall environment, the rainfall within a period of time is calculated by the pulse signal of the tipping bucket rain gauge as the standard value of the rainfall during this period, and then the peak voltage of the piezoelectric sensor is used to input the model for cumulative rainfall calculation. The errors of the two form an error surface, and the piezoelectric rain sensor is calibrated by iteratively optimizing the parameters to minimize the error, and finally the calibration coefficient and calibration curve are obtained. Although this adaptive calibration method based on the tipping bucket rain gauge and piezoelectric sensor can realize the calibration of the piezoelectric rain gauge, it still has many limitations. First, the tipping bucket rain gauge has a low resolution and can only record a fixed rainfall increment each time it flips, which cannot accurately reflect the details of small rainfall or rainfall changes. Second, the output signal of the piezoelectric sensor has nonlinear characteristics, and its response is affected by factors such as raindrop size and speed, making it difficult to accurately fit it through a simple model. In addition, the piezoelectric sensor is sensitive to external environmental noise and is easily disturbed by factors such as wind or vibration, which causes signal distortion and affects the accuracy of the calibration.
[0005] Therefore, how to effectively overcome the problem of insufficient resolution of the tipping bucket rain gauge, accurately model and process the nonlinear characteristics of the piezoelectric sensor output signal, and improve the system's anti-noise performance, has become a key challenge to further improve the measurement accuracy and real-time performance of the piezoelectric rain gauge. The solution to these problems has important theoretical and practical significance for achieving high-precision, real-time rainfall monitoring. Summary of the invention
[0006] In order to overcome the shortcomings of the prior art that the rainfall signal output by the piezoelectric sensor presents nonlinear characteristics and is easily disturbed by wind, the present invention provides a piezoelectric rainfall measurement method based on an optimized deep time series prediction network, introduces deep learning technology, combines multi-sensor fusion technology, and utilizes the advantages of deep learning models. It can automatically learn the complex nonlinear relationship between the tipping bucket rain gauge and the piezoelectric sensor from a large amount of data without relying on a manually designed model. At the same time, it eliminates the external interference of wind on the piezoelectric rainfall signal output by the piezoelectric sensor in combination with wind speed data. By training this neural network model, the method effectively compensates for the nonlinear error in the rainfall value output by the piezoelectric sensor, improves the anti-noise performance of the system, and thus significantly improves the calibration accuracy.
[0007] The technical solution adopted by the present invention to solve the technical problem is:
[0008] A piezoelectric rainfall measurement method based on an optimized deep time series prediction network comprises the following steps:
[0009] Step 1: Obtain piezoelectric ADC rainfall signal data at the target location, as well as synchronized wind speed information, temperature and humidity information, and rainfall information. The piezoelectric ADC rainfall signal data refers to signal data collected by the piezoelectric sensor at the target location, while the synchronized wind speed information, temperature and humidity information, and rainfall information come from signal data obtained by the wind speed sensor, temperature and humidity sensor, and tipping bucket rain gauge installed at the same location, respectively.
[0010] Step 2: extracting a piezoelectric raindrop waveform sequence from the piezoelectric ADC rainfall signal data, and extracting a piezoelectric raindrop waveform sequence caused by raindrop impact by processing the piezoelectric ADC rainfall signal data, so as to reduce the amount of model calculation and enhance the extraction efficiency of key features;
[0011] Step 3: Based on the synchronized rainfall data, the corresponding piezoelectric raindrop waveform data and the synchronized wind speed, temperature and humidity information are obtained; then, the obtained rainfall is used as the label of the piezoelectric raindrop waveform, wind speed, temperature and humidity to construct a data set containing four types of information: piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall;
[0012] Step 4: Based on the piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall data sets, a rainfall estimation neural network is constructed and trained. The network uses a neural network structure that combines convolutional neural network (CNN), long short-term memory network (LSTM), and attention mechanism (Attention), namely the CNN-LSTM-Attention architecture, to enhance the model's ability to capture time series dependencies and important features, thereby achieving accurate estimation of rainfall;
[0013] Step 5: Reacquire the rainfall data output by the piezoelectric sensor ADC, and simultaneously collect wind speed, temperature and humidity data to create a test set; after the above processing, the test set data is input into the trained model to perform actual rainfall prediction.
[0014] Further, the process of step 2 is as follows:
[0015] Step 2.1: Convert the piezoelectric ADC rainfall signal data into millivolt values through basic conversion and perform data centralization to improve numerical stability and enhance model performance; the ADC used has a 16-bit resolution, a sampling rate of 20 kHz and a reference voltage of 3.3 V, with a total sampling point number of 1.2 × 10 per minute. 6 The nth sampling value of ADC per minute is d n, the corresponding analog voltage v n The conversion formula is:
[0016]
[0017] Where n = 1, 2, 3…, N, N = 1.2×10 6 ,v n The unit is mv, which is millivolt;
[0018] The centralization formula is:
[0019]
[0020] in, Represents the average value of the analog voltage per minute, v n ′ represents the analog voltage data after removing the average value. Through this conversion, the ADC output data is standardized to the corresponding millivolt value, and combined with central processing to improve the consistency of the data and the generalization ability of the model;
[0021] Step 2.2: Bandpass filter the centralized piezoelectric rainfall data. The bandpass filter can filter out low-frequency drift and high-frequency noise, and remove invalid noise beyond the frequency range of raindrop signals, thereby improving the signal-to-noise ratio and signal quality. This step aims to retain the effective frequency components related to raindrops, further optimize the availability of data, and ensure the accuracy of subsequent analysis and processing.
[0022] Step 2.3: The filtered data contains continuous raindrop signals and noise. By analyzing the statistical characteristics of these data, the threshold of the piezoelectric raindrop waveform is determined to extract the effective waveform sequence. Due to the differences in the length of the collected waveform sequences, in order to ensure data consistency, a zero-filling method is used to fill all piezoelectric raindrop waveform sequences to the same length T for subsequent analysis and model training; the piezoelectric raindrop waveform sequence is recorded as x = [x1, x2, ..., x T ], after the above processing, each piezoelectric raindrop waveform can be regarded as corresponding to a single raindrop, reflecting the process of raindrop impacting the piezoelectric sensor.
[0023] Furthermore, the process of step 4 is as follows:
[0024] Step 4.1, load the piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall data set, and standardize the piezoelectric raindrop waveform sequence x, with its mean and standard deviation denoted as μ and σ respectively:
[0025]
[0026]
[0027] The normalized vector x′ is calculated by the following formula:
[0028]
[0029] where x i represents the sampling point in the piezoelectric raindrop waveform sequence, i = 1, 2, 3…, T, so the vector representation of the piezoelectric raindrop waveform sequence after standardization is:
[0030]
[0031] Step 4.2: For the processing path of the standardized piezoelectric raindrop waveform signal, the network uses two one-dimensional convolutional modules (Conv1D Block), each of which consists of a one-dimensional convolutional layer (1D CNN) and a maximum pooling layer (Max Pool1D) to extract the temporal features of the waveform layer by layer; then, these extracted features are input into a bidirectional long short-term memory network (BiLSTM) to capture the temporal dependencies in the waveform. Subsequently, the network introduces the attention mechanism (Attention) to further emphasize the focus on important features;
[0032] Step 4.3: For the processing path of wind speed, temperature and humidity data, the network first uses a linear layer (LinearLayer) to perform feature mapping on these meteorological features, and uses a rectified linear unit (ReLU) for nonlinear activation; the processed meteorological features are then connected with the piezoelectric raindrop waveform features processed by step 4.2. Specifically, the two are fused through the Concat Layer to form a comprehensive feature representation; finally, through the multi-layer perceptron (MLPBlock), dimensionality reduction and nonlinear transformation are gradually performed, and finally a regression value, i.e., the predicted value of rainfall, is output.
[0033] In step 4.2, the one-dimensional convolutional neural network (1D CNN) is a convolution operation commonly used to process sequence data (such as time series or text data). For the input sequence (normalized piezoelectric raindrop waveform sequence) and the convolution kernel (filter), the calculation formula for each element in the output sequence of the one-dimensional convolution is as follows:
[0034]
[0035]
[0036] in, is the input sequence of length T, w is the convolution kernel of length k, y is the output sequence of length T′, the length T′ depends on the input sequence length T, the size of the convolution kernel k, the type of padding size p and the stride s, i represents the position index in the output sequence, and j represents the position index in the convolution kernel.
[0037] In step 4.2, the one-dimensional maximum pooling (MaxPool1D) is used to further reduce the feature dimension of the convolutional layer output and retain the most significant features. Its mathematical expression is:
[0038]
[0039] Among them, y i is the output sequence after the MaxPool1D operation, x is the output sequence of the 1D CNN, s is the stride, and k is the size of the pooling window. i is the index of the output sequence, corresponding to the i-th position after the MaxPool1D operation. s·i represents the position of the starting position of the pooling window in the input signal, and j represents the specific position within the window, taking into account the stride s and the dilation d. This pooling process effectively reduces the dimensionality of the features by selecting the maximum value in each pooling window, retaining the main features in the signal, thereby improving the generalization ability and computational efficiency of the model.
[0040] In step 4.2, the bidirectional long short-term memory network (BiLSTM) is composed of two independent LSTMs, one for processing the forward sequence and the other for processing the reverse sequence; the input sequence of the BiLSTM is the output sequence processed by two one-dimensional convolutional layers twice, denoted as x t ; The forward LSTM processes the sequential information of the input sequence from time step t=1 to t=T, while the reverse LSTM processes the reverse information from t=T to t=1. The BiLSTM concatenates the outputs of these two LSTMs to capture the bidirectional dependencies in the sequence. Suppose the hidden state and memory unit of the forward LSTM are and The hidden state and memory unit of the reverse LSTM are and For a BiLSTM input x at time step t t , the formula of BiLSTM is as follows:
[0041] 1) Forward LSTM
[0042] Forget Gate:
[0043] Input Gate:
[0044] Candidate memory cells:
[0045] Update memory unit:
[0046] Output Gate:
[0047] Update the hidden state: Among them, in the forget gate, σ is the Sigmoid function, is the current input x t The weight matrix of It is the hidden state of the previous moment. The weight matrix of is the bias term of the forget gate, The subscript f in represents the forget gate. It is the output of the forget gate at time step t, which controls how much memory from the previous moment needs to be "forgotten" at the current moment;
[0048] Enter the door, is the current input x t The weight matrix of It is the hidden state of the previous moment. The weight matrix of is the bias term of the input gate, The subscript i in the formula represents the input gate. t is the input gate output at time step t, which controls the degree of retention of the current input information;
[0049] W in the candidate memory unit C is the weight matrix of the current input to the candidate memory unit, is the weight matrix of the previous hidden state for the candidate memory unit, is the bias term of the candidate memory cell, The subscript C in represents the candidate memory cell. is the candidate memory cell value, used to generate new memory content;
[0050] In the update memory unit, ⊙ represents element-by-element multiplication (Hadamard product), is the memory unit of the previous moment, is an updated memory unit that combines the memory of the previous moment and the new input of the current moment;
[0051] In the output gate, is the weight matrix of the output gate for the current input, It is the hidden state of the previous moment. The weight matrix of is the bias term of the output gate, The subscript o in the output gate indicates the output gate.t is the output of the output gate at time step t, which controls the strength of the hidden state output at the current moment;
[0052] In updating the hidden state, tanh is the hyperbolic tangent function, Indicates the hidden state at the current moment;
[0053] 2) Reverse LSTM
[0054] Forget Gate:
[0055] Input Gate:
[0056] Candidate memory cells:
[0057] Update memory unit:
[0058] Output Gate:
[0059] Update hidden state:
[0060] The structure of the reverse LSTM is the same as that of the forward LSTM, except that the time step is updated from back to front. The form of the formula is the same as that of the forward LSTM, except that all symbols have reverse arrows.
[0061] In step 4.2, the attention mechanism is a technique in a neural network that assigns different weights to different parts of an input sequence, so that the model can focus on more important parts of the input sequence. The following is a mathematical expression of the attention mechanism combined with LSTM output:
[0062] Assume that the output of LSTM is h t , the process of the attention mechanism is as follows:
[0063] 1) Calculate the attention score
[0064] e t,i =score(h t ,h i )(twenty two)
[0065] where h t is the LSTM output of the current time step, h i is the LSTM output of all time steps, score is the function to calculate the attention score, which measures the correlation between two time steps, e t,i represents the correlation score between the current time step t and other time steps i, called the "attention score";
[0066] 2) Calculate attention weight
[0067]
[0068] 3) Calculate the context vector
[0069] context t =∑ i α t,i h i (twenty four)
[0070] where α t,i represents the attention weight of time step i for the current time step t. This formula converts the attention score e into t,i Normalized to a probability distribution, indicating the importance of each time step to the current moment. t Represents the context vector of the current time step t, which is the output h of all time steps i The result of weighted summation. By outputting h of LSTM at each time step i According to the corresponding attention weight α t,i Weighted, calculate the context representation of the current time step.
[0071] In step 4.3, the MLP Block is composed of three Linear Layers and ReLU;
[0072] The Linear Layer is one of the basic layers in the neural network. It performs a linear transformation. The mathematical formula of the linear layer is as follows:
[0073] y=Wx+b(25)
[0074] Among them, y is the output of the linear layer, x is the input of the linear layer, W is the weight matrix, that is, the weight matrix maps the input to the output dimension, and b is the bias vector;
[0075] The ReLU is a commonly used activation function in deep learning. It can introduce nonlinearity so that the neural network can fit complex nonlinear models. The mathematical expression of ReLU is as follows:
[0076] ReLU = max(0,x)(26)
[0077] Where x is the input of ReLU;
[0078] The rainfall estimation neural network uses the mean square error loss function, and its mathematical expression is as follows:
[0079]
[0080] Among them, yi Indicates that the i-th sample is the true value, represents the predicted value of the i-th sample, and N is the total number of samples.
[0081] The beneficial effects of the present invention are mainly manifested in: effectively compensating for the nonlinear error in the rainfall value output by the piezoelectric sensor, improving the anti-noise performance of the system, and thus significantly improving the calibration accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] Figure 1 It is a flow chart of a piezoelectric rainfall measurement method based on an optimized deep time series prediction network.
[0083] Figure 2 This is the structure diagram of the CNN-LSTM-Attention neural network.
[0084] Figure 3 It is a comparison curve between the predicted results and the true values.
[0085] Figure 4 It is the Loss curve diagram of the method of the present invention. DETAILED DESCRIPTION
[0086] The present invention will be further described below in conjunction with the accompanying drawings.
[0087] Reference Figure 1 to Figure 3 , a piezoelectric rainfall measurement method based on an optimized deep time series prediction network comprises the following steps:
[0088] Step 1: Obtain piezoelectric ADC rainfall signal data at the target location, as well as synchronized wind speed information, temperature and humidity information, and rainfall information. The piezoelectric ADC rainfall signal data refers to signal data collected by the piezoelectric sensor at the target location, while the synchronized wind speed information, temperature and humidity information, and rainfall information come from signal data obtained by the wind speed sensor, temperature and humidity sensor, and tipping bucket rain gauge installed at the same location, respectively.
[0089] Step 2: Extract the piezoelectric raindrop waveform sequence from the piezoelectric ADC rainfall signal data. By processing the piezoelectric ADC rainfall signal data, the piezoelectric raindrop waveform sequence caused by the raindrop impact is extracted to reduce the model calculation amount and enhance the extraction efficiency of key features. The process is as follows:
[0090] Step 2.1: The piezoelectric ADC rainfall signal data is converted into millivolt value through basic conversion, and data is centralized to improve numerical stability and enhance model performance. The ADC used in the present invention has a 16-bit resolution, a sampling rate of 20 kHz, and a reference voltage of 3.3 V. The total number of sampling points per minute is 1.2×10 6 The nth sampling value of ADC per minute is dn , the corresponding analog voltage v n The conversion formula is:
[0091]
[0092] Where n = 1, 2, 3…, N, N = 1.2×10 6 ,v n The unit is mv, which is millivolt;
[0093] The centralization formula is:
[0094]
[0095] in, Represents the average value of the analog voltage per minute, v n ′ represents the analog voltage data after removing the average value. Through this conversion, the ADC output data is standardized to the corresponding millivolt value, and combined with the centralization process to improve the consistency of the data and the generalization ability of the model;
[0096] Step 2.2: Bandpass filter the centralized piezoelectric rainfall data. The bandpass filter is used to filter out low-frequency drift and high-frequency noise, and remove invalid noise beyond the frequency range of raindrop signals, thereby improving the signal-to-noise ratio and signal quality. This step aims to retain the effective frequency components related to raindrops, further optimize the availability of data, and ensure the accuracy of subsequent analysis and processing.
[0097] Step 2.3: The filtered data contains continuous raindrop signals and noise. By analyzing the statistical characteristics of these data, the threshold of the piezoelectric raindrop waveform is determined to extract the effective waveform sequence. Due to the differences in the length of the collected waveform sequences, in order to ensure data consistency, the zero-filling method is used to fill all piezoelectric raindrop waveform sequences to the same length T for subsequent analysis and model training. The piezoelectric raindrop waveform sequence is denoted as x = [x1, x2, ..., x T ], after the above processing, each piezoelectric raindrop waveform can be regarded as corresponding to a single raindrop, reflecting the process of raindrop impacting the piezoelectric sensor;
[0098] Step 3: Based on the synchronized rainfall data, the corresponding piezoelectric raindrop waveform data and the synchronized wind speed, temperature and humidity information are obtained; then, the obtained rainfall is used as the label of the piezoelectric raindrop waveform, wind speed, temperature and humidity to construct a data set containing four types of information: piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall;
[0099] Step 4: Based on the piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall datasets, a rainfall estimation neural network is constructed and trained. The network adopts a neural network structure that combines convolutional neural network (CNN), long short-term memory network (LSTM), and attention mechanism (Attention), namely, CNN-LSTM-Attention architecture, to enhance the model's ability to capture time series dependencies and important features, thereby achieving accurate estimation of rainfall. The network structure is as follows: Figure 2 As shown, the process is as follows:
[0100] Step 4.1, load the piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall data set, and standardize the piezoelectric raindrop waveform sequence x, with its mean and standard deviation denoted as μ and σ respectively:
[0101]
[0102]
[0103] The normalized vector x′ can be calculated using the following formula:
[0104]
[0105] where x i represents the sampling point in the piezoelectric raindrop waveform sequence, i = 1, 2, 3…, T, so the vector representation of the piezoelectric raindrop waveform sequence after standardization is:
[0106]
[0107] Step 4.2: For the processing path of the standardized piezoelectric raindrop waveform signal, the network uses two one-dimensional convolutional modules (Conv1D Block), each of which consists of a one-dimensional convolutional layer (1D CNN) and a maximum pooling layer (Max Pool1D) to extract the temporal features of the waveform layer by layer; then, these extracted features are input into a bidirectional long short-term memory network (BiLSTM) to capture the temporal dependencies in the waveform; then, the network introduces the attention mechanism (Attention) to further emphasize the focus on important features;
[0108] The one-dimensional convolutional neural network (1D CNN) is a convolution operation commonly used to process sequence data (such as time series or text data). For the input sequence (normalized piezoelectric raindrop waveform sequence) and the convolution kernel (filter), the calculation formula for each element in the output sequence of the one-dimensional convolution is as follows:
[0109]
[0110]
[0111] in, is the input sequence of length T, w is the convolution kernel of length k, and y is the output sequence of length T′, where the length T′ depends on the input sequence length T, the size of the convolution kernel k, the type of padding size p, and the stride s, as shown in (3.2). i represents the position index in the output sequence. j represents the position index in the convolution kernel.
[0112] The one-dimensional maximum pooling (MaxPool1D) is used to further reduce the feature dimension of the convolutional layer output and retain the most significant features. Its mathematical expression is:
[0113]
[0114] Among them, y i is the output sequence after the MaxPool1D operation, x is the output sequence of the 1D CNN, s is the stride, and k is the size of the pooling window. i is the index of the output sequence, corresponding to the i-th position after the MaxPool1D operation. s·i represents the starting position of the pooling window in the input signal, and j represents the specific position within the window, taking into account the stride s and the dilation d. This pooling process effectively reduces the dimension of the feature by selecting the maximum value in each pooling window, retaining the main features in the signal, thereby improving the generalization ability and computational efficiency of the model;
[0115] The BiLSTM is composed of two independent LSTMs, one for processing the forward sequence and the other for processing the reverse sequence (the input sequence of BiLSTM is Figure 3 The output sequence processed by two one-dimensional convolutional layers is denoted as x t ), the forward LSTM processes the sequential information of the input sequence from time step t=1 to t=T, while the reverse LSTM processes the reverse information from t=T to t=1. The BiLSTM concatenates the outputs of these two LSTMs to capture the bidirectional dependencies in the sequence. Suppose the hidden state and memory unit of the forward LSTM are and The hidden state and memory unit of the reverse LSTM are and For a BiLSTM input x at time step t t , the formula of BiLSTM is as follows:
[0116] 1) Forward LSTM
[0117] Forget Gate:
[0118] Input Gate:
[0119] Candidate memory cells:
[0120] Update memory unit:
[0121] Output Gate:
[0122] Update the hidden state: Among them, in the forget gate, σ is the Sigmoid function, is the current input x t The weight matrix of It is the hidden state of the previous moment. The weight matrix of is the bias term of the forget gate, The subscript f in represents the forget gate. It is the output of the forget gate at time step t, which controls how much memory from the previous moment needs to be "forgotten" at the current moment;
[0123] Enter the door, is the current input x t The weight matrix of It is the hidden state of the previous moment. The weight matrix of is the bias term of the input gate, The subscript i in denotes the input gate, is the input gate output at time step t, which controls the degree of retention of the current input information;
[0124] Candidate memory cells is the weight matrix of the current input to the candidate memory unit, is the weight matrix of the previous hidden state for the candidate memory unit, is the bias term of the candidate memory cell, The subscript C in represents the candidate memory cell. is the candidate memory cell value, used to generate new memory content;
[0125] In the update memory unit, ⊙ represents element-by-element multiplication (Hadamard product), is the memory unit of the previous moment, is an updated memory unit that combines the memory of the previous moment and the new input of the current moment;
[0126] In the output gate, is the weight matrix of the output gate for the current input, It is the hidden state of the previous moment. The weight matrix of is the bias term of the output gate, The subscript o in represents the output gate, is the output of the output gate at time step t, which controls the strength of the hidden state output at the current moment;
[0127] In updating the hidden state, tanh is the hyperbolic tangent function, Indicates the hidden state at the current moment;
[0128] 2) Reverse LSTM
[0129] Forget Gate:
[0130] Input Gate:
[0131] Candidate memory cells:
[0132] Update memory unit:
[0133] Output Gate:
[0134] Update hidden state:
[0135] The structure of the reverse LSTM is the same as that of the forward LSTM, except that the time step is updated from back to front. The form of the formula is the same as that of the forward LSTM, except that all symbols have reverse arrows;
[0136] The attention mechanism is a technique in neural networks that assigns different weights to different parts of an input sequence, allowing the model to focus on more important parts of the input sequence. The following is a mathematical expression of the attention mechanism combined with LSTM output:
[0137] Assume that the output of LSTM is h t , the process of the attention mechanism is as follows:
[0138] 1) Calculate the attention score
[0139] e t,i =score(h t ,h i )(twenty two)
[0140] where h t is the LSTM output of the current time step, h i is the LSTM output of all time steps, score is the function to calculate the attention score, which measures the correlation between two time steps, e t,irepresents the correlation score between the current time step t and other time steps i, which is called the “attention score”.
[0141] 2) Calculate attention weight
[0142]
[0143] 3) Calculate the context vector
[0144] context t =Σ i α t,i h i (twenty four)
[0145] where α t,i represents the attention weight of time step i for the current time step t. This formula converts the attention score e into t,i Normalized to a probability distribution, indicating the importance of each time step to the current moment. t Represents the context vector of the current time step t, which is the output h of all time steps i The result of weighted summation. By outputting h of LSTM at each time step i According to the corresponding attention weight α t,i Weighted, calculate the context representation of the current time step;
[0146] Step 4.3: For the processing path of wind speed, temperature and humidity data, the network first uses a linear layer (LinearLayer) to perform feature mapping on these meteorological features, and uses a rectified linear unit (ReLU) for nonlinear activation; the processed meteorological features are then connected with the piezoelectric raindrop waveform features processed by step 4.2. Specifically, the two are fused through the Concat Layer to form a comprehensive feature representation; finally, through the multi-layer perceptron (MLPBlock), dimensionality reduction and nonlinear transformation are gradually performed, and finally a regression value, i.e., the predicted value of rainfall, is output;
[0147] The MLP Block is composed of three Linear Layers and ReLU;
[0148] The Linear Layer is one of the basic layers in the neural network, which performs a linear transformation. The mathematical formula of the linear layer is as follows:
[0149] y=Wx+b(25)
[0150] Among them, y is the output of the linear layer, x is the input of the linear layer, W is the weight matrix, that is, the weight matrix maps the input to the output dimension, and b is the bias vector;
[0151] The ReLU is a commonly used activation function in deep learning. It can introduce nonlinearity so that the neural network can fit complex nonlinear models. The mathematical expression of ReLU is as follows:
[0152] ReLU = max(0,x)(26)
[0153] Where x is the input of ReLU;
[0154] The rainfall estimation neural network uses the mean square error loss function, and its mathematical expression is as follows:
[0155]
[0156] Among them, y i Indicates that the i-th sample is the true value, represents the predicted value of the i-th sample, and N is the total number of samples;
[0157] Step 5: Reacquire the rainfall data output by the piezoelectric sensor ADC, and simultaneously collect wind speed, temperature and humidity data to create a test set; after the above processing, the test set data is input into the trained model to perform actual rainfall prediction.
[0158] In the real rainfall measurement experiment of the method of the present invention, the piezoelectric rainfall data collected on November 18, November 28 and November 30, 2022 in the area of 30°16′30″N, 119°57′38″E were selected as training data, as well as the synchronized environmental parameters such as temperature, humidity and wind speed and the corresponding real rainfall. The data set contains a total of 300,000 raindrop waveform sequences and their corresponding real rainfall as training samples of the model. Based on this data set, the present invention predicts the rainfall on January 31, 2024. At the same time, in order to verify the effectiveness of the model, the convolutional neural network model and the long short-term memory network model are used for prediction. The comparison curve between the prediction results and the true values is shown in the figure. Figure 3 shown.
[0159] As can be seen from the above figure, in the prediction experiment on January 31, 2024, the prediction effects of the CNN model and the LSTM model are poor, and the deviation between the prediction results and the true values is large. The prediction results of the method of the present invention are closest to the true values, and the cumulative error is within 5%.
[0160] The actual rainfall value at 30°16′30″N, 119°57′38″E on January 31, 2024 is 39 mm. The prediction results and errors of each model are shown in Table 1:
[0161]
[0162]
[0163] Table 1
[0164] From the Loss loss curve of the method of the present invention (such as Figure 4 As shown in the figure, both the training loss and the validation loss drop rapidly in the early stage of training, indicating that the model can quickly learn effective features. As the training progresses, the validation loss tends to stabilize, indicating that the model has strong generalization ability in the medium term. Although slight overfitting may occur in the middle and late stages, the overfitting trend is effectively suppressed by appropriate regularization strategies (such as the introduction of the Dropout layer). Finally, the validation loss gradually approaches the training loss, indicating that the model's performance on the validation set is relatively stable and has good generalization ability.
[0165] The overall architecture of the CNN-LSTM-Attention model constructed by the method of the present invention is as follows: the input data is first subjected to two convolution and pooling operations for feature extraction, and then the data dimension is adjusted to adapt to the input requirements of the LSTM layer. After the LSTM layer, the model introduces the Attention mechanism to enhance the ability to capture key time series features. Subsequently, external features such as temperature, humidity, and wind speed are fused through the fully connected layer, and finally the prediction results are generated through the output layer. Through multiple experimental optimizations, including adjusting hyperparameters such as the number of convolution kernels and the number of neurons in the LSTM layer, the network structure and parameter configuration were finally determined, as shown in Table 2. Among them, the learning rate of the model is set to 0.001.
[0166] Table 2 is a network structure table of the method of the present invention.
[0167]
[0168] Table 2
[0169] The contents described in the embodiments of this specification are merely enumerations of implementation forms of the inventive concept and are for illustrative purposes only. The protection scope of the present invention should not be considered to be limited to the specific forms described in this embodiment, and the protection scope of the present invention also extends to equivalent technical means that can be thought of by ordinary technicians in this field based on the inventive concept.
Claims
1. A piezoelectric rainfall measurement method based on an optimized deep time series prediction network, characterized in that: The method comprises the following steps: Step 1: Obtain piezoelectric ADC rainfall signal data at the target location, as well as synchronized wind speed information, temperature and humidity information, and rainfall information. The piezoelectric ADC rainfall signal data refers to signal data collected by the piezoelectric sensor at the target location, while the synchronized wind speed information, temperature and humidity information, and rainfall information come from signal data obtained by the wind speed sensor, temperature and humidity sensor, and tipping bucket rain gauge installed at the same location, respectively. Step 2: extracting a piezoelectric raindrop waveform sequence from the piezoelectric ADC rainfall signal data, and extracting a piezoelectric raindrop waveform sequence caused by raindrop impact by processing the piezoelectric ADC rainfall signal data, so as to reduce the amount of model calculation and enhance the extraction efficiency of key features; Step 3: Based on the synchronized rainfall data, the corresponding piezoelectric raindrop waveform data and the synchronized wind speed, temperature and humidity information are obtained; then, the obtained rainfall is used as the label of the piezoelectric raindrop waveform, wind speed, temperature and humidity to construct a data set containing four types of information: piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall; Step 4: Based on the piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall data sets, a rainfall estimation neural network is constructed and trained. The network adopts a neural network structure that combines convolutional neural network CNN, long short-term memory network LSTM, and attention mechanism Attention, namely the CNN-LSTM-Attention architecture; Step 5: Reacquire the rainfall data output by the piezoelectric sensor ADC, and simultaneously collect wind speed, temperature and humidity data to create a test set; after the above processing, the test set data is input into the trained model to perform actual rainfall prediction.
2. A piezoelectric rainfall measurement method based on an optimized deep time series prediction network as claimed in claim 1, characterized in that: The process of step 2 is as follows: Step 2.1: Convert the piezoelectric ADC rainfall signal data into millivolt values through basic conversion and perform data centralization to improve numerical stability and enhance model performance; the ADC used has a 16-bit resolution, a sampling rate of 20 kHz and a reference voltage of 3.3 V, with a total sampling point number of 1.2 × 10 per minute. 6 The nth sampling value of ADC per minute is d n , the corresponding analog voltage v n The conversion formula is: Where n = 1, 2, 3…, N, N = 1.2×10 6 ,v n The unit is mv, which is millivolt; The centralization formula is: in, Represents the average value of the analog voltage per minute, v n ′ represents the analog voltage data after removing the average value. Through this conversion, the ADC output data is standardized to the corresponding millivolt value, and combined with central processing to improve the consistency of the data and the generalization ability of the model; Step 2.2: Bandpass filter the centralized piezoelectric rainfall data. The bandpass filter can filter out low-frequency drift and high-frequency noise, and remove invalid noise beyond the frequency range of raindrop signals, thereby improving the signal-to-noise ratio and signal quality. This step aims to retain the effective frequency components related to raindrops, further optimize the availability of data, and ensure the accuracy of subsequent analysis and processing. Step 2.3: The filtered data contains continuous raindrop signals and noise. By analyzing the statistical characteristics of these data, the threshold of the piezoelectric raindrop waveform is determined to extract the effective waveform sequence. Due to the differences in the lengths of the collected waveform sequences, in order to ensure data consistency, the zero-filling method is used to fill all piezoelectric raindrop waveform sequences to the same length T for subsequent analysis and model training; the piezoelectric raindrop waveform sequence is denoted as x = [x1, x2, …, x T ], after the above processing, each piezoelectric raindrop waveform can be regarded as corresponding to a single raindrop, reflecting the process of raindrop impacting the piezoelectric sensor.
3. A piezoelectric rainfall measurement method based on an optimized deep time series prediction network as described in claim 1 or 2, characterized in that: The process of step 4 is as follows: Step 4.1, load the piezoelectric raindrop waveform, wind speed, temperature and humidity, and rainfall data set, and standardize the piezoelectric raindrop waveform sequence x, with its mean and standard deviation denoted as μ and σ respectively: The normalized vector x′ is calculated by the following formula: where x i represents the sampling point in the piezoelectric raindrop waveform sequence, i = 1, 2, 3…, T, so the vector representation of the piezoelectric raindrop waveform sequence after standardization is: Step 4.2: For the processing path of the standardized piezoelectric raindrop waveform signal, the network uses two one-dimensional convolutional modules Conv1D Block. Each one-dimensional convolutional module consists of a one-dimensional convolutional layer 1D CNN and a maximum pooling layer MaxPool1D, which is used to extract the temporal features of the waveform layer by layer. Then, these extracted features are input into a bidirectional long short-term memory network BiLSTM to capture the temporal dependencies in the waveform. Subsequently, the network introduces the attention mechanism Attention to further emphasize the focus on important features. Step 4.3: For the processing path of wind speed, temperature and humidity data, the network first uses the linear layer to perform feature mapping on these meteorological features, and uses the rectified linear unit ReLU for nonlinear activation; the processed meteorological features are then connected with the piezoelectric raindrop waveform features processed by step 4.
2. Specifically, the two are fused through the Concat Layer to form a comprehensive feature representation; finally, the multi-layer perceptron MLP Block is used to gradually perform dimensionality reduction and nonlinear transformation, and finally a regression value is output, which is the predicted value of rainfall.
4. A piezoelectric rainfall measurement method based on an optimized deep time series prediction network as claimed in claim 3, characterized in that: In step 4.2, the one-dimensional convolutional neural network 1D CNN is a convolution operation for processing sequence data. For the input sequence, i.e., the standardized piezoelectric raindrop waveform sequence and the convolution kernel, i.e., the filter, the calculation formula for each element in the output sequence of the one-dimensional convolution is as follows: in, is the input sequence of length T, w is the convolution kernel of length k, y is the output sequence of length T′, the length T′ depends on the input sequence length T, the size of the convolution kernel k, the type of padding size p and the stride s, i represents the position index in the output sequence, and j represents the position index in the convolution kernel.
5. A piezoelectric rainfall measurement method based on an optimized deep time series prediction network as claimed in claim 3, characterized in that: In step 4.2, the one-dimensional maximum pooling MaxPool1D is used to further reduce the feature dimension of the convolutional layer output and retain the most significant features. Its mathematical expression is: Among them, y i is the output sequence after the MaxPool1D operation, x is the output sequence of the 1D CNN, s is the stride, k is the size of the pooling window, i is the index of the output sequence corresponding to the i-th position after the MaxPool1D operation, s·i represents the position of the starting position of the pooling window in the input signal, and j represents the specific position within the window, taking into account the stride s and the dilation d.
6. A piezoelectric rainfall measurement method based on an optimized deep time series prediction network as claimed in claim 3, characterized in that: In step 4.2, the bidirectional long short-term memory network BiLSTM is composed of two independent LSTMs, one for processing the forward sequence and the other for processing the reverse sequence; the input sequence of BiLSTM is the output sequence processed by two one-dimensional convolutional layers twice, denoted as x t ; The forward LSTM processes the sequential information of the input sequence from time step t=1 to t=T, while the reverse LSTM processes the reverse information from t=T to t=1. The BiLSTM concatenates the outputs of these two LSTMs to capture the bidirectional dependencies in the sequence. Suppose the hidden state and memory unit of the forward LSTM are and The hidden state and memory unit of the reverse LSTM are and For a BiLSTM input x at time step t t , the formula of BiLSTM is as follows: 1) Forward LSTM Forget Gate: Input Gate: Candidate memory cells: Update memory unit: Output Gate: Update the hidden state: Among them, in the forget gate, σ is the Sigmoid function, is the current input x t The weight matrix of It is the hidden state of the previous moment. The weight matrix of is the bias term of the forget gate, The subscript f in represents the forget gate. It is the output of the forget gate at time step t, which controls how much memory from the previous moment needs to be "forgotten" at the current moment; Enter the door, is the current input x t The weight matrix of It is the hidden state of the previous moment. The weight matrix of is the bias term of the input gate, The subscript i in denotes the input gate, is the input gate output at time step t, which controls the degree of retention of the current input information; Candidate memory cells is the weight matrix of the current input to the candidate memory unit, is the weight matrix of the previous hidden state for the candidate memory unit, is the bias term of the candidate memory cell, The subscript C in represents the candidate memory cell. is the candidate memory cell value, used to generate new memory content; In the update memory unit, ⊙ represents element-by-element multiplication (Hadamard product), is the memory unit of the previous moment, is an updated memory unit that combines the memory of the previous moment and the new input of the current moment; In the output gate, is the weight matrix of the output gate for the current input, It is the hidden state of the previous moment. The weight matrix of is the bias term of the output gate, The subscript o in represents the output gate, is the output of the output gate at time step t, which controls the strength of the hidden state output at the current moment; In updating the hidden state, tanh is the hyperbolic tangent function, Indicates the hidden state at the current moment; 2) Reverse LSTM Forget Gate: Input Gate: Candidate memory cells: Update memory unit: Output Gate: Update hidden state: The structure of the reverse LSTM is the same as that of the forward LSTM, except that the time step is updated from back to front. The form of the formula is consistent with that of the forward LSTM, except that all symbols have reverse arrows.
7. A piezoelectric rainfall measurement method based on an optimized deep time series prediction network as claimed in claim 3, characterized in that: In step 4.2, the attention mechanism is a technique in a neural network that assigns different weights to different parts of an input sequence, so that the model can focus on more important parts of the input sequence. The following is a mathematical expression of the attention mechanism combined with the LSTM output: Assume that the output of LSTM is h t , the process of the attention mechanism is as follows: 1) Calculate the attention score e t,i =score(h t ,h i ) (22) where h t is the LSTM output of the current time step, h i is the LSTM output of all time steps, score is the function to calculate the attention score, which measures the correlation between two time steps, e t,i represents the correlation score between the current time step t and other time steps i, called the "attention score"; 2) Calculate attention weight 3) Calculate the context vector context t =∑ i α t,i h i (24) where α t,i represents the attention weight of time step i for the current time step t. This formula converts the attention score e into t,i Normalized to a probability distribution, indicating the importance of each time step to the current moment, context t Represents the context vector of the current time step t, which is the output h of all time steps i The result of weighted summation is obtained by outputting h of LSTM at each time step. i According to the corresponding attention weight α t,i Weighted, calculate the context representation of the current time step.
8. The piezoelectric rainfall measurement method based on optimized deep time series prediction network according to claim 3, characterized in that: In step 4.3, the MLP Block is composed of three Linear Layers and ReLU; The Linear Layer is one of the basic layers in the neural network. It performs a linear transformation. The mathematical formula of the linear layer is as follows: y=Wx+b (25) Among them, y is the output of the linear layer, x is the input of the linear layer, W is the weight matrix, that is, the weight matrix maps the input to the output dimension, and b is the bias vector; The ReLU deep learning activation function can introduce nonlinearity, so that the neural network can fit complex nonlinear models. The mathematical expression of ReLU is as follows: ReLU=max(0,x) (26) Where x is the input of ReLU; The rainfall estimation neural network uses the mean square error loss function, and its mathematical expression is as follows: Among them, y i Indicates that the i-th sample is the true value, represents the predicted value of the i-th sample, and N is the total number of samples.
Citation Information
Cited By
Beidou navigation system short-time rainfall prediction method based on LSTM network
CN120045849A