An ultrasonic water meter flow prediction method and system based on a hybrid neural network
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-06
- Publication Date
- 2026-08-11
AI Technical Summary
[0005]鉴于以上现有技术的不足,本发明实施例的目的在于提供一种基于混合神经网络的超声波水表流量预测方法,能够解决现有技术存在的传统控制模型与单一神经网络模型对多源特征的时序关联性融合不够充分、对复杂动态状态的适配性仍有提升空间、且尚未实现控制结果不确定性的有效量化的技术问题
[0009]本发明实施例提供的技术方案带来的有益效果至少包括:
Smart Images

Figure CN122544882A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart water management technology, and in particular to a method and system for predicting the flow rate of ultrasonic water meters based on a hybrid neural network. Background Technology
[0002] With the rapid development of smart city and IoT technologies, ultrasonic water meters, as a new generation of intelligent metering devices, have been widely used for real-time monitoring and metering of residential, commercial, and industrial water use due to their non-mechanical structure, high accuracy, fast response, and long service life. However, since they calculate flow based on the time difference of ultrasonic wave propagation upstream and downstream, they need to cope with complex operating conditions such as fluid disturbance, temperature changes, and electronic noise. To achieve refined water resource management, leakage monitoring, and water use behavior analysis, more reliable flow prediction technologies are urgently needed.
[0003] Current technologies for ultrasonic water meter flow prediction mainly fall into two categories: one is the traditional physical model based on fluid dynamics principles, which calculates flow rate by combining parameters such as pipe diameter and transducer spacing; the other is a single neural network model, such as LSTM and GRU, which achieves prediction by learning the mapping relationship of historical time-series data, and is accompanied by auxiliary technologies such as data filtering, noise reduction, normalization processing, and flow curve fitting. These technologies have laid the metrological foundation for ultrasonic water meters, promoted the upgrade from mechanical metering to intelligent sensing, met basic flow monitoring needs, and provided important references for subsequent technology optimization.
[0004] However, existing technologies still have room for improvement in practical applications: traditional physical models and single neural network models do not fully integrate the temporal correlation of multi-source features, there is still room for improvement in adaptability to complex fluid states, and effective quantification of the uncertainty of prediction results has not yet been achieved. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the purpose of this invention is to provide an ultrasonic water meter flow prediction method based on a hybrid neural network, which can solve the technical problems of insufficient fusion of the temporal correlation of multi-source features by traditional control models and single neural network models, room for improvement in adaptability to complex dynamic states, and failure to effectively quantify the uncertainty of control results.
[0006] A first aspect of this invention proposes a method for predicting the flow rate of an ultrasonic water meter based on a hybrid neural network, comprising: S1: Acquire measurement data from the ultrasonic water meter and construct a dataset based on the measurement data. The dataset includes flight time, temperature data, and pulse width ratio. S2: Filter the flight time and determine the filtered flight time; S3: Perform feature expansion on the filtered flight time and temperature data to obtain expanded features; S4: The expanded features and the pulse width ratio are fused by a pre-trained shared temporal encoder to obtain a shared feature vector; S5: Input the shared feature vector into the pre-trained fluid state recognition network to obtain the probability distribution vector of the fluid state; S6: Input the shared feature vector, the probability distribution vector of the fluid state, and the prior physical flow rate in the expanded features into the pre-trained probabilistic flow prediction network, and output the flow prediction result.
[0007] A second aspect of this invention provides an ultrasonic water meter flow prediction system based on a hybrid neural network, comprising: a processor and a memory; The memory stores programs or instructions that can run on the processor, which, when executed by the processor, implement the steps of the ultrasonic water meter flow prediction method based on a hybrid neural network as described in the first aspect.
[0008] A third aspect of the present invention provides a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the ultrasonic water meter flow prediction method based on a hybrid neural network as described in the first aspect.
[0009] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: In this embodiment of the invention, a shared time-series encoder is used to achieve deep fusion of multi-source time-series features, effectively improving the ability to capture time-series dynamics under complex working conditions; a fluid state recognition network is used to accurately identify the fluid state and input it as key prior knowledge into the prediction network, significantly enhancing the adaptability to complex fluid states; at the same time, a probabilistic flow prediction network is used to quantify uncertainty, enabling the model to not only output accurate flow values but also provide corresponding confidence assessments, thereby systematically improving the metering reliability and decision-making security of ultrasonic water meters under complex working conditions. Attached Figure Description
[0010] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. Obviously, the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without any creative effort.
[0011] Figure 1 This is a flowchart illustrating an ultrasonic water meter flow prediction method based on a hybrid neural network, provided in an embodiment of the present invention.
[0012] Figure 2 This is a schematic diagram of a shared temporal feature extraction network structure provided in an embodiment of the present invention.
[0013] Figure 3 This is a schematic diagram of a fluid state recognition decoder network structure provided in an embodiment of the present invention.
[0014] Figure 4 This is a schematic diagram of a probabilistic traffic prediction decoder network structure provided in an embodiment of the present invention.
[0015] Figure 5 This is a schematic diagram of the structure of an ultrasonic water meter flow prediction system based on a hybrid neural network, provided in an embodiment of the present invention. Detailed Implementation
[0016] To enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. It should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0017] The ultrasonic water meter flow prediction method based on hybrid neural networks provided by the present invention will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0018] Reference manual attached Figure 1 The diagram shows a flowchart of an ultrasonic water meter flow prediction method based on a hybrid neural network provided by an embodiment of the present invention.
[0019] This invention provides a method for predicting the flow rate of an ultrasonic water meter based on a hybrid neural network, which may include the following steps: S1: Acquire measurement data from the ultrasonic water meter and construct a dataset based on the measurement data. The dataset includes flight time, temperature data, and pulse width ratio.
[0020] Among them, time of flight refers to the time it takes for the ultrasonic wave to propagate in both directions within the pipe, temperature data refers to the temperature parameters of the measurement environment, and pulse width ratio refers to the ratio of the width of the first ultrasonic pulse.
[0021] Optionally, the dataset includes the upstream flight time, downstream flight time, upstream first pulse width ratio, downstream first pulse width ratio, temperature data, fluid state, and calibration station flow rate of the ultrasonic water meter.
[0022] Among them, upstream flight time refers to the time it takes for the ultrasonic wave to propagate upstream in the pipe, downstream flight time refers to the time it takes for the ultrasonic wave to propagate downstream in the pipe, upstream first pulse width ratio and downstream first pulse width ratio refer to the ratio of the width of the first pulse of the ultrasonic wave in the corresponding direction, fluid state refers to the operating state of the fluid in the pipe, and calibration station flow rate refers to the standard flow rate reference value provided by the calibration station.
[0023] Specifically, the dataset needs to cover both normal and abnormal fluid states. By setting a uniform sampling frequency and duration, and combining temperature and flow sampling points of different ranges and intervals, data collection and labeling can be completed.
[0024] For example, under normal fluid conditions, the sampling frequency is set to 2Hz, each sampling point is sampled for 25s, the water tank temperature is configured with temperature sampling points at fixed intervals within the range of 5℃ to 60℃, and the flow rate sampling points are densely and reasonably set in the low flow rate sub-range and the normal flow rate range, respectively, and the status label is marked as "normal".
[0025] Furthermore, under abnormal fluid conditions, the sampling frequency and sampling duration remain unchanged. Temperature sampling points are configured at fixed intervals within the water tank temperature range of 10℃ to 60℃. By configuring standard sediment solutions of different concentrations and injecting controllable air bubbles, different levels of abnormal sediment and air bubble conditions are simulated. The status labels strictly correspond to the simulated abnormality types, and the flow rate labels are all taken from the flow rate values given by the calibration station.
[0026] S2: Filter the flight time to determine the filtered flight time.
[0027] Among them, filtering refers to the data processing method to reduce noise interference, and the filtered flight time refers to the ultrasonic wave propagation time data after noise suppression.
[0028] In one possible implementation, S2 specifically includes sub-steps S201 to S208: S201: Based on time-of-flight, define the true time of flight as it evolves over time: ; in, x k Indicates the first k The actual flight time at any given moment x k-1 Indicates the first k -1 moment's actual flight time w k-1 Indicates the first k -1 time point process noise.
[0029] The actual flight time refers to the actual propagation time of the ultrasonic wave without noise interference, while the process noise is a random interference factor that follows a Gaussian distribution.
[0030] Specifically, to ensure the consistency of global data, all upstream and downstream flight time data should be treated as independent sequences, and a model of the temporal evolution of real flight time should be defined based on this.
[0031] S202: Based on actual flight time, define the observation equation between actual flight time and true flight time: ; in, z k Indicates the first k The measured flight time at each moment. v k Indicates the first k The observation noise at each moment.
[0032] Among them, the measured flight time refers to the flight time with noise directly collected by the water meter, and the observed noise refers to the random interference introduced during the measurement process.
[0033] It should be noted that establishing a correlation between measured data and actual values provides a core basis for state correction.
[0034] S203: Based on the observation equation and the posterior state estimate of the previous time step, calculate the prior state estimate of the actual flight time at the current time step: ; in, Indicates the first k Prior state estimate at time 1 Indicates the first k Posterior state estimate at time -1.
[0035] Among them, the prior state estimate refers to the predicted flight time at the current moment based on historical information, and the posterior state estimate refers to the optimal state value after correction by measured data.
[0036] It should be noted that using historical best estimates to derive the current prior value ensures the temporal continuity of the state estimation.
[0037] S204: Based on the prior state estimate at the current moment, the prior estimate error covariance at the current moment is calculated through covariance prediction. ; in, Indicates the first k The prior estimate error covariance at time 1 Indicates the first k-1 time step posterior estimation error covariance This represents the process noise covariance.
[0038] Among them, the prior / posterior estimation error covariance refers to the parameter that quantifies the uncertainty of the corresponding state estimation, and the process noise covariance refers to the parameter that characterizes the degree of process noise fluctuation.
[0039] It should be noted that quantifying the error level of the prior estimate provides a key basis for calculating the Kalman gain.
[0040] S205: Based on the prior estimation error covariance at the current time, the Kalman gain at the current time is obtained through gain calculation. ; in, K k Indicates the first k Kalman gain at each moment, R This represents the observation noise covariance.
[0041] Among them, Kalman gain refers to the coefficient that balances the weights of prior estimates and measured data, and observation noise covariance refers to the parameter that characterizes the degree of fluctuation in observation noise.
[0042] It should be noted that the rationality of state correction is improved by adaptively balancing the weights of prior information and measured data.
[0043] S206: Based on the prior state estimate, the Kalman gain, and the measured flight time at the current moment, the posterior state estimate is obtained by performing a state update calculation on the prior state estimate at the current moment. ; in, Indicates the first k The posterior state estimate at time t.
[0044] Among them, the state update calculation refers to the process of correcting the prior estimate using the measured residuals, and the posterior state estimate refers to the corrected optimal flight time estimate.
[0045] It should be noted that the accuracy of flight time estimation is improved by correcting the prior estimate with measured residuals.
[0046] S207: Based on the Kalman gain at the current time and the prior estimation error covariance at the current time, the posterior state error covariance at the current time is calculated through covariance update. ; in, Indicates the first k The posterior state error covariance at each time step.
[0047] Among them, covariance update calculation refers to the process of correcting the error covariance, while posterior state error covariance refers to the parameter that quantifies the uncertainty of the posterior estimate.
[0048] It should be noted that by calculating the posterior state error covariance, the reliability of the posterior estimate is accurately quantified, providing an error reference for subsequent iterations.
[0049] S208: In chronological order, the posterior state estimate of the current moment is used as the input for the prior state estimate of the next moment. The flight time of all time points is processed iteratively in sequence, and the filtered flight time is output.
[0050] Among them, iterative processing refers to the process of updating the state estimate in chronological order, and the filtered time of flight refers to the data after complete Kalman filtering and denoising.
[0051] It should be noted that the iterative processing must strictly follow the sampling order, and the above prediction and update steps must be performed sequentially for each time point to ensure that all flight time data are effectively processed.
[0052] Furthermore, the final output filtered time of flight includes both the filtered upstream and downstream time of flight, providing high-quality data support for subsequent feature processing.
[0053] It should be noted that by iteratively processing the flight times at all time points, noise suppression of the entire time series flight time is achieved, and high-quality data is output to support subsequent processing.
[0054] In this embodiment of the invention, a complete one-dimensional Kalman filter procedure for flight time series is defined. Through iterative calculations of state prediction and measurement updates, an optimal estimate of the actual flight time is achieved, providing a high-quality input signal for the model.
[0055] S3: Perform feature expansion on the filtered flight time and temperature data to obtain expanded features.
[0056] Feature expansion refers to the processing method of increasing feature dimensions, and expanded features refer to a comprehensive feature set that includes both original and newly added features.
[0057] In one possible implementation, S3 specifically includes sub-steps S301 to S304: S301: Calculate the average flight time by averaging the filtered flight time. ; in, t avg Indicates the average flight time. t upThis represents the filtered upstream flight time. t down This represents the downstream flight time after filtering.
[0058] The average flight time refers to the average of the upstream and downstream flight times after filtering. The upstream flight time after filtering refers to the upstream propagation time of the ultrasonic wave after filtering, and the downstream flight time after filtering refers to the downstream propagation time of the ultrasonic wave after filtering.
[0059] Specifically, the average flight time is mainly used to characterize the combined temperature and density of a medium, and its calculation is based on the average of the filtered upstream and downstream flight times.
[0060] Furthermore, to more accurately capture the temporal fluctuation characteristics of flight time, it is also necessary to calculate the upstream average flight time and the downstream average flight time based on the flight time at different times, as follows: ; in, Indicates the average flight time upstream. This represents the filtered upstream flight time of the previous time step. This represents the filtered upstream flight time at the current moment.
[0061] Among them, the upstream average flight time is the average of the upstream flight time at the previous moment and the current moment, which can smooth out the temporal noise interference of the upstream flight time.
[0062] Based on the filtered downstream flight times from the previous and current times, calculate the downstream average flight time: ; in, Indicates the average flight time downstream. This represents the filtered downstream flight time of the previous time step. This represents the filtered downstream flight time at the current moment.
[0063] Specifically, the calculation logic for downstream average flight time is consistent with that for upstream average flight time, and it is used to smooth out the temporal fluctuations in downstream flight time.
[0064] Next, based on the aforementioned upstream and downstream average flight times, it is necessary to further calculate the average flight time and the difference between them: ; in, This indicates the average flight time.
[0065] It should be noted that the average flight time can more comprehensively characterize the combined effects of medium temperature and density on the total propagation time of ultrasound, thus enriching the physical information dimension of the feature.
[0066] ; in, This represents the average time difference of flight.
[0067] Specifically, the mean time difference of flight is a temporal supplement to velocity-related characteristics, which can improve the stability and reliability of fluid velocity characterization.
[0068] S302: Normalize the filtered flight time to obtain the normalized flight time difference: ; in, This represents the normalized time-of-flight difference.
[0069] Among them, the normalized flight time difference refers to the normalized result of the flight time difference between upstream and downstream.
[0070] Specifically, its physical significance lies in characterizing the average flow velocity of the fluid inside the pipe, providing key velocity-related features for subsequent flow rate calculations.
[0071] It should be noted that the correlation of flow-related features is enhanced by characterizing the average flow velocity of the fluid inside the pipe.
[0072] S303: Prior physical flow is calculated using a physical model based on mean flight time and normalized time-of-flight difference. ; in, Q phy Indicates prior physical flow. D This indicates the pipe diameter of the ultrasonic water meter. L This indicates the effective propagation distance between ultrasonic transducers.
[0073] Among them, the prior physical flow rate refers to the flow rate reference value calculated based on the time-difference method physical model, the pipe diameter refers to the inner diameter of the ultrasonic water meter pipe, and the effective propagation distance refers to the actual propagation distance of the ultrasonic waves between the two ultrasonic transducers.
[0074] Furthermore, the calculation of prior physical flow incorporates the characteristics of the average flight time and the normalized flight time difference, while also introducing pipeline structure parameters to enhance the physical correlation of the characteristics.
[0075] It should be noted that incorporating prior physical knowledge from the time difference method enhances the physical consistency of subsequent predictions.
[0076] S304: Combine the average flight time, normalized time difference, and prior physical flow to expand the features and obtain expanded features.
[0077] Among them, expanded features refer to the comprehensive feature set that integrates the three types of features.
[0078] It should be noted that by integrating multi-dimensional physical-related features, comprehensive feature support is provided for subsequent network modeling.
[0079] In this embodiment of the invention, a feature construction method based on physical principles is described in detail. By introducing features such as prior physical flow, a preliminary fusion of the data-driven method and the physical model is achieved, enhancing the physical consistency and interpretability of the model output.
[0080] Reference manual attached Figure 2 The diagram illustrates a shared temporal feature extraction network structure provided by an embodiment of the present invention.
[0081] exist Figure 2 In the middle, Preprocessed Data N win ×C in Represents preprocessed data, where N win C is the length of the time window. in The input feature dimension is the input data of the shared temporal feature extraction network; Deep Feature Extraction represents the deep feature extraction module, which is the core functional module for feature extraction; Conv1dBlock1, Conv1dBlock2, and Conv1dBlock3 are all one-dimensional convolutional blocks, which are parallel sub-modules within the deep feature extraction module; Conv1d1 represents a one-dimensional convolutional layer, which is the feature extraction layer within the one-dimensional convolutional block; ReLU represents a ReLU activation layer, used to introduce non-linear feature transformations into the network; GRU represents a gated recurrent unit, which is the temporal feature processing unit within the deep feature extraction module; Deep FeatureVector h shared This represents the shared deep feature vector, which is the feature output of the network.
[0082] Figure 2 The inclusion relationship is as follows: the deep feature extraction module contains three parallel one-dimensional convolutional blocks (Conv1dBlock1, Conv1dBlock2, Conv1dBlock3) and one gated recurrent unit (GRU); each one-dimensional convolutional block (Conv1dBlock1, Conv1dBlock2, Conv1dBlock3) contains a one-dimensional convolutional layer (Conv1d1) and a ReLU activation layer (ReLU).
[0083] Figure 2The connections in the diagram clearly illustrate the feature processing flow of the shared temporal feature extraction network: Preprocessed Data N win ×C in The input is fed into three parallel one-dimensional convolutional blocks (Conv1dBlock1, Conv1dBlock2, and Conv1dBlock3); the outputs of the three one-dimensional convolutional blocks are connected to a gated recurrent unit (GRU); the output of the GRU is connected to a shared deep feature vector. shared ).
[0084] Figure 2 The shared temporal feature extraction network shown captures multi-scale local temporal features through parallel one-dimensional convolutional blocks and gated recurrent units to capture long-term temporal dependencies, effectively extracting shared deep features that combine local details and global correlations, providing high-quality feature support for subsequent fluid state recognition and flow prediction.
[0085] S4: By using a pre-trained shared temporal encoder, the expanded features and the pulse width ratio are fused through temporal feature encoding to obtain a shared feature vector.
[0086] Among them, the shared temporal encoder refers to the feature extraction structure that integrates multi-scale one-dimensional convolution and gated recurrent units, the temporal feature encoding fusion refers to the process of encoding and fusing temporal features, and the shared feature vector refers to the unified deep features after encoding and fusion.
[0087] Specifically, the construction of the shared temporal encoder includes two stages: the first stage is a multi-scale one-dimensional convolutional module, which consists of three parallel convolutional blocks, each of which consists of a one-dimensional convolutional layer and a ReLU activation layer; the second stage is a gated recurrent unit, which adaptively retains or forgets historical information at each time step through a gating mechanism to generate a unified deep feature vector.
[0088] Optionally, the shared temporal encoder includes a multi-scale one-dimensional convolutional unit and a gated recurrent unit connected in sequence.
[0089] The multi-scale one-dimensional convolutional unit consists of three parallel convolutional blocks, each of which is composed of a one-dimensional convolutional layer and a ReLU activation layer connected in sequence.
[0090] The outputs of the three parallel convolutional blocks are connected to the input of the gated recurrent unit, and the output of the gated recurrent unit outputs a shared feature vector.
[0091] Among them, multi-scale one-dimensional convolutional units refer to parallel convolutional structures containing three different convolutional kernels, gated recurrent units refer to units that retain or forget historical information through gating mechanisms, one-dimensional convolutional layers refer to network layers that extract temporal local features, and ReLU activation layers refer to activation layers that introduce nonlinear features.
[0092] Specifically, the first stage of the shared temporal encoder is a multi-scale one-dimensional convolutional unit, whose input is a temporal segment of a specific dimension. The three parallel convolutional blocks can capture local mutation features of different granularities respectively.
[0093] For example, the kernels of the three parallel convolutional blocks can be selected with different values to cover temporal features of different ranges, such as short, medium and long, and the time window length of the temporal segment can be set to a fixed value.
[0094] Specifically, the first stage of the shared temporal encoder is a multi-scale one-dimensional convolutional unit, whose input is a dimension of... N A time segment of ×7, N Indicates the length of the time window.
[0095] For example, time window length N The kernel value is preferably set to 6, and the kernel values of the three parallel convolutional blocks are preferably 3, 5, and 7, respectively, to capture local mutation features of different granularities.
[0096] Furthermore, the second stage of the shared temporal encoder is a gated recurrent unit, whose input is a vector concatenated from the outputs of three convolutional blocks along the feature dimension. Through a gating mechanism, historical information is adaptively retained or forgotten at each time step, ultimately generating a unified deep feature vector with a dimension of 1×128.
[0097] Furthermore, the second stage of the shared temporal encoder is a gated recurrent unit, whose input is a vector concatenated from the outputs of three convolutional blocks along the feature dimension. Through a gating mechanism, historical information is adaptively retained or forgotten at each time step, ultimately generating a unified deep feature vector.
[0098] In this embodiment of the invention, a hybrid architecture is used to fully leverage the local feature extraction capabilities of CNNs and the sequence modeling advantages of GRUs, significantly improving the comprehensiveness of temporal feature encoding. It achieves unified capture of local mutation patterns and long-term dependencies, providing a high-level fused feature representation for downstream tasks.
[0099] Reference manual attached Figure 3 The diagram shows a schematic of a fluid state recognition decoder network structure provided by an embodiment of the present invention.
[0100] In the figure, Deep Feature Vector h sharedThis represents the shared feature vector extracted and input by the shared temporal encoder, with a dimension of 1×128. The fluid state recognition decoder network is a multilayer perceptron dedicated to fluid state classification, and its structure includes two hidden modules and one output module.
[0101] The first hidden module consists of a first fully connected layer FCNN (preferably with an output dimension of 64), a first ReLU activation layer, and a first Dropout layer (preferably with a dropout rate of 0.5) connected sequentially. The second hidden module consists of a second fully connected layer FCNN (preferably with an output dimension of 32), a second ReLU activation layer, and a second Dropout layer (preferably with a dropout rate of 0.5) connected sequentially. The output module consists of an output fully connected layer FCNN (with an output dimension of 7, corresponding to seven fluid states) and a Softmax activation layer connected sequentially.
[0102] Figure 3 The connection relationship of the network is clearly shown: the shared feature vector is used as input, and it flows through the first hidden module and the second hidden module in sequence to perform feature transformation and nonlinear mapping. Finally, the probability of belonging to each fluid state category is calculated through the output module, and a 1×7 state probability distribution vector is finally output.
[0103] Figure 3 The fluid state recognition decoder network shown achieves decoding and state identification of shared high-level features through multi-layer nonlinear transformation, and effectively prevents overfitting by combining the Dropout mechanism, thereby achieving accurate and robust identification of complex fluid states such as bubbles and silt.
[0104] S5: Input the shared feature vector into the pre-trained fluid state recognition network to obtain the probability distribution vector of the fluid state.
[0105] Among them, the fluid state recognition network refers to the network that identifies the fluid state within the pipe section, and the probability distribution vector refers to the vector that represents the probability of various fluid states.
[0106] Optionally, the fluid state recognition network includes a first fully connected layer, a second fully connected layer, and an output layer connected in sequence.
[0107] The first fully connected module consists of a first fully connected layer, a first ReLU activation layer, and a first Dropout layer connected in sequence.
[0108] The second fully connected module consists of a second fully connected layer, a second ReLU activation layer, and a second Dropout layer connected sequentially.
[0109] The output module consists of an output fully connected layer and a Softmax activation layer connected in sequence.
[0110] The input of the first fully connected module receives the shared feature vector, and the output of the Softmax activation layer outputs the probability distribution vector.
[0111] Among them, the fully connected module refers to the feature transformation unit composed of fully connected layers, the Dropout layer refers to the network layer that prevents overfitting, the output fully connected layer refers to the network layer that maps features to the output dimension, and the Softmax activation layer refers to the activation layer that outputs the class probability.
[0112] Specifically, both the first and second fully connected modules achieve feature transformation and optimization through a combination of fully connected layers, ReLU activation layers, and Dropout layers. The output dimension of the fully connected layers and the Dropout value of both modules are optimally set.
[0113] Furthermore, the fully connected layer of the output module maps the features to the fluid state category dimension, and the Softmax activation layer converts the mapping result into a probability distribution form, so that the output vector can intuitively reflect the predicted probability of various fluid states.
[0114] Specifically, the output dimension of the fully connected layer of the first fully connected module is preferably 64, and the value of the Dropout layer is preferably 0.5; the output dimension of the fully connected layer of the second fully connected module is preferably 32, and the value of the Dropout layer is preferably 0.5.
[0115] Furthermore, the output dimension of the fully connected layer of the output module is 7, and the Softmax activation layer converts it into a state probability distribution vector with a dimension of 1×7, which intuitively reflects the predicted probability of various fluid states.
[0116] It should be noted that the fluid state recognition network achieves in-depth analysis of shared feature vectors through the cascaded processing of multiple modules, accurately outputting the probability distribution vector of fluid state, and providing key prior knowledge for subsequent flow prediction.
[0117] It should be noted that the generalization ability is improved by using multi-layer fully connected layers and Dropout layers, and the state probability is accurately output by combining the Softmax activation layer.
[0118] Optionally, the activation function of the Softmax activation layer is as follows: ; Where Softmax represents the activation function. x This represents the original output vector of the fluid state recognition network output layer. x i Indicates the first element in the output vector. i The output value of each node, x j Indicates the first element in the output vector.j The output value of each node, exp This represents the natural exponential function. This indicates the number of activations calculated using the Softmax activation function. i Predicted probability of fluid-like states.
[0119] In this embodiment of the invention, by quantifying the prediction probability of various fluid states, the accurate identification of fluid states within the pipe section is achieved, providing key prior knowledge for flow prediction.
[0120] Reference manual attached Figure 4 The diagram illustrates a network structure of a probabilistic traffic prediction decoder provided in an embodiment of the present invention.
[0121] exist Figure 4 In the context of Deep Feature Vector h shared The first vector represents the deep feature vector extracted by the shared temporal encoder, with a dimension of 1×128; the second vector represents the state probability distribution vector output by the fluid state recognition network, with a dimension of 1×7; and the third vector represents the prior physical flow calculated based on the physical model, which is a scalar input. These three multi-source information sources together constitute the input features of the decoder.
[0122] The probabilistic traffic prediction decoder network structure consists of two parts: a feature fusion encoder and a dual-branch output unit. The feature fusion encoder comprises three cascaded fully connected sub-modules: the first sub-module contains a fully connected FCNN layer with an output dimension of 256, sequentially connected to a ReLU activation layer, a batch normalization (BN) layer, and a Dropout layer; the second sub-module maintains the same structure, with an output dimension of 128; the third sub-module contains a fully connected layer with an output dimension of 64 and a ReLU activation layer. The dual-branch output unit adopts a parallel structure: the mean branch contains two cascaded fully connected blocks with output dimensions of 32 and 1 respectively; the variance branch also contains two cascaded fully connected blocks with output dimensions of 16 and 1 respectively.
[0123] Figure 4 The connection relationships clearly illustrate the decoder's workflow: the three input features first undergo deep fusion and nonlinear transformation through three cascaded sub-modules in the feature fusion encoder; the generated unified feature representation is simultaneously fed into the dual-branch output; the mean branch and variance branch are calculated independently, and finally, the mean of the flow prediction is output in parallel. μ and variance σ² .
[0124] Figure 4The probabilistic decoder shown deeply integrates data-driven features, fluid state priors, and physical knowledge, and uses a dual-branch structure to explicitly model and predict uncertainties. This enables ultrasonic water meters to not only output accurate flow values under complex operating conditions, but also provide corresponding confidence assessments, significantly improving the reliability of metering and the security of decision-making.
[0125] S6: Input the shared feature vector, the probability distribution vector of the fluid state, and the prior physical flow rate in the expanded features into the pre-trained probabilistic flow prediction network, and output the flow prediction result.
[0126] Among them, the probabilistic traffic prediction network refers to the network that realizes traffic prediction and uncertainty quantification, and the traffic prediction result refers to the output containing the predicted value and uncertainty.
[0127] It should be noted that the construction of the probabilistic traffic prediction network consists of two main parts. The first part, the multilayer perceptron, is composed of three cascaded fully connected sub-modules. The first sub-module contains a fully connected layer, a ReLU activation layer, a batch normalization layer, and a Dropout layer, with an output dimension of 256. The second sub-module has the same structure as the first sub-module, with an output dimension of 128. The third sub-module consists of a fully connected layer and a ReLU activation layer, with an output dimension of 64. In the second part, the dual-branch structure consists of two cascaded fully connected blocks, with output dimensions of 32 and 1, respectively; the variance branch also consists of two cascaded fully connected blocks, with output dimensions of 16 and 1, respectively.
[0128] In this embodiment of the invention, the mean and variance of the flow rate are predicted separately using a dual-branch structure, thereby quantifying the uncertainty of the prediction results and improving the reliability of the measurement results and the security of decision-making. By fusing multi-dimensional information, accurate flow rate prediction is achieved while quantifying the uncertainty of the prediction.
[0129] Optionally, after S6, it also includes: S7: Based on the dataset, by dividing the training set, validation set, and test set according to a preset ratio, a joint loss function is constructed and an iterative optimization algorithm is used to complete the training of the shared temporal encoder, the fluid state recognition network, and the probabilistic flow prediction network. The joint loss function is specifically as follows: ; in, L Denotes the joint loss function. α This represents the coefficient used to weigh the loss term in balancing fluid state identification. β This represents the coefficient used to balance the weights of the loss term in traffic forecasting. L state This represents the loss term corresponding to the fluid state recognition network. L flowThis represents the loss term for a probabilistic traffic prediction network.
[0130] Among them, the joint loss function refers to the optimization objective function that combines the losses of two types of tasks, the iterative optimization algorithm refers to the algorithm that iteratively updates the network parameters, and the training set / validation set / test set refers to the data sets used for parameter learning, training monitoring, and performance evaluation, respectively.
[0131] It should be noted that those skilled in the art can set the preset ratio according to actual needs, and this invention does not limit that.
[0132] Specifically, during model training, the sample data is divided into training, validation, and test sets in a 7:2:1 ratio. The Adam optimization algorithm with a learning rate of 0.001 and a batch size of 64 is used to iteratively update the network parameters. Backpropagation and gradient updates are performed with the joint loss function as the objective until the performance of the validation set meets the preset convergence condition.
[0133] Furthermore, the weighting coefficients of the fluid state identification loss term in the joint loss function α The value is set to 0.35, and the weighting coefficient β for the traffic prediction loss term is set to 0.65. These coefficients can be adjusted based on experimental results on the validation set to optimize model performance.
[0134] For example, in practical applications, after collecting the operating data of the ultrasonic water meter, the data is sequentially passed through a pre-trained shared temporal encoder and a fluid state recognition network to output the probability distribution of each fluid state. The state with the highest probability is selected as the recognition result. Then, the shared features, the fluid state probability distribution, and the prior physical flow rate are input into a pre-trained probabilistic flow prediction network to finally obtain the predicted flow rate and the corresponding uncertainty quantification result.
[0135] It should be noted that by aligning the dual-task optimization objectives through a joint loss function, the network's recognition and prediction performance is improved through iterative training.
[0136] The ultrasonic water meter flow prediction method based on a hybrid neural network provided in this application can be executed by an ultrasonic water meter flow prediction device based on a hybrid neural network. This application uses the example of an ultrasonic water meter flow prediction device based on a hybrid neural network executing the ultrasonic water meter flow prediction method based on a hybrid neural network to illustrate the ultrasonic water meter flow prediction device based on a hybrid neural network provided in this application.
[0137] Reference manual attached Figure 5 The diagram shows a schematic of the structure of an ultrasonic water meter flow prediction system based on a hybrid neural network provided in an embodiment of the present invention.
[0138] This invention provides an ultrasonic water meter flow prediction system 20 based on a hybrid neural network, comprising: a processor 201 and a memory 202; The memory 202 stores programs or instructions that can run on the processor 201. When the program or instructions are executed by the processor 201, they implement the steps of the ultrasonic water meter flow prediction method based on the hybrid neural network described above and can achieve the same technical effect. To avoid repetition, the present invention will not elaborate further.
[0139] It should be understood that the processor 201 in this embodiment of the invention may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0140] It should also be understood that the memory 202 in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DR RAM).
[0141] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.
[0142] It should be understood that, in various embodiments of the present invention, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0143] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0144] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0145] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0146] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0147] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0148] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0149] This invention provides a readable storage medium comprising: storing a program or instructions on the readable storage medium, wherein when the program or instructions are executed by a processor, the program or instructions implement the steps of the above-described ultrasonic water meter flow prediction method based on a hybrid neural network, and can achieve the same technical effect. To avoid repetition, this invention will not elaborate further.
[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the protection scope of the present invention.
Claims
1. A method for predicting the flow rate of an ultrasonic water meter based on a hybrid neural network, characterized in that, include: S1: Acquire measurement data from the ultrasonic water meter and construct a dataset based on the measurement data, wherein the dataset includes flight time, temperature data, and pulse width ratio; S2: Filter the flight time to determine the filtered flight time; S3: Perform feature expansion on the filtered flight time and temperature data to obtain expanded features; S4: The expanded feature and the pulse width ratio are fused by a pre-trained shared temporal encoder to obtain a shared feature vector; S5: Input the shared feature vector into the pre-trained fluid state recognition network to obtain the probability distribution vector of the fluid state; S6: Input the shared feature vector, the probability distribution vector of the fluid state, and the prior physical flow rate in the expansion feature into a pre-trained probabilistic flow prediction network, and output the flow prediction result.
2. The ultrasonic water meter flow prediction method based on a hybrid neural network according to claim 1, characterized in that, The dataset includes the upstream flight time, downstream flight time, upstream first pulse width ratio, downstream first pulse width ratio, temperature data, fluid state, and calibration station flow rate of the ultrasonic water meter.
3. The ultrasonic water meter flow prediction method based on a hybrid neural network according to claim 1, characterized in that, S2 specifically includes: S201: Based on the stated flight time, define the actual flight time as it evolves over time: ; in, x k Indicates the first k The actual flight time at any given moment x k-1 Indicates the first k -1 moment's actual flight time w k-1 Indicates the first k -1 time-time process noise; S202: Based on the actual flight time, define the observation equation between the actual flight time and the true flight time: ; in, z k Indicates the first k The measured flight time at each moment. v k Indicates the first k Observation noise at each moment; S203: Based on the observation equation and the posterior state estimate of the previous time step, calculate the prior state estimate of the actual flight time at the current time step: ; in, Indicates the first k Prior state estimate at time 1 Indicates the first k Posterior state estimation at time -1; S204: Based on the prior state estimate at the current moment, the prior estimate error covariance at the current moment is calculated through covariance prediction. ; in, Indicates the first k The prior estimate error covariance at time 1 Indicates the first k -1 time step posterior estimation error covariance Represents the process noise covariance; S205: Based on the prior estimation error covariance at the current time, the Kalman gain at the current time is obtained through gain calculation. ; in, K k Indicates the first k Kalman gain at each moment, R Represents the observation noise covariance; S206: Based on the prior state estimate, the Kalman gain, and the measured flight time at the current moment, the posterior state estimate is obtained by performing a state update calculation on the prior state estimate at the current moment. ; in, Indicates the first k Posterior state estimation at time 1; S207: Based on the Kalman gain at the current time and the prior estimation error covariance at the current time, the posterior state error covariance at the current time is calculated through covariance update: ; in, Indicates the first k The posterior state error covariance at each time step; S208: In chronological order, the posterior state estimate of the current moment is used as the input for the prior state estimate of the next moment. The flight time of all time points is processed iteratively in sequence, and the filtered flight time is output.
4. The ultrasonic water meter flow prediction method based on a hybrid neural network according to claim 1, characterized in that, S3 specifically includes: S301: Calculate the average flight time by averaging the filtered flight time to obtain the average flight time: ; in, t avg Indicates the average flight time. t up This represents the filtered upstream flight time. t down This represents the downstream flight time after filtering; S302: Normalize the filtered flight time to obtain the normalized flight time difference: ; in, Indicates the normalized time-of-flight difference; S303: Based on the average flight time and the normalized flight time difference, the prior physical flow rate is calculated using a physical model: ; in, Q phy Indicates prior physical flow. D This indicates the pipe diameter of the ultrasonic water meter. L This indicates the effective propagation distance between ultrasonic transducers. S304: Combine the average flight time, the normalized flight time difference, and the prior physical flow to perform feature expansion and obtain the expanded feature.
5. The ultrasonic water meter flow prediction method based on a hybrid neural network according to claim 1, characterized in that, The shared temporal encoder includes a multi-scale one-dimensional convolutional unit and a gated loop unit connected in sequence; The multi-scale one-dimensional convolutional unit includes three parallel convolutional blocks, each of which consists of a one-dimensional convolutional layer and a ReLU activation layer connected in sequence. The outputs of the three parallel convolutional blocks are connected to the input of the gated recurrent unit, and the output of the gated recurrent unit outputs the shared feature vector.
6. The ultrasonic water meter flow prediction method based on a hybrid neural network according to claim 1, characterized in that, The fluid state recognition network includes a first fully connected layer, a second fully connected layer, and an output layer connected in sequence. The first fully connected module is composed of a first fully connected layer, a first ReLU activation layer, and a first Dropout layer connected in sequence. The second fully connected module is composed of a second fully connected layer, a second ReLU activation layer, and a second Dropout layer connected in sequence; The output module is composed of an output fully connected layer and a Softmax activation layer connected in sequence. The input of the first fully connected module receives the shared feature vector, and the output of the Softmax activation layer outputs the probability distribution vector.
7. The ultrasonic water meter flow prediction method based on a hybrid neural network according to claim 6, characterized in that, The activation function of the Softmax activation layer is as follows: ; Where Softmax represents the activation function. x This represents the original output vector of the fluid state recognition network output layer. x i Indicates the first element in the output vector. i The output value of each node, x j Indicates the first element in the output vector. j The output value of each node, exp This represents the natural exponential function. This indicates the number of activations calculated using the Softmax activation function. i Predicted probability of fluid-like states.
8. The ultrasonic water meter flow prediction method based on a hybrid neural network according to claim 1, characterized in that, Following S6, the following is also included: S7: Based on the dataset, by dividing the training set, validation set, and test set according to a preset ratio, a joint loss function is constructed and an iterative optimization algorithm is used to complete the training of the shared temporal encoder, the fluid state recognition network, and the probabilistic flow prediction network. Specifically, the joint loss function is: ; in, L Denotes the joint loss function. α This represents the coefficient used to weigh the loss term in balancing fluid state identification. β This represents the coefficient used to balance the weights of the loss term in traffic forecasting. L state This represents the loss term corresponding to the fluid state recognition network. L flow This represents the loss term for a probabilistic traffic prediction network.
9. An ultrasonic water meter flow prediction system based on a hybrid neural network, characterized in that, include: Processor and memory; The memory stores programs or instructions that can run on the processor, which, when executed by the processor, implement the steps of the ultrasonic water meter flow prediction method based on a hybrid neural network as described in any one of claims 1 to 8.
10. An ultrasonic water meter flow prediction system based on a hybrid neural network, characterized in that, include: Processor and memory; The memory stores programs or instructions that can run on the processor, which, when executed by the processor, implement the steps of the ultrasonic water meter flow prediction method based on a hybrid neural network as described in any one of claims 1 to 8.