Distributed optical fiber sensing water pipe leakage identification optimization method based on machine learning

Through the improved TimeSformer network and trust domain strategy optimization algorithm, the feature extraction of optical fiber scattered signals is optimized, which solves the problems of false alarms and high computational complexity of traditional detection methods, and realizes high-precision and low-false alarm water pipe leakage detection.

CN120162675AInactive Publication Date: 2025-06-17YANGZHOU YUNCHEN INTELLIGENT TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510313430.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-17
Publication Date
2025-06-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional water pipe leakage detection methods are prone to false alarms in complex pipeline environments, and existing deep learning-based methods have high computational complexity and insufficient feature extraction when processing fiber scattered signals, resulting in limited detection accuracy.

Method used

The improved TimeSformer network is adopted, combining the sparse attention mechanism and convolution module to optimize the timing feature extraction of fiber scattered signals, and optimize model parameters through trust domain strategy optimization algorithm to improve detection accuracy and model stability.

Benefits of technology

It improves the recognition accuracy of water pipe leakage signals, reduces the calculation complexity, enhances the robustness and adaptability of the model, and realizes high-precision and low false alarm leakage detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120162675A_ABST
    Figure CN120162675A_ABST
Patent Text Reader

Abstract

The invention discloses a distributed optical fiber sensing water pipe leakage identification optimization method based on machine learning. The method comprises the following steps: S1, collecting optical fiber scattering signals in a water pipe operation process; s2, performing data preprocessing on the acquired optical fiber scattering signals; s3, using an improved TimeSform network to extract time sequence features of the optical fiber scattering signals, and performing classification based on adversarial enhancement Softmax; s4, the improved TimeSform network is optimized based on a trust region strategy optimization algorithm, and parameters of the improved TimeSform network are adjusted; s5, the optimized TimeSform network is applied to real-time leakage detection, and feature extraction and classification are carried out on newly collected optical fiber scattering signals; and S6, on the basis of historical detection data, adaptive optimization is carried out on the TimeSform network by adopting incremental learning. According to the method, the improved TimeSform network and the trust region strategy optimization algorithm are adopted, accurate detection of water pipe leakage is achieved, and the method has the advantages of being high in precision, low in misinformation and stable in optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of target detection and recognition, and particularly to an optimized method for identifying water pipe leaks based on machine learning in distributed optical fiber sensing. Background Art

[0002] Water pipe leaks are common problems in water supply pipe networks and industrial transportation systems. Leaks can lead to a large amount of water resource waste, abnormal pipeline pressure, and even secondary disasters such as foundation collapse. Traditional leak detection methods mainly rely on means such as pressure monitoring, acoustic detection, flow analysis, and pipe network balance analysis. Among them, the pressure monitoring method relies on the layout of pressure sensors to judge the leak situation by detecting abnormal water pressure. However, in a complex pipe network environment, pressure fluctuations may be caused by various factors, which are prone to false alarms. The acoustic detection method judges by picking up the acoustic wave signals generated by the leak point, but it is greatly affected by pipeline materials, noise interference, and leak scale, and the detection effect is easily interfered by environmental factors. The flow analysis method judges leaks based on the data changes of network flow meters, but its detection accuracy is low, and it is difficult to accurately identify small leaks.

[0003] In recent years, distributed optical fiber sensing technology has been gradually applied to the field of pipeline leak detection. Distributed optical fiber sensors can be laid along the pipeline to monitor the physical changes inside and around the pipeline in real time, with the advantages of high sensitivity, long-distance monitoring, and anti-electromagnetic interference. Optical fiber scattering signals, such as Brillouin scattering, Rayleigh scattering, and Raman scattering, can provide continuous monitoring information on the pipeline state, thus realizing the early detection of pipeline leaks. However, due to the complex pipeline environment, optical fiber signals are easily interfered by temperature changes, mechanical vibrations, and external noises, resulting in a large amount of noise and non-leakage features in the signals, making it difficult for traditional signal processing methods to accurately identify leakage signals.

[0004] Currently, machine learning technology has been applied to pipeline leak detection. Common methods include support vector machines, random forests, and convolutional neural networks, etc. Support vector machines are suitable for small sample classification tasks, but in the face of complex time series signals, their feature extraction ability is limited, and it is difficult to effectively model the time series correlation of optical fiber signals. The random forest method has certain advantages in dealing with high-dimensional data, but its decision tree model is difficult to fully learn the time-dependent features of leakage signals and cannot accurately distinguish leakage signals from noise signals. Although convolutional neural networks can effectively extract spatial features, their ability to model the long-term dependence relationship of time series signals is weak, resulting in limited detection accuracy.

[0005] With the development of deep learning, time-series signal processing methods based on Transformer have gradually attracted attention. Transformer learns the long-range dependence characteristics of sequence data through the self-attention mechanism and performs excellently in fields such as speech recognition, financial prediction, and medical signal processing. However, the standard Transformer has a high computational complexity when dealing with long time-series data and is not optimized for spatio-temporal features, so its adaptability in the fiber optic sensing leakage detection task still needs to be improved. TimeSformer, as an improved form of Transformer in time-series signal analysis, adopts a decomposed spatio-temporal attention mechanism, which can effectively extract the spatio-temporal features of time-series data and improve the model's ability to identify leakage signals. However, the original TimeSformer model still has problems of high computational complexity and insufficiently fine feature extraction when dealing with fiber optic scattering signals, resulting in limited detection accuracy. In addition, existing deep learning-based leakage detection methods usually adopt static training models and cannot adapt to the long-term changes in the pipeline environment, resulting in poor generalization ability of the model in practical applications. Summary of the Invention

[0006] An object of the present invention is to propose an optimized method for identifying water pipe leakage in distributed fiber optic sensing based on machine learning. The present invention optimizes the time-series feature extraction ability of fiber optic scattering signals and improves the recognition accuracy of the model for leakage signals through an improved TimeSformer network combined with a sparse attention mechanism and a convolutional module. The Trust Region Policy Optimization algorithm is used to optimize the TimeSformer network, so that the model parameter update is constrained by the KL divergence, improving the stability of the optimization.

[0007] An optimized method for identifying water pipe leakage in distributed fiber optic sensing based on machine learning according to an embodiment of the present invention includes the following steps:

[0008] S1. Deploy distributed fiber optic sensors along the water pipe to collect fiber optic scattering signals during the operation of the water pipe;

[0009] S2. Perform data preprocessing on the collected fiber optic scattering signals to form original data;

[0010] S3. Use the original data to train the improved TimeSformer network, extract the time-series features of the fiber optic scattering signals, and perform classification based on adversarial enhanced Softmax to calculate the leakage detection probability;

[0011] S4. Optimize the improved TimeSformer network based on the Trust Region Policy Optimization algorithm, construct a state space, an action space, and a reward function, update the step size through the constraint policy of the Trust Region Policy Optimization algorithm, adjust the parameters of the improved TimeSformer network, and optimize the TimeSformer network;

[0012] S5. Apply the optimized TimeSformer network to real-time leakage detection, extract features and classify the newly acquired optical fiber scattering signals, determine whether there is a water pipe leakage, and output the leakage detection result;

[0013] S6. Perform adaptive optimization on the TimeSformer network based on historical detection data using incremental learning.

[0014] Optionally, the optical fiber scattering signals include Brillouin scattering signals, Rayleigh scattering signals, and Raman scattering signals, and the preprocessing includes band-pass filtering, wavelet transform, and time-frequency analysis.

[0015] Optionally, the specific steps of S3 are as follows:

[0016] S31. Construct an improved TimeSformer network. The TimeSformer network includes an input layer, a linear projection layer, a temporal attention layer, a spatial attention layer, a residual connection layer, a normalization layer, a convolutional module, a fully connected layer, and a Softmax classification layer. The improved TimeSformer network uses a sparse attention mechanism and adds a convolutional module. The convolutional module adds a one-dimensional convolutional layer at the input end of the TimeSformer network for short-term feature extraction;

[0017] S32. Standardize the original data, divide the standardized data into time windows, and set the window size and step size;

[0018] S33. Perform linear projection on the original data of each time window, map it to a fixed dimension, and calculate the linear projection result:

[0019] X' patch =ReLU(W p X patch +b p );

[0020] Where X′ patch represents the data after linear projection, ReLU represents the rectified linear unit activation function, W p represents the linear projection weight matrix, b p represents the linear projection bias term, and X patch represents the original data after windowing;

[0021] S34. In the temporal attention layer, based on the data after linear projection, use a method combining local window and global skip attention to calculate the temporal attention weights:

[0022]

[0023] Where, WTi represents the temporal attention weight, λ represents the adaptive weight coefficient, Softmax represents normalization, d k represents the dimension of the key matrix of temporal attention, Q represents the query matrix of temporal attention, K represents the key matrix of temporal attention, ⊙ represents matrix dot product operation, T represents matrix transpose, M represents the local window mask matrix, 1 - M represents the subtraction operation of the identity matrix and the local window mask matrix;

[0024] S35. Calculate the temporal attention output, introduce the residual connection, and calculate the residual temporal feature:

[0025] F resT = X' patch + e -λ (W Ti ·tanh(V));

[0026] Among them, F resT represents the residual temporal feature, X′ patch represents the data after linear projection, e represents the natural constant, λ represents the adaptive weight coefficient, tanh represents the hyperbolic tangent activation function, V represents the value matrix of temporal attention, W Ti ·tanh(V) represents the temporal attention output;

[0027] S36. Based on the data after linear projection, adopt the adaptive sparse attention mechanism, calculate the spatial attention weight, and calculate the spatial attention output, introduce the residual connection, and calculate the spatio - temporal feature:

[0028]

[0029] Among them, F resS represents the spatio - temporal feature, F resT represents the residual temporal feature, γ represents the adaptive weight parameter, Q S represents the query matrix of spatial attention, K S represents the key matrix of spatial attention, V S represents the value matrix of spatial attention, d s represents the dimension of the key matrix of spatial attention;

[0030] S37. Add a convolutional module to the input end of the improved TimeSformer network, and calculate the short - term feature using one - dimensional convolution based on the data after linear projection:

[0031] F cnn = tanh(W c X′ patch + b c );

[0032] Among them, F cnndenotes the short - term features output by the convolutional module, tanh denotes the hyperbolic tangent activation function, and W c denotes the convolutional kernel of the convolutional module, and X′ patch denotes the data after linear projection;

[0033] S38. Fuse the spatio - temporal features extracted by the improved TimeSformer network and the short - term features output by the convolutional module, and calculate the fused features:

[0034] F merge = e -β ·(α·tanh(F cnn )+(1 - α)·F resS );

[0035] Among them, F merge denotes the fused features, β denotes the fusion adjustment factor, α denotes the fusion weight parameter, Δt denotes the time step, F cnn denotes the short - term features output by the convolutional module, and F resS denotes the spatio - temporal features extracted by the improved TimeSformer network;

[0036] S39. Input the fused features into the fully - connected layer, calculate the fully - connected output, and perform classification based on adversarial - enhanced Softmax to calculate the leakage detection probability. The adversarial - enhanced Softmax represents an improved Softmax classification method, which introduces an adversarial perturbation term during calculation to enhance the stability and robustness of the model in the face of uncertain inputs or noisy environments:

[0037]

[0038] Among them, P(y = k|X) represents the predicted probability of class k, X represents the input data, exp represents the natural exponential function, Z k represents the score of class k, which is the output of the fully - connected layer, Z j represents the score of class j, C represents the number of classification categories, ∈ represents the adversarial perturbation coefficient, 10 -6 represents the smoothing factor to prevent the denominator from being zero, represents the loss function for the gradient of Z k with respect to the score of class k, represents the cross - entropy loss function.

[0039] Optionally, the specific content of S4 includes:

[0040] S41. The TimeSformer network optimized and improved based on the trust region policy optimization algorithm, constructing the state space, action space, and reward function of the trust region policy optimization algorithm. The state space consists of the parameter states of the TimeSformer network. The action space includes the adjustment operations on the parameters of the TimeSformer network. The reward function is calculated from the classification accuracy, loss value, and convergence speed of the TimeSformer network.

[0041] S42. Define the state space S, and set the parameters of the improved TimeSformer network as θ = {W T , θ c , W c}, where W T represents the attention weight, θ c represents the classification threshold, and W c represents the parameters of the convolutional module:

[0042]

[0043] Among them, S t represents the parameter state of the TimeSformer network at time t, represents the attention weight at time t, represents the classification threshold at time t, represents the parameters of the convolutional module at time t;

[0044] S43. Define the action space A, and set the parameter adjustment operations of the TimeSformer network:

[0045]

[0046] Among them, A t represents the action at time t, represents the adjustment amount of the attention weight, represents the adjustment amount of the classification threshold, represents the adjustment amount of the parameters of the convolutional module;

[0047] S44. Calculate the classification loss and accuracy of the TimeSformer network, and define the reward function R t :

[0048]

[0049] Among them, R t represents the reward function, Acc(θ) represents the classification accuracy, represents the loss adjustment coefficient, θ represents the parameters of the improved TimeSformer network, P(y = k|X) represents the predicted probability of class k, X represents the input data, C represents the number of classification categories, and yk Denote the true label of class k, represent the classification loss of the TimeSformer network;

[0050] S45. Calculate the gradient of the policy optimization objective function Optimize the parameters of the TimeSformer network based on the policy gradient method, and update the parameters of the TimeSformer network by maximizing the policy optimization objective function:

[0051]

[0052] where J(θ) represents the policy optimization objective function, represent the gradient of the policy optimization objective function, E represents the mathematical expectation, π θ (A t |S t ) represents the policy function, A t represents the action at time t, S t represents the parameter state of the TimeSformer network at time t, R t represents the reward function, θ′ represents the updated parameters of the TimeSformer network, and μ represents the policy step size;

[0053] S46. Calculate the policy update step size based on the trust region policy optimization algorithm, set the policy function π θ and the optimized policy function π θ′ , and calculate the KL divergence of the policy update:

[0054]

[0055] where D KL (π θ ||π θ′ ) represents the KL divergence, P θ′ (y = k|X) represents the predicted probability of class k after update, π θ represents the policy function, and π θ′ represents the optimized policy function;

[0056] If D KL exceeds the set threshold, then reduce the step size μ and recalculate the parameter update;

[0057] S47. Repeat steps S45 and S46 until the policy converges, and finally output the optimized TimeSformer network.

[0058] The beneficial effects of the present invention are:

[0059] First, the present invention optimizes the temporal feature extraction of fiber optic scattering signals through an improved TimeSformer network, enabling the model to fully capture the spatio-temporal features of water pipe leakage signals and improving the detection accuracy. Compared with traditional leakage detection methods based on pressure, acoustics, or flow analysis, the present invention relies on distributed fiber optic sensing technology to provide more accurate and real-time pipeline status monitoring, avoiding false alarm problems caused by environmental noise or pipeline network pressure fluctuations. At the same time, the TimeSformer network based on the adaptive sparse attention mechanism effectively reduces the computational complexity, enabling the model to operate efficiently on large-scale temporal data and improving the detection efficiency.

[0060] Secondly, the trust region policy optimization algorithm is used to optimize the TimeSformer network, enabling the model to optimize its classification ability based on policy gradients during the training process and ensuring the stability of parameter updates through KL divergence constraints. Compared with traditional gradient descent optimization methods, this optimization strategy can prevent instability caused by excessive parameter update amplitudes and ensure that the TimeSformer network can maintain high accuracy in complex environments. In addition, by adaptively optimizing the attention weights, classification thresholds, and convolutional module parameters of the TimeSformer network, the present invention further enhances the robustness of the model, enabling it to maintain high detection performance under different water pipe materials, flow conditions, and leakage scales.

[0061] Finally, in order to enable the system to have long-term adaptability, the present invention adopts an incremental learning method, enabling the TimeSformer network to be continuously optimized based on historical detection data. Traditional deep learning models usually rely on static training data and are prone to problems of decreased generalization ability when the pipeline environment changes. However, the present invention continuously adjusts the network parameters through incremental learning, enabling the model to adapt to changes in the water pipe operation environment and improving the long-term detection stability. This method not only reduces the computational cost of retraining the entire model but also avoids the problem of catastrophic forgetting, enabling the leakage detection system to maintain high detection accuracy during long-term operation.

[0062] Generally speaking, the present invention breaks through the technical bottlenecks of traditional leakage detection methods, such as sensitivity to environmental noise, insufficient model generalization ability, and high computational overhead, and proposes an intelligent leakage detection method combining distributed fiber optic sensing, deep learning optimization, and reinforcement learning. This method can achieve high-precision and low-false-alarm leakage detection in complex water pipe operation environments and ensure the long-term adaptability of the model through incremental learning. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] The drawings are used to provide a further understanding of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the present invention and do not constitute a limitation to the present invention. In the drawings:

[0064] Figure 1 Flow chart of an optimized method for identifying water pipe leakage by distributed optical fiber sensing based on machine learning proposed by the present invention;

[0065] Figure 2 Flow chart of optimizing the TimeSformer network by the trust region strategy optimization algorithm for an optimized method for identifying water pipe leakage by distributed optical fiber sensing based on machine learning proposed by the present invention. Specific implementation manners

[0066] Now, the present invention will be further described in detail with reference to the accompanying drawings. These drawings are all simplified schematic diagrams, only illustrating the basic structure of the present invention in a schematic manner, so they only show the components related to the present invention.

[0067] Refer to Figure 1 and Figure 2 , an optimized method for identifying water pipe leakage by distributed optical fiber sensing based on machine learning, comprising the following steps:

[0068] S1. Arrange distributed optical fiber sensors along the water pipe to collect the optical fiber scattering signals during the operation of the water pipe;

[0069] S2. Perform data preprocessing on the collected optical fiber scattering signals to form raw data;

[0070] S3. Use the raw data to train the improved TimeSformer network, extract the temporal features of the optical fiber scattering signals, and perform classification based on adversarial enhanced Softmax to calculate the leakage detection probability;

[0071] S4. Optimize the improved TimeSformer network based on the trust region strategy optimization algorithm, construct the state space, action space, and reward function, update the step size of the constraint strategy through the trust region strategy optimization algorithm, adjust the parameters of the improved TimeSformer network, and optimize the TimeSformer network;

[0072] S5. Apply the optimized TimeSformer network to real-time leakage detection, extract features and classify the newly collected optical fiber scattering signals, determine whether there is water pipe leakage, and output the leakage detection result;

[0073] S6. Perform adaptive optimization on the TimeSformer network by incremental learning based on historical detection data.

[0074] In this embodiment, the optical fiber scattering signals include Brillouin scattering signals, Rayleigh scattering signals, and Raman scattering signals, and the preprocessing includes band-pass filtering, wavelet transform, and time-frequency analysis.

[0075] In this embodiment, S3 specifically includes:

[0076] S31. Construct an improved TimeSformer network. The TimeSformer network includes an input layer, a linear projection layer, a temporal attention layer, a spatial attention layer, a residual connection layer, a normalization layer, a convolutional module, a fully connected layer, and a Softmax classification layer. The improved TimeSformer network uses a sparse attention mechanism and adds a convolutional module. The convolutional module adds a one-dimensional convolutional layer at the input end of the TimeSformer network for short-term feature extraction;

[0077] S32. Standardize the original data, divide the standardized data into time windows, and set the window size and stride;

[0078] S33. Perform a linear projection on the original data of each time window, map it to a fixed dimension, and calculate the linear projection result:

[0079] X' patch = ReLU(W p X patch + b p );

[0080] Where X′ patch represents the data after linear projection, ReLU represents the rectified linear unit activation function, W p represents the linear projection weight matrix, b p represents the linear projection bias term, and X patch represents the original data after windowing;

[0081] S34. In the temporal attention layer, based on the data after linear projection, use a method combining local window and global skip attention to calculate the temporal attention weights:

[0082]

[0083] Where W Ti represents the temporal attention weights, λ represents the adaptive weight coefficient, Softmax represents normalization, d k represents the dimension of the key matrix of the temporal attention, Q represents the query matrix of the temporal attention, K represents the key matrix of the temporal attention, ⊙ represents the matrix dot product operation, T represents the matrix transpose, M represents the local window mask matrix, and 1 - M represents the subtraction operation between the identity matrix and the local window mask matrix;

[0084] S35. Calculate the temporal attention output, introduce a residual connection, and calculate the residual temporal features:

[0085] F resT = X'patch +e -λ (W Ti ·tanh(V));

[0086] Among them, F resT represents the residual time feature, X' patch represents the data after linear projection, e represents the natural constant, λ represents the adaptive weight coefficient, tanh represents the hyperbolic tangent activation function, V represents the value matrix of time attention, and W Ti ·tanh(V) represents the time attention output;

[0087] S36. Based on the data after linear projection, adopt the adaptive sparse attention mechanism, calculate the spatial attention weight, calculate the spatial attention output, introduce the residual connection, and calculate the spatio-temporal feature:

[0088]

[0089] Among them, F resS represents the spatio-temporal feature, F resT represents the residual time feature, γ represents the adaptive weight parameter, Q S represents the query matrix of spatial attention, K S represents the key matrix of spatial attention, V S represents the value matrix of spatial attention, and d s represents the dimension of the key matrix of spatial attention;

[0090] S37. Add a convolution module to the input end of the improved TimeSformer network, and calculate the short-term feature based on the data after linear projection using one-dimensional convolution:

[0091] F cnn =tanh(W c X' patch +b c );

[0092] Among them, F cnn represents the short-term feature output by the convolution module, tanh represents the hyperbolic tangent activation function, W c represents the convolution kernel of the convolution module, and X' patch represents the data after linear projection;

[0093] S38. Fuse the spatio-temporal feature extracted by the improved TimeSformer network and the short-term feature output by the convolution module, and calculate the fusion feature:

[0094] F merge =e -β ·(α·tanh(F cnn )+(1-α)·F resS );

[0095] Among them, F merge represents the fused feature, β represents the fusion adjustment factor, α represents the fusion weight parameter, Δt represents the time step, and F cnn represents the short-term feature output by the convolutional module, and F resS represents the spatio-temporal feature extracted by the improved TimeSformer network;

[0096] S39. Input the fused feature into the fully connected layer, calculate the fully connected output, and perform classification based on adversarial enhanced Softmax, and calculate the leakage detection probability. The adversarial enhanced Softmax represents an improved Softmax classification method, and an adversarial perturbation term is introduced during calculation to enhance the stability and robustness of the model in the face of uncertain inputs or noisy environments:

[0097]

[0098] Among them, P(y = k|X) represents the predicted probability of class k, X represents the input data, exp represents the natural exponential function, and Z k represents the score of class k, which is the output of the fully connected layer, and Z j represents the score of class j, C represents the number of classification categories, ∈ represents the adversarial perturbation coefficient, and 10 -6 represents the smoothing factor to prevent the denominator from being zero, represents the loss function the gradient of Z with respect to the score of class k k represents the cross-entropy loss function.

[0099] In this embodiment, the S4 specifically includes:

[0100] S41. Optimize the improved TimeSformer network based on the trust region policy optimization algorithm, construct the state space, action space, and reward function of the trust region policy optimization algorithm. The state space consists of the parameter states of the TimeSformer network, the action space includes the adjustment operations on the parameters of the TimeSformer network, and the reward function is calculated from the classification accuracy, loss value, and convergence speed of the TimeSformer network;

[0101] S42. Define the state space S, and set the parameters of the improved TimeSformer network as θ = {W T , θ c , W c}, where W T represents the attention weight, θ c represents the classification threshold, and W c represents the convolutional module parameters: ​

[0102]

[0103] Among them, S t represents the state of the TimeSformer network parameters at time t, represents the attention weight at time t, represents the classification threshold at time t, represents the parameters of the convolutional module at time t;

[0104] S43. Define the action space A and set the operation for adjusting the TimeSformer network parameters:

[0105]

[0106] Among them, A t represents the action at time t, represents the adjustment amount of the attention weight, represents the adjustment amount of the classification threshold, represents the adjustment amount of the parameters of the convolutional module;

[0107] S44. Calculate the classification loss and accuracy of the TimeSformer network, and define the reward function R t :

[0108]

[0109] Among them, R t represents the reward function, Acc(θ) represents the classification accuracy, represents the loss adjustment coefficient, θ represents the parameters of the improved TimeSformer network, P(y = k|X) represents the predicted probability of class k, X represents the input data, C represents the number of classification categories, y k represents the true label of class k, represents the classification loss of the TimeSformer network;

[0110] S45. Calculate the gradient of the policy optimization objective function Optimize the TimeSformer network parameters based on the policy gradient method, and update the TimeSformer network parameters by maximizing the policy optimization objective function:

[0111]

[0112] Among them, J(θ) represents the policy optimization objective function, represents the gradient of the policy optimization objective function, E represents the mathematical expectation, π θ (A t |S t ) represents the policy function, At The action at time t, S t The state of the TimeSformer network parameters at time t, R t Denote the reward function, θ′ denote the updated TimeSformer network parameters, and μ denote the policy step size;

[0113] S46. Calculate the policy update step size based on the trust region policy optimization algorithm, and set the policy function π θ And the optimized policy function π θ′ , calculate the KL divergence of the policy update:

[0114]

[0115] where D KL (π θ ||π θ′ ) represents the KL divergence, P θ′ (y = k|X) represents the predicted probability of the updated class k, π θ denotes the policy function, and π θ′ denotes the optimized policy function;

[0116] If D KL exceeds the set threshold, then reduce the step size μ and recalculate the parameter update;

[0117] S47. Repeat steps S45 and S46 until the policy converges, and finally output the optimized TimeSformer network.

[0118] Example 1:

[0119] To verify the feasibility of the present invention in implementation, the present invention is applied to a leakage detection system of a large urban water supply network. The water supply network has a wide coverage area, with a total pipeline length exceeding 3200 kilometers. Some of the pipelines have a long service life and are at risk of aging. Moreover, the pipeline materials are complex, including ductile iron pipes, stainless steel pipes, PVC pipes, etc. Traditional leakage detection methods mainly rely on pressure sensors and acoustic detection equipment. However, due to factors such as pipeline burial depth and ambient noise interference, the detection accuracy is greatly affected. Especially in the case of low flow and small leakage, the false alarm rate is relatively high, resulting in an increase in a large amount of manual inspection costs.

[0120] In this experiment, distributed fiber optic sensors are arranged along the water supply pipeline, and the fiber optic scattering signal is used for leakage detection. The method of the present invention mainly adopts an improved TimeSformer network, combined with a trust region strategy optimization algorithm, to improve the signal feature extraction ability and reduce environmental noise interference. In the data acquisition stage, the arranged fiber optic sensors continuously collect fiber optic scattering signals, including Brillouin scattering, Rayleigh scattering, and Raman scattering signals. During the data preprocessing process, band-pass filtering is used to remove high-frequency interference, wavelet transform is used to extract key leakage features, and time-frequency analysis is performed to form a feature dataset. Subsequently, the improved TimeSformer network is used to train the feature dataset, enhancing the spatio-temporal feature extraction ability through an adaptive sparse attention mechanism and combining with a one-dimensional convolutional layer to improve the short-time feature capture ability.

[0121] In the model optimization stage, the trust region strategy optimization algorithm is adopted to optimize the attention weights, classification thresholds, and convolutional layer parameters of the TimeSformer network, construct the state space, action space, and reward function, and optimize the parameters based on the policy gradient method. To ensure the stability of the optimization process, KL divergence constraints are introduced to control the policy update amplitude, enabling the model to maintain a high accuracy rate in complex environments.

[0122] The experimental data collection time is one year, covering four different seasons, to verify the adaptability of the present invention to environmental temperature changes. Twenty key monitoring areas in the urban water supply network are selected for the experiment, and each area contains different pipeline materials and water flow conditions. Based on the actual working condition data, the detection effects of the method of the present invention are compared with those of traditional acoustic detection, random forest, and convolutional neural network methods.

[0123] Table 1 Experimental comparison data table

[0124]

[0125] The experimental results show that the method of the present invention has significant advantages in the water pipe leakage detection task. First, in terms of the accuracy rate of leakage identification, the average accuracy rate of the method of the present invention reaches 97.8%, far higher than that of the CNN method (91.5%), the random forest method (85.3%), and the traditional acoustic detection method (80.2%). Especially in the low-flow leakage detection task, the detection accuracy rate of the method of the present invention is 94.6%, showing a large improvement compared with the CNN method (85.2%) and the random forest method (79.4%), while the detection accuracy rate of the traditional acoustic method is only 68.4%, indicating that the traditional wave-based detection method has obvious limitations under low-flow conditions.

[0126] In terms of the false alarm rate, the false alarm rate of the method of the present invention is only 2.3%, far lower than that of the CNN method (6.5%), the random forest method (8.7%) and the acoustic detection method (12.1%). The reduction of the false alarm rate means that the method of the present invention can effectively distinguish the leakage signal from the environmental noise, reduce the manual inspection and maintenance costs caused by false alarms. At the same time, the calculation efficiency of the method of the present invention is also significantly better than other methods. Its average calculation time is only 0.73 seconds, while the CNN method requires 1.25 seconds, the random forest method is 2.1 seconds, and the traditional acoustic detection method reaches 2.8 seconds, indicating that the method of the present invention can achieve faster real-time detection ability, which is beneficial to the online monitoring and early warning of large-scale pipe networks.

[0127] In addition, in terms of reducing the workload of manual inspection, the method of the present invention can reduce the manual inspection demand by 42%. Compared with the CNN method (28%), the random forest method (18%) and the acoustic detection method (12%), it has a more significant effect of reducing costs and increasing efficiency. This shows that the method of the present invention not only improves the accuracy and efficiency of detection, but also effectively reduces the burden of manual inspection, and is suitable for the long-term monitoring of large-scale water supply pipe networks and industrial pipelines. Generally speaking, the method of the present invention has obvious advantages in terms of accuracy, real-time performance, low false alarm and reduction of manual intervention, providing an efficient and intelligent solution for water pipe leakage detection.

[0128] The above is only the preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution and inventive concept of the present invention, makes equivalent substitutions or changes, and should be covered by the protection scope of the present invention.

Claims

1. A distributed optical fiber sensing water pipe leakage identification optimization method based on machine learning, characterized in that: The steps include: S1. Distributed optical fiber sensors are deployed along the water pipe to collect optical fiber scattered signals during the operation of the water pipe; S2, performing data preprocessing on the collected optical fiber scattering signal to form raw data; S3, using the original data to train the improved TimeSformer network, extract the time series characteristics of the fiber scattering signal, and classify it based on the adversarial enhanced Softmax to calculate the leakage detection probability; S4. Based on the trust region policy optimization algorithm, the improved TimeSformer network is optimized, the state space, action space and reward function are constructed, the step size is updated through the constraint strategy of the trust region policy optimization algorithm, the parameters of the improved TimeSformer network are adjusted, and the TimeSformer network is optimized; S5. Apply the optimized TimeSformer network to real-time leak detection, extract and classify the newly collected optical fiber scattering signals, determine whether there is a water pipe leak, and output the leak detection results; S6. Based on historical detection data, the TimeSformer network is adaptively optimized using incremental learning.

2. According to the method of optimizing the identification of water pipe leakage based on distributed optical fiber sensing and machine learning in claim 1, it is characterized in that: The optical fiber scattering signal includes a Brillouin scattering signal, a Rayleigh scattering signal and a Raman scattering signal, and the preprocessing includes bandpass filtering, wavelet transform and time-frequency analysis.

3. According to the method of optimizing the identification of water pipe leakage based on distributed optical fiber sensing and machine learning in claim 1, it is characterized in that: The S3 specifically includes: S31. Construct an improved TimeSformer network, wherein the TimeSformer network includes an input layer, a linear projection layer, a temporal attention layer, a spatial attention layer, a residual connection layer, a normalization layer, a convolution module, a fully connected layer, and a Softmax classification layer. The improved TimeSformer network uses a sparse attention mechanism and adds a convolution module. The convolution module adds a one-dimensional convolution layer at the input end of the TimeSformer network to perform short-term feature extraction. S32, standardize the original data, divide the standardized data into time windows, and set the window size and step size; S33. Linearly project the original data of each time window, map it to a fixed dimension, and calculate the linear projection result: X' patch =ReLU(W p X patch +b p ): Among them, X′ patch represents the data after linear projection, ReLU represents the rectified linear unit activation function, W p represents the linear projection weight matrix, b p represents the linear projection bias term, X patch Represents the original data after windowing; S34. In the temporal attention layer, based on the linearly projected data, a method combining local window and global jump attention is used to calculate the temporal attention weight: Among them, W Ti represents the temporal attention weight, λ represents the adaptive weight coefficient, Softmax represents normalization, and d k represents the dimension of the key matrix of temporal attention, Q represents the query matrix of temporal attention, K represents the key matrix of temporal attention, ⊙ represents the matrix dot product operation, T represents the matrix transpose, M represents the local window mask matrix, and 1-M represents the subtraction operation of the identity matrix and the local window mask matrix; S35. Calculate the temporal attention output, introduce residual connection, and calculate the residual temporal features: F resT =X' patch +e -λ (W Ti ·tanh(V); Among them, F resT represents the residual time feature, X′ patch represents the data after linear projection, e represents the natural constant, λ represents the adaptive weight coefficient, tanh represents the hyperbolic tangent activation function, V represents the value matrix of time attention, W Ti tanh(V) represents the temporal attention output; S36. Based on the data after linear projection, an adaptive sparse attention mechanism is used to calculate the spatial attention weight and the spatial attention output, and residual connections are introduced to calculate the spatiotemporal features: Among them, F resS represents the spatiotemporal characteristics, F resT represents the residual time feature, γ represents the adaptive weight parameter, Q S The query matrix K represents the spatial attention. S The key matrix representing spatial attention, V S The value matrix representing spatial attention, d s The dimension of the key matrix representing spatial attention; S37. Add a convolution module to the input of the improved TimeSformer network, and use one-dimensional convolution to calculate short-term features based on the linearly projected data: F cnn =tanh(W c X′ patch +b c ); Among them, F cnn represents the short-term features output by the convolution module, tanh represents the hyperbolic tangent activation function, and W c represents the convolution kernel of the convolution module, X′ patch Represents the data after linear projection; S38. Fuse the spatiotemporal features extracted by the improved TimeSformer network and the short-term features output by the convolution module to calculate the fused features: F merge =e -β ·(α·tanh(F cnn )+(1-α)·F resS ); Among them, F merge represents the fused feature, β represents the fusion adjustment factor, α represents the fusion weight parameter, Δt represents the time step, F cnn represents the short-term features output by the convolution module, F resS Represents the spatiotemporal features extracted by the improved TimeSformer network; S39. Input the fused features into the fully connected layer, calculate the fully connected output, and perform classification based on the adversarial enhanced Softmax to calculate the leakage detection probability. The adversarial enhanced Softmax represents an improved Softmax classification method, which introduces adversarial perturbation terms during calculation to enhance the stability and robustness of the model under uncertain input or noisy environment: Among them, P(y=k|X) represents the predicted probability of category k, X represents the input data, exp represents the natural exponential function, and Z k represents the score of category k, which is the output of the fully connected layer, Z j represents the score of category j, C represents the number of classification categories, ∈ represents the adversarial perturbation coefficient, 10 -6 represents the smoothing factor to prevent the denominator from being zero, Represents the loss function The score Z for category k k gradient, represents the cross entropy loss function.

4. The method for optimizing water pipe leakage identification based on distributed optical fiber sensing and machine learning according to claim 1 is characterized in that: The S4 specifically includes: S41, based on the TimeSformer network optimized and improved by the trust region strategy optimization algorithm, construct the state space, action space and reward function of the trust region strategy optimization algorithm, wherein the state space is composed of the parameter state of the TimeSformer network, the action space includes the adjustment operation of the TimeSformer network parameters, and the reward function is calculated by the classification accuracy, loss value and convergence speed of the TimeSformer network; S42. Define the state space S and set the parameters of the improved TimeSformer network to θ = W T ,θ c ,W c }, where W T represents the attention weight, θ c represents the classification threshold, W c Represents the convolution module parameters: Among them, S t represents the TimeSformer network parameter status at time t, represents the attention weight at time t, represents the classification threshold at time t, Represents the convolution module parameters at time t; S43, define the action space A, set the TimeSformer network parameter adjustment operation: Among them, A t represents the action at time t, represents the adjustment amount of attention weight, represents the adjustment amount of the classification threshold, Indicates the adjustment amount of the convolution module parameters; S44. Calculate the classification loss and accuracy of the TimeSformer network and define the reward function R t : Among them, R t represents the reward function, Acc(θ) represents the classification accuracy, represents the loss adjustment coefficient, θ represents the improved TimeSformer network parameter, P(y=k|X) represents the predicted probability of category k, X represents the input data, C represents the number of classification categories, y k represents the true label of category k, Represents the classification loss of the TimeSformer network; S45. Calculate the gradient of the objective function of the strategy optimization The TimeSformer network parameters are optimized based on the policy gradient method, and the TimeSformer network parameters are updated by maximizing the policy optimization objective function: Among them, J(θ) represents the policy optimization objective function, represents the gradient of the policy optimization objective function, E represents the mathematical expectation, and π θ (A t |S t ) represents the policy function, A t represents the action at time t, S t represents the TimeSformer network parameter state at time t, R t represents the reward function, θ' represents the updated TimeSformer network parameters, and μ represents the strategy step size; S46, calculate the strategy update step size based on the trust region strategy optimization algorithm, and set the strategy function π θ And the optimized strategy function π θ′ , calculate the KL divergence of the policy update: Among them, D KL (π θ ||π θ′ ) represents KL divergence, P θ′ (y=k|X) represents the predicted probability of category k after update, π θ represents the policy function, π θ′ represents the optimized policy function; If D KL If it exceeds the set threshold, the step size μ is reduced and the parameter update is recalculated; S47. Repeat steps S45 and S46 until the strategy converges, and finally output the optimized TimeSformer network.

Citation Information

Cited By

  • Coal mine optical fiber laying depth fault prediction method based on space-time self-attention coupling

    CN120724125A

  • Hydrogen-doped natural gas pipeline leakage detection method and system based on multi-task Mamba-CNN

    CN120932683A