Detection method, device, equipment and storage medium
By using a network model combined with graph neural network and converter layer in the water system to analyze sensor data, the problem of untimely and accurate data collection in traditional water monitoring systems is solved, and more efficient abnormal detection and early warning is achieved.
Patent Information
- Application Number
- CN202411166300.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-08-23
AI Technical Summary
Traditional water monitoring systems rely on manpower inspection and simple sensor data collection, resulting in untimely data collection, low quality, inaccurate detection results, affecting the system operation efficiency.
A detection method is adopted to obtain sensor data at key locations of urban water system, pre-process and feature extraction, and use a network model combined with graph neural network and converter layer to perform data analysis, and output early warning signals to improve detection accuracy.
It improves the accuracy and efficiency of water system inspection, can detect abnormal situations in a timely manner, and enhances the ability to capture abnormal situations such as water quality pollution, pipeline leakage and abnormal flow velocity.
Smart Images

Figure CN118673450B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of water service detection technology, and in particular, relates to a detection method, device, equipment and storage medium. Background Art
[0002] Traditional water monitoring systems mainly rely on manual inspections and simple sensor data collection, which has problems such as untimely data collection, low data quality, and inaccurate monitoring results. These problems make it impossible to detect and handle abnormal situations in a timely manner, which in turn affects the overall operating efficiency of urban water systems. In traditional water monitoring systems, data collection mainly relies on a single type of sensor, and the data processing method is relatively simple. Rules or empirical models are usually used for data analysis and anomaly detection. However, these methods have low detection accuracy and low efficiency. Summary of the invention
[0003] In response to the above problems, the embodiments of the present application provide a detection method, device, equipment and storage medium, which can improve the accuracy of detection of water systems.
[0004] The present application embodiment provides a detection method, including:
[0005] Acquire first detection data of sensors at key locations in the urban water system;
[0006] Preprocessing the first detection data to obtain processed first detection data;
[0007] Extracting key feature information corresponding to each sensor from the processed first detection data;
[0008] Inputting the key feature information and the topological structure data of the sensor into a pre-established network model to determine the detection results of each key position;
[0009] When there are abnormalities in the detection results of key target locations, an early warning signal is output.
[0010] In some embodiments, the key feature information includes: feature data based on time series, the network model includes: a converter layer, a graph neural network layer, a fusion layer and a detection result output layer, the outputs of the converter layer and the graph neural network layer are input to the fusion layer, the output of the fusion layer is input to the detection result output layer, the input of the converter layer includes: feature data based on time series, the output of the converter layer includes encoded features, the input of the graph neural network layer includes: topological structure data of the sensor and feature data based on time series, the output of the graph neural network layer is updated feature data for each sensor, the fusion layer is used to fuse the encoded features and the updated feature data to obtain fused features, and the detection result output layer is used to output detection results based on the fused features.
[0011] In some embodiments, the graph neural network layer introduces an attention mechanism and multi-head attention. The attention mechanism introduced in the graph neural network layer is used to calculate the attention coefficient based on the topological structure data of the sensor and the feature data based on the time series. The multi-head attention mechanism introduced in the graph neural network layer is used to apply the attention coefficient to the message transmission process in the graph neural network layer to update the updated feature data of each sensor based on the attention coefficient.
[0012] In some embodiments, the characteristic data of the time series include: heavy metal content, microbial concentration, water volume, water flow rate, water temperature and water pressure. The first calculation formula for calculating the attention coefficient includes:
[0013] ;
[0014] in, ij For sensor and sensors The attention coefficient between is the training parameter vector in the attention mechanism, W is the feature transformation matrix, || represents the vector connection operation, d For sensor and sensors The distance between ( ) For sensor The neighbor node set, X is the characteristic matrix of the sensor, X includes the heavy metal content C HM , microbial concentration F MB , water volume Q, water flow velocity v, water temperature T and water pressure P, the adjacency matrix A represents the connection relationship between sensors;
[0015] The graph neural network layer updates the updated feature data of each sensor using a second calculation formula based on the attention coefficient, and the second calculation formula includes:
[0016] ; where σ is the activation function, For the The attention coefficient of the attention head, For the The feature transformation matrix of the attention heads, H is the number of multi-head attention heads.
[0017] In some embodiments, the converter layer introduces a dual self-supervised learning mechanism, which is used to add feature data based on time series to position coding, and perform dual self-supervised learning based on the feature data with position coding, wherein the dual self-supervised learning includes: a masked feature prediction task and a neighborhood feature prediction task, the masked feature prediction task is used to randomly mask the feature data with position coding and predict the masked feature value, the neighborhood feature prediction task is used to predict the feature representation of the sensor's neighbor nodes, and the loss function of the converter layer includes: the loss of the neighborhood feature prediction task and the loss of the masked feature prediction task.
[0018] In some embodiments, the method further comprises:
[0019] Acquire second detection data of the candidate monitoring point in the urban water system, wherein the second detection data includes: heavy metal content, water temperature and water flow;
[0020] The target monitoring point is determined from the candidate monitoring points using a third calculation formula based on the second detection data, so as to determine a key position based on the target monitoring point, wherein the third calculation formula includes:
[0021]
[0022] in, L optimal is the optimal monitoring point location, N is the number of alternative monitoring points, For the The water volume at each monitoring point, For the The heavy metal content at each monitoring point For the The distance between each monitoring point and the center of the urban water system, For the The water temperature at each monitoring point, α and β are empirical coefficients.
[0023] In some embodiments, the detection information includes: abnormality type, abnormality location and abnormality degree. When the detection result of the target key position is abnormal, an early warning signal is output, including:
[0024] In the event that the detection result of the target key position is abnormal, a processing suggestion is determined based on the abnormality type, abnormality location and abnormality degree;
[0025] The abnormality type, abnormality location and processing suggestion are sent to the management personnel corresponding to the target key location.
[0026] The present application provides a detection device, including:
[0027] An acquisition module, used to acquire first detection data of sensors at key locations in the urban water system;
[0028] A preprocessing module, used for preprocessing the first detection data to obtain processed first detection data;
[0029] An extraction module, used to extract key feature information corresponding to each sensor from the processed first detection data;
[0030] A determination module, used to input the key feature information and the topological structure data of the sensor into a pre-established network model to determine the detection results of each key position;
[0031] The output module is used to output a warning signal when there is an abnormality in the detection result of the key position of the target.
[0032] An embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described methods when executing the computer program.
[0033] An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned methods is implemented.
[0034] An embodiment of the present application provides a computer program product. When the computer program product is executed on a terminal device, the electronic device executes any one of the above methods.
[0035] A detection method provided in an embodiment of the present application obtains first detection data of sensors at key positions in an urban water system; preprocesses the first detection data to obtain processed first detection data; extracts key feature information corresponding to each sensor from the processed first detection data; inputs the key feature information and the topological structure data of the sensor into a pre-established network model to determine the detection results of each key position; and outputs a warning signal when there is an abnormality in the detection result of the target key position, thereby improving the accuracy of detection of the water system. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Hereinafter, the present application will be described in more detail according to embodiments and with reference to the accompanying drawings.
[0037] Figure 1 A schematic diagram of the structure of a detection system provided in an embodiment of the present application;
[0038] Figure 2 A schematic diagram of a detection method for implementing this application;
[0039] Figure 3 A schematic diagram of an implementation flow of a detection method provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of a processing flow of a network model provided in an embodiment of the present application;
[0041] Figure 5 A schematic diagram of the structure of a detection device provided in an embodiment of the present application;
[0042] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0043] In the drawings, the same reference numerals are used for the same components, and the drawings are not drawn to scale. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0045] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0046] If similar descriptions of "first\second\third" appear in the application documents, the following instructions are added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0047] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0048] In view of the problems in the related art, the embodiments of the present application provide a detection method that can be applied to electronic devices such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), etc. The embodiments of the present application do not impose any restrictions on the specific type of electronic devices. The electronic device can be a cloud server of the detection system. Figure 1 A schematic diagram of the structure of a detection system provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the detection system includes various types of sensors, each of which is connected to the cloud server for communication. The sensors are used to detect detection data at key locations in the urban water system and upload the detection data to the cloud server in real time, and the cloud server can process the data.
[0049] The functions implemented by the detection method provided in the embodiment of the present application can be implemented by calling program codes by a processor of an electronic device, wherein the program codes can be stored in a computer storage medium.
[0050] The present application embodiment provides a detection method, Figure 2 A schematic diagram of the implementation process of a detection method provided for the implementation of this application, such as Figure 2 As shown, the detection method includes:
[0051] Step S101, obtaining first detection data of sensors at key locations in an urban water system.
[0052] In the embodiment of the present application, the urban water system may include: at least one of a river, a lake, a drinking water source and a sewage outlet; the key location may be one or more selected monitoring points; various types of sensors may be installed at the monitoring points; and the first detection data of each key location may be detected by various types of sensors. The sensor may include: at least one of a microbial sensor, a water quality sensor, a flow sensor and a pressure sensor.
[0053] In the embodiment of the present application, the first detection data may include: heavy metal content, microbial concentration, water volume, water flow rate, pH value, temperature, flow rate, etc.
[0054] In the embodiment of the present application, the heavy metal content can be detected by a water quality sensor. The water quality sensor can be an electrochemical sensor. After the electrochemical sensor is calibrated to a standard solution, the electrochemical sensor probe is immersed in the water body, and the heavy metal content is detected by voltammetry. The voltage range of the electrochemical sensor can be set to 0.1V to 10V, which can detect lead, cadmium, mercury and arsenic in water. The heavy metal content calculation formula can be expressed as:
[0055]
[0056] Among them, C HM is the heavy metal content, M is the number of heavy metal types detected, For the A heavy metal current, For the The electrode potential of heavy metals, is the standard electrode potential, R is the gas constant, T is the water temperature, A is the electrode area, F is the Faraday constant, is the background current.
[0057] In the embodiment of the present application, the water flow rate can be collected by a flow sensor. The flow sensor adopts an ultrasonic flow sensor with a dual-channel structure. The flow sensor is installed in a pipeline or an open channel. The flow sensor transmits and receives ultrasonic signals, and the water flow rate is calculated by measuring the signal transmission time difference. The formula for calculating the water flow rate can be expressed as:
[0058]
[0059] Where, Q is the water flow, D is the pipe diameter, n is the number of sampling times, and For the The upstream and downstream flow velocities of the subsamples, For the The flow velocity angle of the sub-sample, For the The sampling time, γ is the flow correction factor, h is the water depth, and L is the pipeline length.
[0060] In the embodiment of the present application, the water pressure can be detected by a pressure sensor. The pressure sensor can be a resistance strain gauge pressure sensor, and the measurement range is set to 0 Pa to 1000 kPa. The pressure sensor is installed in the pipeline. The strain gauge of the sensor converts the pressure signal into an electrical signal through a bridge circuit to obtain the water pressure. The formula for calculating the water pressure can be expressed as:
[0061] ;
[0062] Where P is the water pressure, is the output voltage change, G is the amplification factor, m is the number of measurements, For the The resistance value measured is is the initial resistance value, For the The energy measured, is the reference energy, k is the Boltzmann constant, T is the absolute temperature, is the pressure correction coefficient, D is the sensor diameter, and H is the sensor height.
[0063] In the embodiment of the present application, the microbial concentration can be collected in real time by a microbial sensor. The microbial sensor can use an optical sensor and a fluorescence detection method. The excitation light source of the sensor is an LED with a wavelength range of 360nm to 370nm. The concentration of Escherichia coli, enterococcus and Vibrio cholerae in water is calculated by detecting the fluorescence intensity by a photomultiplier tube. The microbial concentration can be calculated by the following formula: ;
[0064] Among them, C MB is the microbial concentration, is the maximum fluorescence intensity, is the fluorescence signal intensity, is the initial fluorescence intensity, is the standard deviation of fluorescence intensity, is the microbial growth rate constant, is the sampling time interval, For reference time.
[0065] Step S102: pre-process the first detection data to obtain processed first detection data.
[0066] In the embodiments of the present application, different data are pre-processed in different ways due to different sources and formats.
[0067] In the embodiments of the present application, the data may be cleaned using an outlier detection algorithm and noise filtering technology to remove noise data and outliers, and the data from different sources may be normalized and detrended, including unified processing of data formats and scales.
[0068] Step S103: extract key feature information corresponding to each sensor from the processed first detection data.
[0069] In the embodiment of the present application, the key feature information may include: feature data based on time series and frequency domain data. The feature data based on time series may be referred to as time series features.
[0070] In the embodiment of the present application, different first detection data may have different feature extraction methods.
[0071] In the embodiment of the present application, the heavy metal content after pretreatment can be analyzed by using an improved autoregressive integral moving average model combined with wavelet transform. C HM Modeling to extract heavy metal content based on time series C HM , the modeling formula is:
[0072]
[0073] in, is the heavy metal content at time t, is the autoregressive parameter, is the moving average parameter, is the error term, is the time-dependent disturbance term, and q are the orders of autoregression and moving average, respectively. is the wavelet transform coefficient, is the wavelet function, and are the scale and translation parameters of the wavelet transform.
[0074] In the embodiment of the present application, the microbial concentration data can be converted into the frequency domain using the improved fast Fourier transform combined with the Hilbert-Huang transform to extract the frequency domain features. , extract frequency domain features The following formula can be used:
[0075]
[0076] in, is the microbial concentration at the nth sampling point, is the frequency domain feature at frequency f, N is the total number of sampling points, is the attenuation factor, is the intrinsic mode function of the Hilbert transform.
[0077] In the embodiment of the present application, the water volume may be feature extracted to calculate the time series features of the water volume Q, that is, feature data based on the time series.
[0078] In the embodiment of the present application, the water flow velocity may be feature extracted, and the time series characteristics of the water flow velocity v may be calculated using a recursive neural network model.
[0079] In the embodiment of the present application, the pH value of the water quality can be subjected to time series analysis, and the time series characteristics of the pH value can be calculated using a variational autoencoder combined with a Gaussian process regression.
[0080] In the embodiment of the present application, a time series analysis is performed on the water temperature and the water pressure, and the time series characteristics of the water temperature T and the water pressure P are calculated.
[0081] Step S104: input the key feature information and the topological structure data of the sensor into a pre-established network model to determine the detection results of each key position.
[0082] In the embodiment of the present application, the network model may be an improved deep learning model. Self-supervised learning and attention mechanism are introduced into the deep learning model, batch model training and online model training are performed using a large amount of historical data, and a pre-established network model is obtained through big data analysis and self-supervised learning methods.
[0083] In the embodiment of the present application, the topological structure data of the sensor includes: the position relationship and the connection relationship between the various sensors.
[0084] In an embodiment of the present application, the improved deep learning model can be constructed based on a hybrid structure of a graph neural network layer and a transformer model layer.
[0085] In the embodiment of the present application, the trained network model can be used to monitor the operating status of the urban water system in real time, thereby obtaining detection information. The detection information may include: whether the water quality at each location is polluted, whether the pipeline is leaking, and whether the flow rate is abnormal.
[0086] In an embodiment of the present application, the network model includes: a converter layer, a graph neural network layer, a fusion layer and a detection result output layer. The outputs of the converter layer and the graph neural network layer are the inputs of the fusion layer, and the output of the fusion layer is the input of the detection result output layer. The input of the converter layer includes: feature data based on time series, the output of the converter layer includes encoded features, the input of the graph neural network layer includes: topological structure data of the sensor and feature data based on time series, the output of the graph neural network layer is the updated feature data of each sensor, the fusion layer is used to fuse the encoded features and the updated feature data to obtain fused features, and the detection module is used to output detection information based on the fused features.
[0087] In an embodiment of the present application, the graph neural network layer introduces an attention mechanism and multi-head attention. The attention mechanism introduced in the graph neural network layer is used to calculate the attention coefficient based on the topological structure data of the sensor and the feature data based on the time series. The multi-head attention mechanism introduced in the graph neural network layer is used to apply the attention coefficient to the message transmission process in the graph neural network layer, so as to update the updated feature data of each sensor based on the attention coefficient.
[0088] In the embodiment of the present application, by combining the graph neural network layer and the converter layer, the spatial topological structure and time series data of the sensor network are fully utilized to improve the processing accuracy and reliability of the model for sensor data. It can more accurately capture various abnormal conditions in the water system, such as water pollution, pipeline leakage and abnormal flow rate.
[0089] In some embodiments, the characteristic data of the time series include: heavy metal content, microbial concentration, water volume, water flow rate, water temperature and water pressure. The first calculation formula for calculating the attention coefficient includes:
[0090] ;
[0091] in, ij For sensor and sensors The attention coefficient between is the training parameter vector in the attention mechanism, W is the feature transformation matrix, || represents the vector connection operation, d For sensor and sensors The distance between ( ) For sensor The neighbor node set, X is the characteristic matrix of the sensor, X includes the heavy metal content C HM , microbial concentration F MB, water volume Q, water flow velocity v, water temperature T and water pressure P, and the adjacency matrix A represents the connection relationship between sensors.
[0092] In the embodiment of the present application, the graph neural network layer uses a second calculation formula based on the attention coefficient to update the updated feature data of each sensor, and the second calculation formula includes:
[0093] ; where σ is the activation function, For the The attention coefficient of the attention head, For the The feature transformation matrix of the attention heads, H is the number of multi-head attention heads.
[0094] In the embodiments of the present application, the attention mechanism and multi-head attention mechanism are introduced to enable the model to better understand and model the complex relationship between sensor data, thereby improving the accuracy and efficiency of anomaly detection. Combined with the self-supervised learning mechanism, the model can effectively learn under unsupervised conditions, further improving the performance of anomaly detection and early warning.
[0095] In an embodiment of the present application, a dual self-supervised learning mechanism is introduced into the converter layer, and the dual self-supervised learning mechanism introduced into the converter layer is used to add feature data based on time series to position coding, and perform dual self-supervised learning based on the feature data with position coding added, wherein the dual self-supervised learning includes: a masked feature prediction task and a neighborhood feature prediction task, the masked feature prediction task is used to randomly mask the feature data with position coding added and predict the masked feature value, the neighborhood feature prediction task is used to predict the feature representation of the neighboring nodes of the sensor, and the loss function of the converter layer includes: the loss of the neighborhood feature prediction task and the loss of the masked feature prediction task.
[0096] In the embodiment of the present application, the feature data based on the time series is the input feature, and adding the feature data based on the time series to the position code can be achieved by the following formula:
[0097]
[0098]
[0099] in, and They represent the even and odd position codes at position pos, d is the dimension of the position code, K is the number of historical time steps, is the heavy metal content at position pos-k, is the microbial concentration at position pos-k.
[0100] In the embodiment of the present application, by introducing dual self-supervised learning, the model can be effectively trained in the absence of labeled data, thereby enhancing the adaptability and generalization ability of the model, enabling it to maintain good performance in different application scenarios.
[0101] In the embodiment of the present application, the construction of the masked feature prediction task includes randomly masking a part of the features of the input feature matrix X, and predicting the masked feature values through the model. The loss function is:
[0102]
[0103] in, is the set of masked positions, For features in other locations Predict the masked position under the condition probability.
[0104] In the embodiment of the present application, the construction of the neighborhood feature prediction task includes predicting the node neighborhood features through the message passing mechanism of the graph neural network and constructing the neighborhood feature similarity loss function, and the formula is as follows:
[0105]
[0106] Where N is the number of nodes, is the set of neighbor nodes of node i, and Node and nodes The feature representation of .
[0107] In the embodiment of the present application, the total loss function of the model can be expressed as:
[0108]
[0109] ;
[0110] in, To balance the weight coefficients of the two tasks, T is the number of time steps, They are the predicted heavy metal content, microbial concentration, water volume, water flow rate, water temperature and water pressure.
[0111] In the embodiment of the present application, each node can be each key position, and each key position corresponds to a sensor at the position, so the node corresponds to the sensor.
[0112] In the embodiment of the present application, the features output by the converter layer and the graph neural network layer are fused by the fusion layer to obtain the feature vector representation of the detection data of each sensor. Exemplarily, the feature vector representation includes: heavy metal content feature vector , microbial concentration feature vector , water quantity characteristic vector , water flow velocity characteristic vector , pH value feature vector , water temperature feature vector and the water pressure eigenvector .
[0113] In an embodiment of the present application, after obtaining the feature vector, the feature vector can be input into a detection result output layer, and the detection result output layer can be called an anomaly detection module, which is used to determine whether the detection information is abnormal.
[0114] In the embodiment of the present application, the detection result output layer can calculate the Euclidean distance and cosine similarity between feature vectors, and the calculation formula can be expressed as:
[0115]
[0116]
[0117] in, and is the feature vector of any two sensors, and d is the dimension of the feature vector.
[0118] In the embodiment of the present application, the detection result output layer can judge abnormal conditions such as water pollution, pipeline leakage and abnormal flow rate by calculating the Euclidean distance and cosine similarity between feature vectors.
[0119] In the embodiment of the present application, the abnormal situation can be classified based on a rule-based classifier, and the classifier rules include:
[0120] when When the concentration of pollutants is less than 10%, it is judged as heavy metal pollution;
[0121] when When the
[0122] when or When , it is judged as pipeline leakage;
[0123] when or When the temperature or pressure is abnormal.
[0124] In the embodiment of the present application, , , , , , are the set judgment thresholds respectively.
[0125] Step S105: when there is an abnormality in the detection result of the target key position, output a warning signal.
[0126] In the embodiment of the present application, the target key position may be one or more of the key positions, and warning signals may be output through multiple channels such as text messages, emails, and mobile phone APPs.
[0127] In some embodiments, relevant managers are notified through multiple channels such as SMS, email, and mobile phone APP to output early warning signals.
[0128] In some embodiments, the detection result includes: abnormality type, abnormality location and abnormality degree. When there is an abnormality in the detection result of the target key position, an early warning signal is output, including: when there is an abnormality in the detection result of the target key position, a processing suggestion is determined based on the abnormality type, abnormality location and abnormality degree; and the abnormality type, abnormality location and processing suggestion are sent to the management personnel corresponding to the target key position.
[0129] The method provided in the embodiment of the present application obtains first detection data of sensors at key positions in an urban water system; preprocesses the first detection data to obtain processed first detection data; extracts key feature information corresponding to each sensor from the processed first detection data; inputs the key feature information and the topological structure data of the sensor into a pre-established network model to determine the detection results of each key position; and outputs a warning signal when there is an abnormality in the detection result of the target key position, thereby improving the accuracy of detection of the water system.
[0130] In some embodiments, before step S101, the method further includes:
[0131] Step S1011, obtaining second detection data of the candidate monitoring point in the urban water system, wherein the second detection data includes: heavy metal content, water temperature and water flow;
[0132] Step S1012: Determine the target monitoring point from the candidate monitoring points using a third calculation formula based on the second detection data, so as to determine the key position based on the target monitoring point, wherein the third calculation formula includes:
[0133]
[0134] in, L optimalis the optimal monitoring point location, N is the number of alternative monitoring points, For the The water volume at each monitoring point, For the The heavy metal content at each monitoring point For the The distance between each monitoring point and the center of the urban water system, For the The water temperature at each monitoring point, α and β are empirical coefficients.
[0135] In some embodiments, the method further comprises:
[0136] Displays the specific location and type of anomaly.
[0137] In the embodiment of the present application, a visualization interface and a geographic information system may be integrated to display a specific location and anomaly type based on the geographic information system.
[0138] In some embodiments, the method further comprises:
[0139] Perform time series forecasting, seasonal analysis and forecasting based on historical and real-time data, analyze the operating trends of water systems, predict potential problems, and provide optimization suggestions based on the analysis results, including adjusting water treatment processes, strengthening monitoring of specific areas, and optimizing resource allocation.
[0140] The detection method provided in the embodiment of the present application, through the combination of the graph neural network layer and the Transformer layer, makes full use of the spatial topological structure and time series data of the sensor network, improves the processing accuracy and reliability of the model for sensor data, and can more accurately capture various abnormal conditions in the water system, such as water pollution, pipeline leakage and abnormal flow rate.
[0141] In an embodiment of the present application, a hybrid structure model based on a graph neural network layer and a Transformer layer is constructed to fully utilize the topological structure information and time series data of the sensor network, introduce an attention mechanism and a multi-head attention mechanism, calculate the attention coefficient between sensor nodes and perform feature updates, combine position encoding and self-supervised learning, and perform masked feature prediction tasks and neighborhood feature prediction tasks to enhance the model's adaptability and generalization capabilities, thereby improving the model's prediction capabilities.
[0142] The method provided in the embodiment of the present application monitors the operating status of the water system in real time through a network model, detects abnormal conditions such as water pollution, pipeline leakage, and abnormal flow rate, performs anomaly detection by calculating the Euclidean distance and cosine similarity of feature vectors, and uses a rule-based classifier to classify the abnormal conditions, thereby achieving accurate detection and early warning of water pollution, pipeline leakage, and temperature or pressure anomalies.
[0143] Based on the above embodiments, the present application further provides a detection method. Figure 3 A schematic diagram of the implementation process of a detection method provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the method includes:
[0144] Step S1, deploy water quality sensors, flow sensors and pressure sensors at key locations of the urban water system to collect heavy metal content, microbial concentration, water volume and water flow rate in real time.
[0145] Step S2, through the Internet of Things technology, the data collected by the water quality sensor, flow sensor and pressure sensor are transmitted to the cloud platform in real time, and the data are summarized and pre-processed on the cloud platform.
[0146] Step S3: clean the aggregated data using an outlier detection algorithm and noise filtering technology to remove noise data and outliers.
[0147] Step S4, normalize and detrend the data from different sources, including unifying the data format and scale.
[0148] Step S5, extracting key features from the pre-treated heavy metal content, microbial concentration, water volume and water flow velocity data through time series analysis and frequency domain feature extraction as input of the deep learning model, the key features including heavy metal content, microbial concentration, pH value of water quality, temperature and flow velocity.
[0149] Step S6, construct an improved deep learning model based on a hybrid structure of graph neural network layer and Transformer layer, and introduce self-supervised learning and attention mechanism.
[0150] Figure 4 A processing flow diagram of a network model provided in an embodiment of the present application is shown in FIG. Figure 4 As shown in the figure, the input of the Transformer layer is time series data. The time series data is positionally encoded and the encoded time series data is processed based on the multi-head self-attention mechanism of the Transformer layer. The feature prediction task is masked using a self-supervised learning mechanism, and then the features are output. The graph neural network layer is used to input sensor data, and the feature matrix X is determined based on the sensor data. Then, the attention mechanism is introduced to calculate the attention coefficient in combination with the adjacency matrix A, and the attention coefficient is passed through the message passing process of the multi-head attention mechanism, and finally the updated features are output. The fusion layer fuses the features output by the Transformer layer and the graph neural network layer, and the overall model outputs the detection results.
[0151] Step S7, using a large amount of historical data and the key features in step S5 to perform batch model training and online model training, and training and improving the deep learning model through big data analysis and self-supervised learning methods.
[0152] Step S8, using the trained improved deep learning model to monitor the operating status of the water system in real time, detect water pollution, pipeline leakage and abnormal flow rate anomalies. When an abnormality is detected, an early warning signal including the type, location and severity of the anomaly is automatically generated, and relevant managers are notified through multiple channels such as SMS, email and mobile phone APP.
[0153] Step S9, providing decision support integrating a visualization interface and a geographic information system to display the specific location and type of the abnormal situation.
[0154] Step S10, perform time series forecasting and seasonal analysis and forecasting, analyze the operation trend of the water system based on historical data and real-time data, predict potential problems, and provide optimization suggestions based on the analysis results, including adjusting the water treatment process, strengthening monitoring of specific areas, and optimizing resource allocation.
[0155] According to the aforementioned embodiments, the embodiments of the present application provide a detection device, and the modules included in the device and the units included in the modules can be implemented by a processor in a computer device; of course, they can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU, Central Processing Unit), a microprocessor (MPU, Microprocessor Unit), a digital signal processor (DSP, Digital Signal Processing) or a field programmable gate array (FPGA, Field Programmable Gate Array), etc.
[0156] The present application embodiment provides a detection device, Figure 5 A schematic diagram of the structure of a detection device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the detection device 500 includes:
[0157] An acquisition module 501 is used to acquire first detection data of sensors at key locations in an urban water system;
[0158] A preprocessing module 502, configured to preprocess the first detection data to obtain processed first detection data;
[0159] An extraction module 503 is used to extract key feature information corresponding to each sensor from the processed first detection data;
[0160] A determination module 504 is used to input the key feature information and the topological structure data of the sensor into a pre-established network model to determine the detection results of each key position;
[0161] The output module 505 is used to output a warning signal when there is an abnormality in the detection result of the key position of the target.
[0162] In some embodiments, the key feature information includes: feature data based on time series, the network model includes: a converter layer, a graph neural network layer, a fusion layer and a detection result output layer, the outputs of the converter layer and the graph neural network layer are input to the fusion layer, the output of the fusion layer is input to the detection result output layer, the input of the converter layer includes: feature data based on time series, the output of the converter layer includes encoded features, the input of the graph neural network layer includes: topological structure data of the sensor and feature data based on time series, the output of the graph neural network layer is updated feature data for each sensor, the fusion layer is used to fuse the encoded features and the updated feature data to obtain fused features, and the detection result output layer is used to output detection results based on the fused features.
[0163] In some embodiments, the graph neural network layer introduces an attention mechanism and multi-head attention. The attention mechanism introduced in the graph neural network layer is used to calculate the attention coefficient based on the topological structure data of the sensor and the feature data based on the time series. The multi-head attention mechanism introduced in the graph neural network layer is used to apply the attention coefficient to the message transmission process in the graph neural network layer to update the updated feature data of each sensor based on the attention coefficient.
[0164] In some embodiments, the characteristic data of the time series include: heavy metal content, microbial concentration, water volume, water flow rate, water temperature and water pressure. The first calculation formula for calculating the attention coefficient includes:
[0165] ;
[0166] in, ij For sensor and sensors The attention coefficient between is the training parameter vector in the attention mechanism, W is the feature transformation matrix, || represents the vector connection operation, d For sensor and sensors The distance between ( ) For sensor The neighbor node set, X is the characteristic matrix of the sensor, X includes the heavy metal content C HM , microbial concentration F MB , water volume Q, water flow velocity v, water temperature T and water pressure P, the adjacency matrix A represents the connection relationship between sensors;
[0167] The graph neural network layer updates the updated feature data of each sensor using a second calculation formula based on the attention coefficient, and the second calculation formula includes:
[0168] ;
[0169] Among them, σ is the activation function, For the The attention coefficient of the attention head, For the The feature transformation matrix of the attention heads, H is the number of multi-head attention heads.
[0170] In some embodiments, the converter layer introduces a dual self-supervised learning mechanism, which is used to add feature data based on time series to position coding, and perform dual self-supervised learning based on the feature data with position coding, wherein the dual self-supervised learning includes: a masked feature prediction task and a neighborhood feature prediction task, the masked feature prediction task is used to randomly mask the feature data with position coding and predict the masked feature value, the neighborhood feature prediction task is used to predict the feature representation of the sensor's neighbor nodes, and the loss function of the converter layer includes: the loss of the neighborhood feature prediction task and the loss of the masked feature prediction task.
[0171] In some embodiments, the detection device 500 further includes:
[0172] A detection data acquisition module, used to acquire second detection data of the candidate monitoring point in the urban water system, wherein the second detection data includes: heavy metal content, water temperature and water flow;
[0173] A calculation module is used to determine the target monitoring point from the candidate monitoring points using a third calculation formula based on the second detection data, so as to determine the key position based on the target monitoring point, wherein the third calculation formula includes:
[0174]
[0175] in, L optimal is the optimal monitoring point location, N is the number of alternative monitoring points, For the The water volume at each monitoring point, For the The heavy metal content at each monitoring point For the The distance between each monitoring point and the center of the urban water system, For the The water temperature at each monitoring point, α and β are empirical coefficients.
[0176] In some embodiments, the detection result includes: abnormality type, abnormality location and abnormality degree. When the detection result of the target key position is abnormal, an early warning signal is output, including:
[0177] In the event that the detection result of the target key position is abnormal, a processing suggestion is determined based on the abnormality type, abnormality location and abnormality degree;
[0178] The abnormality type, abnormality location and processing suggestion are sent to the management personnel corresponding to the target key location.
[0179] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0180] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 6 As shown, the electronic device 3 of this embodiment may include: at least one processor 30 ( Figure 6 Only one processor 30 is shown in the figure), a memory 31, and a computer program 32 stored in the memory 31 and executable on at least one processor 30. When the processor 30 executes the computer program 32, the steps in any of the above-mentioned method embodiments are implemented, for example Figure 6 Steps S101 to S105 in the illustrated embodiment. Alternatively, when the processor 30 executes the computer program 32, the functions of each module / unit in the above-mentioned device embodiments are implemented, for example Figure 5 Functions of modules 501 to 505 are shown.
[0181] Exemplarily, the computer program 32 may be divided into one or more modules / units, one or more modules / units are stored in the memory 31, and are executed by the processor 30 to complete the present application. One or more modules / units may be a series of computer program 32 instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 32 in the electronic device 3.
[0182] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program 32. When the computer program 32 is executed by the processor 30, the steps in the above-mentioned method embodiments can be implemented.
[0183] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0184] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. According to this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program 32, and the computer program 32 can be stored in a computer-readable storage medium. When the computer program 32 is executed by the processor 30, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program 32 includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the terminal, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0185] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0186] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0187] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0188] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0189] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A detection method, characterized in that: include: Acquire first detection data of sensors at key locations in the urban water system; Preprocessing the first detection data to obtain processed first detection data; Extracting key feature information corresponding to each sensor from the processed first detection data, the key feature information comprising: feature data based on time series; Input the key feature information and the topological structure data of the sensor into a pre-established network model to determine the detection results of each key position. The network model includes: a converter layer, a graph neural network layer, a fusion layer and a detection result output layer. The outputs of the converter layer and the graph neural network layer are the inputs of the fusion layer. The output of the fusion layer is the input of the detection result output layer. The input of the converter layer includes: feature data based on time series. The output of the converter layer includes encoded features. The input of the graph neural network layer includes: topological structure data of the sensor and feature data based on time series. The output of the graph neural network layer is updated feature data of each sensor. The fusion layer is used to fuse the encoded features and the updated feature data to obtain fused features. The detection result output layer is used to output the detection result based on the fused features. The graph neural network layer introduces an attention mechanism and multi-head attention. The attention mechanism introduced in the graph neural network layer is used to calculate the attention coefficient based on the topological structure data of the sensor and the feature data based on the time series. The multi-head attention introduced in the graph neural network layer is used to apply the attention coefficient to the message transmission process in the graph neural network layer to update the updated feature data of each sensor based on the attention coefficient. The characteristic data of the time series include: heavy metal content, microbial concentration, water volume, water flow rate, water temperature and water pressure. The first calculation formula for calculating the attention coefficient includes: ; For sensor and sensors The attention coefficient between is the training parameter vector of the attention mechanism, W is the feature transformation matrix, represents a vector concatenation operation, For sensor and sensors The distance between For sensor and sensors The distance between N( ) For sensor The neighbor node set, X is the characteristic matrix of the sensor, X includes the heavy metal content C HM , microbial concentration F MB , water volume Q , water flow speed v , water temperature t and water pressure P ; The graph neural network layer updates the updated feature data of each sensor using a second calculation formula based on the attention coefficient, and the second calculation formula includes: Among them, σ is the activation function, For the The attention coefficient of the attention head, For the The feature transformation matrix of the attention heads, H is the number of multi-head attention heads, For sensor Feature data before update, For sensor Update feature data of When there are abnormalities in the detection results of key target locations, an early warning signal is output.
2. The method according to claim 1, characterized in that The converter layer introduces a dual self-supervised learning mechanism, which is used to add feature data based on time series to position coding, and perform dual self-supervised learning based on the feature data with position coding, wherein the dual self-supervised learning includes: a masked feature prediction task and a neighborhood feature prediction task, the masked feature prediction task is used to randomly mask the feature data with position coding and predict the masked feature value, the neighborhood feature prediction task is used to predict the feature representation of the sensor's neighbor nodes, and the loss function of the converter layer includes: the loss of the neighborhood feature prediction task and the loss of the masked feature prediction task.
3. The method according to claim 1, characterized in that: The method further comprises: Acquire second detection data of the candidate monitoring point in the urban water system, wherein the second detection data includes: heavy metal content, water temperature and water flow; Based on the second detection data, a target monitoring point is determined from the candidate monitoring points using a third calculation formula to determine a key position based on the target monitoring point, wherein the third calculation formula includes: in, L optimal is the optimal monitoring point location, N is the number of alternative monitoring points, For the The water volume at each monitoring point, For the The heavy metal content at each monitoring point For the The distance between each monitoring point and the center of the urban water system, For the The water temperature at each monitoring point, α and β are empirical coefficients.
4. The method according to claim 1, characterized in that The detection result includes: abnormal type, abnormal location and abnormal degree. When the detection result of the target key position is abnormal, an early warning signal is output, including: In the event that the detection result of the target key position is abnormal, a processing suggestion is determined based on the abnormality type, abnormality location and abnormality degree; The abnormality type, abnormality location and processing suggestion are sent to the management personnel corresponding to the target key location.
5. A detection device, characterized in that: include: An acquisition module, used for acquiring first detection data of sensors at key positions in the urban water system; A preprocessing module, used for preprocessing the first detection data to obtain processed first detection data; An extraction module, used to extract key feature information corresponding to each sensor from the processed first detection data, wherein the key feature information includes: feature data based on time series; A determination module, used to input the key feature information and the topological structure data of the sensor into a pre-established network model to determine the detection results of each key position, the network model includes: a converter layer, a graph neural network layer, a fusion layer and a detection result output layer, the output of the converter layer and the graph neural network layer is the input of the fusion layer, the output of the fusion layer is the input of the detection result output layer, the input of the converter layer includes: feature data based on time series, the output of the converter layer includes encoded features, the input of the graph neural network layer includes: topological structure data of the sensor and feature data based on time series, the output of the graph neural network layer is the updated feature data of each sensor, the fusion layer is used to fuse the encoded features and the updated feature data to obtain fused features, the detection result output layer is used to output the detection result based on the fused features, the graph neural network layer introduces an attention mechanism and multi-head attention, the attention mechanism introduced in the graph neural network layer is used to calculate the attention coefficient based on the topological structure data of the sensor and the feature data based on the time series, the multi-head attention introduced in the graph neural network layer is used to apply the attention coefficient to the message transmission process in the graph neural network layer to update the updated feature data of each sensor based on the attention coefficient; The characteristic data of the time series include: heavy metal content, microbial concentration, water volume, water flow rate, water temperature and water pressure. The first calculation formula for calculating the attention coefficient includes: ; in, For sensor and sensors The attention coefficient between is the training parameter vector of the attention mechanism, W is the feature transformation matrix, represents a vector concatenation operation, For sensor and sensors The distance between For sensor and sensors The distance between N( ) For sensor The neighbor node set, X is the characteristic matrix of the sensor, X includes the heavy metal content C HM , microbial concentration F MB , water volume Q , water flow speed v , water temperature t and water pressure P ; The graph neural network layer updates the updated feature data of each sensor using a second calculation formula based on the attention coefficient, and the second calculation formula includes: Among them, σ is the activation function, For the The attention coefficient of the attention head, For the The feature transformation matrix of the attention heads, H is the number of multi-head attention heads, For sensor Feature data before update, For sensor Update feature data of The output module is used to output a warning signal when there is an abnormality in the detection result of the key position of the target.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Abnormity detection method and system for water service culvert box based on machine learning
CN117540310A