Gas identification and concentration prediction method based on multi-task learning

By employing multi-task learning and dynamic feature extraction, combined with a gas diffusion physics model, the accuracy and adaptability issues of traditional gas detection systems in complex environments have been resolved. This has enabled efficient and reliable synchronization of gas type identification and concentration prediction, improving the system's response speed and environmental adaptability.

CN122132959APending Publication Date: 2026-06-02BEIJING SMART SHARING TECH SERVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING SMART SHARING TECH SERVICE CO LTD
Filing Date
2026-02-27
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing gas detection systems struggle to comprehensively and reliably reflect gas leaks or diffusion in complex and dynamic environments. Sensor data fusion is susceptible to noise, and gas type identification and concentration prediction do not share feature representations, leading to computational redundancy and inaccurate prediction results. Furthermore, the models cannot adapt to environmental changes.

Method used

A multi-task learning approach is adopted, which integrates multi-source sensor data through a dynamic weight allocation mechanism, adaptively adjusts the feature extraction window size, uses a shared feature extraction network for gas type identification and concentration prediction, and combines a gas diffusion physics model for correction. An online incremental learning framework is established for model optimization.

Benefits of technology

It improves the accuracy of gas identification and concentration prediction, enhances the model's adaptability, strengthens robustness and prediction reliability in complex environments, and ensures the timeliness and reliability of early warnings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132959A_ABST
    Figure CN122132959A_ABST
Patent Text Reader

Abstract

This invention discloses a gas identification and concentration prediction method based on multi-task learning, relating to the fields of intelligent sensing, environmental monitoring, and artificial intelligence. It addresses the problems of traditional gas identification and concentration prediction methods, such as separation of identification and prediction, insufficient utilization of sensor data, poor model adaptability, lack of physical consistency in prediction results, and difficulty in continuous system optimization. This invention achieves synchronous inference of gas type and concentration through dynamic fusion of multi-source sensors, adaptive window feature extraction, shared feature networks, and parallel identification-prediction branches. Furthermore, it combines physical model correction and risk classification early warning mechanisms, and introduces online incremental learning and reinforcement learning strategies to achieve continuous adaptive updates of model parameters. Ultimately, it achieves high-precision identification, concentration prediction, risk assessment, and adaptive early warning of gas leaks, significantly improving the accuracy and real-time response capability of gas monitoring systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the fields of intelligent sensing, environmental monitoring and artificial intelligence technology, specifically a gas identification and concentration prediction method based on multi-task learning. Background Technology

[0002] In fields such as industrial safety, environmental monitoring, and disaster early warning, the real-time and accurate identification and prediction of gas types and their concentrations are of paramount importance. Traditional gas detection systems typically rely on single or multiple independent sensors to achieve qualitative or quantitative analysis of specific gases through changes in physical or chemical signals. However, in complex and dynamic real-world environments, gas leaks or diffusion processes often involve challenges such as the coexistence of multiple components, non-uniform concentration distribution, and diverse environmental interference factors, making it difficult for a single detection task to comprehensively and reliably reflect the actual situation on-site. Gas identification and concentration prediction are two closely related tasks: gas type determines its toxicity, explosion limits, and other hazardous characteristics, while concentration levels and their changing trends directly relate to the degree of risk and emergency decision-making. Separating these two tasks not only increases system complexity and computational burden but may also lead to delayed warnings or decision-making errors due to information asynchrony.

[0003] In recent years, multi-task learning has demonstrated its advantages as an effective machine learning paradigm in various fields. By sharing underlying feature representations, it enables related tasks to mutually promote and optimize each other, thereby improving the model's generalization ability and learning efficiency. Introducing multi-task learning into the field of gas detection is expected to simultaneously achieve accurate gas type identification and dynamic concentration prediction within a unified framework, improving the overall system performance and response speed. Furthermore, combining sensor data fusion technology, time-series analysis methods, and physical constraints can further enhance the model's robustness in noisy environments and the physical reliability of prediction results. Based on this, researching an intelligent method capable of collaboratively performing gas identification and concentration prediction, adapting to environmental changes, and fusing multi-source information and physical knowledge is of great significance for constructing a highly reliable and adaptive gas safety monitoring and early warning system.

[0004] The following problems exist in the existing technology: In existing technologies, multi-sensor data fusion often uses fixed weights or simple averaging, without considering sensor signal quality, historical accuracy, and redundancy between sensors. This makes the fusion results susceptible to noise, drift, or faulty sensors. Existing methods typically use a fixed time window for feature extraction, which cannot adaptively adjust according to the rate of change of gas concentration, resulting in information redundancy when changes are slow and insufficient information when changes are drastic. Traditional methods treat gas type identification and concentration prediction as two independent tasks, without sharing feature representations, resulting in computational redundancy and failing to utilize the inherent correlation between the two tasks, thus affecting overall performance and efficiency. Traditional methods based on purely data-driven concentration prediction models may output results that do not conform to the physical laws of gas diffusion, especially in scenarios with insufficient training data coverage, resulting in low reliability of prediction results. Traditional models are fixed once trained, and cannot be dynamically optimized based on newly acquired data. They are also difficult to adapt to sensor aging, environmental changes, or the emergence of new gas types. Summary of the Invention

[0005] The present invention aims to solve at least one of the technical problems existing in the prior art; to this end, the present invention proposes a gas identification and concentration prediction method based on multi-task learning to solve the above-mentioned technical problem.

[0006] A first aspect of the present invention provides a gas identification and concentration prediction method based on multi-task learning, comprising the following steps: S1: Collect time-series data of the target gas through a multi-source sensor network, and use a dynamic weight allocation mechanism to fuse the time-series data to generate a fused gas feature sequence; S2: Based on the real-time change rate of the gas feature sequence, the window size for feature extraction is adaptively adjusted; the gas feature sequence is divided according to the adjusted window size and then input into a shared feature extraction network for feature encoding; based on the shared features output by the shared feature extraction network, synchronous reasoning is performed through parallel gas type identification branches and gas concentration prediction branches to output the identification result of the current gas type and the gas concentration prediction sequence for future periods, respectively. S3: The gas concentration prediction sequence for the future time period is fused and corrected with the calculation results based on the gas diffusion physics model to generate a gas concentration prediction result corrected by physical constraints. S4: Based on the gas type identification result and the gas concentration prediction result after physical constraint correction, assess the gas leakage risk level; based on the risk level and the future trend of gas concentration prediction results, trigger graded early warning and control commands. S5: Based on the new time-series data collected online, the risk level, and the execution effect information of the control instructions, the parameters of the shared feature extraction network, the gas type identification branch, and the gas concentration prediction branch are jointly fine-tuned and adaptively updated.

[0007] Preferably, step S1 includes the following steps: Construct a multi-source sensor network that includes various gas sensors and auxiliary environmental sensors to synchronously collect time-series concentration data of the target gas; For each time t, a comprehensive dynamic weight is calculated for each sensor, which incorporates the signal quality index Q based on the signal-to-noise ratio. i (t) Accuracy index A based on historical consistency i (t) and the inter-sensor correlation penalty term C used to suppress redundant information i (t); Comprehensive dynamic weight w i The formula for calculating (t) is:

[0008] Where i and j are sensor indices, i,j=1,2,…,N, N is the total number of sensors, x i (t) represents the original measurement value of sensor i at time t, and α, β, and η are adjustment parameters; By utilizing integrated dynamic weights, time-series data from multiple sensors are fused to obtain the fused feature value x at time t. fused (t), generating the fused gas feature sequence {x fused (t)}:

[0009] Where x i (t) represents the original measurement value of sensor i at time t.

[0010] Preferably, in step S2, the data window size for feature extraction is adaptively adjusted based on the real-time rate of change of the gas feature sequence, including the following steps: Based on the fused gas feature sequence {x fused Calculate the real-time rate of change r(t) of the gas characteristic sequence:

[0011] Among them, T s Where L is the sampling period and L is the initial window length; Based on the real-time rate of change r(t) of the gas feature sequence, the baseline window size W for feature extraction is calculated using a nonlinear inverse proportional function. base (t):

[0012] Among them, W min and W max These are the preset minimum and maximum window sizes, respectively; m is the sensitivity coefficient; r0 is the baseline value of the rate of change; σ r This is an estimate of the standard deviation of the rate of change, where p is a power parameter; Set the reference window size W baseBy combining the window size and acceleration information of the rate of change of the previous time step (t), the adaptive window size W(t) for feature extraction is calculated:

[0013] in, The inertia coefficient, Let r(t) be the second derivative of the rate of change. The acceleration sensitivity coefficient; For a given window size W, calculate the data information content index I(W) under that window size:

[0014] Where, μ W and σ W These represent the gas characteristic sequences {x} within the window. fused The mean and standard deviation of (i)}; When I(W) is lower than the preset threshold I th At that time, reselect the window size W that maximizes the data information content index I(W) while minimizing the adjustment cost. new :

[0015] Where λ W To adjust the cost coefficient, W current The current window size.

[0016] Finally, the adaptive window size used for feature extraction was determined to be W. final If W(t) = W(t), then if a reselection is triggered, then W... final (t)=W new .

[0017] Preferably, in step S2, after dividing the gas feature sequence according to the adjusted window size, it is input into a shared feature extraction network for feature encoding, including the following steps: Based on the determined adaptive window size W final (t), from the fused gas characteristic sequence {x fused A cut-off length of W is taken from (t)} final (t) sequence fragments; the gas feature sequence fragments are input in parallel into a shared feature extraction network consisting of three parallel feature extraction sub-networks to extract spatial features, temporal features and time-frequency features respectively; among them, the spatial feature extraction sub-network consists of one-dimensional convolutional layers and is used to extract the spatial topological relationships between multiple sensors; The temporal feature extraction subnetwork consists of a bidirectional long short-term memory network and a temporal attention module. After processing the input gas feature sequence fragments, the bidirectional long short-term memory network outputs the hidden state at each time step, forming a hidden state sequence. Its temporal attention module is used to calculate the importance weight α of the feature at each time step. t The calculation formula is as follows:

[0018] Among them, h t Let v and W be the hidden states at time t. a b a For learnable parameters, The length of the current gas feature sequence segment; using importance weight α t For the hidden state sequence {h t We perform weighted summation to obtain the weighted time series features; The time-frequency feature extraction subnetwork first converts the gas feature sequence into a time-frequency coefficient matrix through dual-tree complex wavelet transform, and then uses a two-dimensional convolutional network to extract multi-scale time-frequency features from it; Spatial features, weighted temporal features, and time-frequency features are concatenated and then nonlinearly fused and dimensionality reduced through a fully connected layer, outputting a shared feature vector h. shared .

[0019] Preferably, in step S2, based on the shared features output by the shared feature extraction network, synchronous reasoning is performed through parallel gas type identification branches and gas concentration prediction branches to output the identification result of the current gas type and the gas concentration prediction sequence for future periods, respectively, including the following steps: The gas type recognition branch receives the shared feature vector, outputs a classification probability distribution vector of the gas type through a fully connected network, and is trained using an adaptive focus loss function. The gas category with the highest probability value in the classification probability distribution vector is identified as the current gas type. The modulation factor γ in this loss function... k Based on the frequency of category samples and gas type, the uncertainty of branch prediction is dynamically adjusted:

[0020] Where γ0 is the basic factor, v is the scaling factor, and N c N represents the number of samples for gas category c. total σ represents the total number of samples for all gas categories. c The standard deviation of the predicted probability of the gas type identification branch for that gas category; The gas concentration prediction branch, based on shared feature vectors, uses an encoder-decoder architecture to generate gas concentration prediction sequences for future time periods. Its training process introduces a physical constraint loss L on top of the traditional mean square error loss. physics The forced gas concentration prediction branch results conform to the physical laws of gas diffusion: ; Where o is the time step T in the gas concentration prediction sequence. f Index in The predicted concentration is output by the gas concentration prediction branch, u is the wind speed vector, F is the discrete diffusion-transmission operator based on the diffusion coefficient D and the wind speed vector u, and Δt is the prediction time step. The gas type identification branch and the gas concentration prediction branch are trained synchronously end-to-end through a multi-task joint loss function. The joint loss is a weighted sum of the losses of each task, and the gradient projection mechanism intervenes when a conflict is detected between the gradients of the loss functions of each task on the shared parameters.

[0021] Preferably, step S3 includes the following steps: Based on real-time environmental parameters and leakage source parameters, the physical model prediction sequence for future periods is obtained by solving the gas diffusion physical model. The leakage source parameters are estimated in real time based on sensor observation data through a Bayesian inversion framework. The first uncertainty of the gas concentration prediction sequence is obtained by quantification using uncertainty estimation methods. The second uncertainty of the physical model predicts the sequence. This includes model simplification error, parameter estimation error, and numerical discretization error; The dynamic confidence level τ of the gas concentration prediction sequence is obtained based on the first and second uncertainties. ML The dynamic confidence τ of the sequence predicted by the physical model phys The calculation formula is as follows: ; ; Where, μ ML and μ phys These are the mean values ​​of the gas concentration prediction sequence and the physical model prediction sequence, respectively. ML Fidelity is a measure of the consistency between gas concentration prediction sequences and their historical observations within a time window. phys α and β represent the degree of agreement between the physical model of gas diffusion and fundamental physical laws, respectively. It is a small constant; Based on the dynamic confidence levels of the two prediction sequences, an adaptive weighted fusion method is used to fuse and correct the two prediction sequences, generating a physically constrained corrected gas concentration prediction result. ; Among them, the fusion weight q>1 is the sharpening parameter.

[0022] Preferably, step S4 includes the following steps: Based on the identified gas type, a predefined gas hazard attribute mapping relationship is queried to determine its inherent hazard feature vector H. g Based on the gas concentration prediction results after physical constraint correction, the current concentration risk ratio is calculated: ; Predicted peak risk ratio: ; Predicting cumulative threshold exceedance: ; Among them, c curr c represents the current gas concentration. pred (t+1) represents the predicted concentration at the l-th future time, C thr (g) and C safe (g) represents the hazard threshold and safety threshold for gas g, respectively, and T represents the hazard threshold and safety threshold for gas g. f To predict the duration, a comprehensive risk baseline value is then calculated: ; Where w is the weight vector of the hazard dimension, and α1, α2, and α3 are the weight coefficients of the concentration risk term; Extract the average rate of change from the future trend of gas concentration prediction results. rate of change acceleration and the proportion of time exceeding the threshold P over And based on these trend characteristics, calculate the dynamic risk correction factor F. trend :

[0023] Where β1, β2, and β3 are adjustment coefficients, and γ1 and γ2 are scaling factors; Based on the comprehensive risk base value R base and dynamic risk correction factor F trend Calculate the final risk score The final risk score is mapped to discrete risk levels based on a preset threshold range [θ1, θ2, θ3]; and based on the risk level and average rate of change... and rate of change acceleration By using predefined hierarchical triggering rules, the corresponding hierarchical warning and control command combinations are selected and executed.

[0024] Preferably, step S5 includes the following steps: An online incremental learning framework is established for the shared feature extraction network, gas type identification branch, and gas concentration prediction branch. When updating parameters using new time-series data, this framework introduces elastic weight consolidation constraints, and its incremental loss function is:

[0025] Among them, L new The loss calculated based on the new data, F represents the model parameters saved before fine-tuning. d λ represents the diagonal element of the Fisher information matrix estimated online, λ is the consolidation strength coefficient, and r is the index of the model parameters; the model parameters include trainable parameters in the shared feature extraction network, the gas type identification branch, and the gas concentration prediction branch; The risk level information is quantified into a continuous penalty signal r. risk (t), and quantify the execution effect of the control command into an evaluation value. Combining the two to construct the advantage function in reinforcement learning ; Based on the advantage function, a trust region strategy optimization method is adopted to maximize the expected advantage and guide the update of model parameters under the constraint of KL divergence of the output distributions of the old and new models. During the update process, for the two tasks of gas identification and concentration prediction, the uncertainty u of their online prediction is considered. cls (t) and u reg (t), dynamically adjust its weight w in the joint fine-tuning loss. cls (t) and w reg (t), and perform gradient surgery based on gradient cosine similarity; The update process is dynamically triggered based on real-time calculated validation loss and parameter drift metrics, and a self-supervised loss incorporating knowledge distillation from the old model is employed.

[0026] Compared with the prior art, the beneficial effects of the present invention are: This invention uses a dynamic weight allocation mechanism to comprehensively consider signal-to-noise ratio, historical consistency, and inter-sensor correlation, adaptively adjusting the contribution of each sensor to improve the reliability of the fused sequence and suppress the influence of noise and redundant information. This invention dynamically adjusts the window size based on the rate of change of gas concentration, ensuring that a large window is used to smooth noise when the change is slow, and a small window is used to capture details when the change is drastic, thereby improving the adaptability and information content of feature extraction. This invention employs a shared feature extraction network and parallel task branches to simultaneously perform gas identification and concentration prediction, leveraging the correlation between the two tasks to improve model efficiency and performance, and mitigating task conflicts through a gradient projection mechanism. This invention integrates machine learning predictions with a gas diffusion physics model using uncertainty weighting, so that the predictions conform to both data patterns and physical constraints, thereby improving generalization ability and reliability in complex environments. This invention utilizes an online incremental learning framework, combined with elastic weight consolidation and reinforcement learning mechanisms, to enable the model to continuously optimize based on new data, risk feedback, and control effects, adapting to environmental changes and new scenario requirements. Attached Figure Description

[0027] Figure 1 This is a schematic diagram of the method flow of the present invention. Detailed Implementation

[0028] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0029] Please see Figure 1 This invention relates to a gas identification and concentration prediction method based on multi-task learning, comprising the following steps: S1: Collect time-series data of the target gas through a multi-source sensor network, and use a dynamic weight allocation mechanism to fuse the time-series data to generate a fused gas feature sequence; S2: Based on the real-time change rate of the gas feature sequence, the window size for feature extraction is adaptively adjusted; the gas feature sequence is divided according to the adjusted window size and then input into a shared feature extraction network for feature encoding; based on the shared features output by the shared feature extraction network, synchronous reasoning is performed through parallel gas type identification branches and gas concentration prediction branches to output the identification result of the current gas type and the gas concentration prediction sequence for future periods, respectively. S3: The gas concentration prediction sequence for the future time period is fused and corrected with the calculation results based on the gas diffusion physics model to generate a gas concentration prediction result corrected by physical constraints. S4: Based on the gas type identification result and the gas concentration prediction result after physical constraint correction, assess the gas leakage risk level; based on the risk level and the future trend of gas concentration prediction results, trigger graded early warning and control commands. S5: Based on the new time-series data collected online, the risk level, and the execution effect information of the control instructions, the parameters of the shared feature extraction network, the gas type identification branch, and the gas concentration prediction branch are jointly fine-tuned and adaptively updated.

[0030] Specifically, the entire method begins with the synchronous acquisition of time-series data of the target gas by a multi-source sensor network. The system employs a dynamic weight allocation mechanism to evaluate the signal quality, historical accuracy, and redundancy with other sensors of each sensor in real time, and calculates and assigns dynamic weights accordingly, thereby fusing them to generate a more robust and accurate gas feature sequence. Next, the system enters the adaptive feature extraction and multi-task inference stage. First, the real-time change rate of the gas feature sequence is analyzed, and the time window size used for feature extraction is dynamically adjusted accordingly: a larger window is used when the concentration change is gradual to smooth noise and extract stable patterns; when the change is drastic, a smaller window is switched to capture fast dynamic details. Then, the data segments divided according to this adaptive window are input into a shared feature extraction network. This network extracts spatial, temporal, and time-frequency multi-dimensional features through parallel sub-networks and fuses them into a unified shared feature vector. This shared feature is then fed to two parallel task branches: the gas type identification branch is responsible for outputting the classification result of the current gas category, while the gas concentration prediction branch, based on an encoder-decoder architecture, generates a gas concentration prediction sequence for a future period. Then, the purely data-driven prediction results are corrected for physical laws. The concentration prediction sequence is compared with the prediction sequence obtained by solving the physical model of gas diffusion based on real-time parameters (estimated through inversion of sensor data). By quantifying the prediction uncertainties of each, their dynamic credibility is calculated, and adaptive weighted fusion is performed accordingly. Finally, a concentration prediction result that fits both the data pattern and the physical laws of diffusion and is corrected for physical constraints is output. Based on the identified gas type and the corrected concentration prediction result, the intelligent risk assessment and response stage begins. Multi-dimensional information such as the inherent hazardous properties of the gas, current concentration, predicted peak, cumulative exposure, and concentration change trend is integrated to calculate a comprehensive risk level. Based on this level and future change trend, graded early warnings (such as different levels of alarms) are triggered and corresponding control commands (such as starting ventilation, closing valves, etc.) are generated. Finally, it has the ability to continuously self-evolve, collecting new online data, risk assessment results, and execution feedback of control commands to form a reinforcement learning signal. Using this information, through an online incremental learning framework that combines elastic weight consolidation and trust region strategy optimization, the model parameters of the shared feature extraction network and the two task branches are jointly fine-tuned and adaptively updated.

[0031] In one embodiment of the present invention, step S1 includes the following steps: Construct a multi-source sensor network that includes various gas sensors and auxiliary environmental sensors to synchronously collect time-series concentration data of the target gas; For each time t, a comprehensive dynamic weight is calculated for each sensor, which incorporates the signal quality index Q based on the signal-to-noise ratio. i(t) Accuracy index A based on historical consistency i (t) and the inter-sensor correlation penalty term C used to suppress redundant information i (t); Comprehensive dynamic weight w i The formula for calculating (t) is: ; Where i and j are sensor indices, i,j=1,2,…,N, N is the total number of sensors, x i (t) represents the original measurement value of sensor i at time t, and α, β, and η are adjustment parameters; By utilizing integrated dynamic weights, time-series data from multiple sensors are fused to obtain the fused feature value x at time t. fused (t), generating the fused gas feature sequence {x fused (t)}:

[0032] Where x i (t) represents the original measurement value of sensor i at time t.

[0033] Specifically, the multi-source sensor network consists of various gas sensors (such as electrochemical sensors, semiconductor sensors, infrared sensors, photoionization detectors, etc.) and auxiliary environmental sensors (such as temperature sensors, humidity sensors, air pressure sensors, wind speed and direction sensors). These sensors are spatially distributed according to the physical layout of the monitoring area (such as grid-like, ring-like, or arranged along potential leak paths). The sensor nodes transmit the collected data (such as specific gas concentrations, temperature, humidity, wind speed, etc.) in real time via wired (such as Ethernet) or wireless (such as Wi-Fi) communication protocols. All sensors operate at a fixed sampling period T. s (e.g., T) s =1 second) Synchronous operation, continuously collecting target gas concentration data and environmental parameter data, forming their respective time-series data streams {x i (t)}, where x i (t) represents the original measurement value (such as voltage or current signal) of sensor i at time t, which is usually converted to standard concentration units or environmental parameter units after preliminary calibration. i=1,2,…,N is the sensor index, N is the total number of sensors, and t is the discrete timestamp.

[0034] Calculate the signal quality index Q i (t) is used to evaluate the reliability of the measurement value of sensor i at time t. Its calculation is based on the signal-to-noise ratio (SNR), and the formula is:

[0035] Among them, P signal,i (t) represents the average power of sensor i measured within a recent time window (e.g., the past 10 sampling points), P noise,i This is the background noise power of the sensor in clean air or in a target gas-free environment (which can be obtained through offline calibration). For a very small constant (e.g., 10) -10 To prevent division by zero errors; Q i A higher Q(t) value indicates better signal quality at that moment; typically, Q... i The value of (t) may range from 0dB to 40dB.

[0036] Calculate accuracy index A i (t) is used to evaluate the historical consistency or reliability of sensor i's measurements at time t; its calculation is based on the reciprocal of the deviation of the sensor's measurements from a sequence of reference values ​​over a period of time (e.g., the past K times, K=30): ; Where, x ref (t) can be the median of all other sensor measurements at the same time, or the measurement from a known high-precision sensor, as a reliable reference; δ is a smoothing constant (e.g., 0.01) to prevent the denominator from being zero; A i The larger the (t) value, the more accurate and stable the sensor's recent measurements are.

[0037] Calculate the correlation penalty term C i (t) is used to suppress redundant information from highly correlated sensors and encourage the inclusion of diverse information during fusion; its calculation is based on the average of the Pearson correlation coefficients of sensor i with all other sensors over the current short time window (e.g., the past W points, W=5): ; Where, ρ ij (t) is the correlation coefficient of time-series data of sensors i and j within the window [t−W+1,t]. Its value ranges from [−1,1]. The closer the absolute value is to 1, the stronger the linear correlation. i,j=1,2,…,N; C i The higher the (t) value, the more similar sensor i is to other sensors, and its weight should be penalized during fusion.

[0038] By integrating the above three indicators, the comprehensive dynamic weight w of the sensor is calculated. i (t), where a normalized weight is calculated for each sensor i at time t; the calculation formula is: ; Among them, α, β, and η are positive adjustment parameters used to control the relative importance of signal quality, historical accuracy, and correlation penalty in weight calculation. The specific values ​​of these parameters need to be determined based on the performance of the actual sensor network (such as the noise level and drift characteristics of each sensor) and the reliability and diversity requirements of the application scenario. They can be optimized through historical data or set empirically. α, β, and η are usually between 0.1 and 2.0. For example, a typical set of values ​​is: α=0.5, β=1.0, η=0.3.

[0039] Using the calculated comprehensive dynamic weight w i (t) The raw measurements from multiple sensors are weighted and fused to generate a fused gas characteristic sequence. A quadratic difference term is introduced to enhance robustness to abnormal readings or significant differences between sensors. The fusion formula is:

[0040] Where, x fused (t) represents the fusion feature value at time t, x i (t) represents the original measurement value of sensor i at time t (e.g., the concentration value after preliminary calibration and unit unification); the difference term coefficient λ is used to control the contribution strength of the quadratic difference term in the fusion result. This coefficient is usually set to a small positive number (e.g., λ = 0.01 to 0.1) to prevent this term from dominating the fusion result; its function is that when the readings of two sensors with higher weights differ significantly, this difference will be added to the fusion value as a "penalty" or "correction" term. This helps to smooth the fusion output when the sensor experiences a momentary failure or is subject to local interference, avoiding excessive influence from a single outlier. By repeating the weight calculation and fusion process for each sampling time t, a continuous and robust gas characteristic sequence {x} formed by fusing all sensor time-series data can be obtained. fused (t)}.

[0041] In one embodiment of the present invention, step S2, adaptively adjusting the data window size for feature extraction based on the real-time rate of change of the gas feature sequence, includes the following steps: Based on the fused gas feature sequence {x fused Calculate the real-time rate of change r(t) of the gas characteristic sequence:

[0042] Among them, T s Where L is the sampling period and L is the initial window length; Based on the real-time rate of change r(t) of the gas feature sequence, the baseline window size W for feature extraction is calculated using a nonlinear inverse proportional function. base (t): ; Among them, W min and W max These are the preset minimum and maximum window sizes, respectively; m is the sensitivity coefficient; r0 is the baseline value of the rate of change; σ r This is an estimate of the standard deviation of the rate of change, where p is a power parameter; Set the reference window size W base By combining the window size and acceleration information of the rate of change of the previous time step (t), the adaptive window size W(t) for feature extraction is calculated: ; in, The inertia coefficient, Let r(t) be the second derivative of the rate of change. The acceleration sensitivity coefficient; For a given window size W, calculate the data information content index I(W) under that window size:

[0043] Where, μ W and σ W These represent the gas characteristic sequences {x} within the window. fused The mean and standard deviation of (i)}; When I(W) is lower than the preset threshold I th At that time, reselect the window size W that maximizes the data information content index I(W) while minimizing the adjustment cost. new : ; Where λ W To adjust the cost coefficient, W current The current window size.

[0044] Finally, the adaptive window size used for feature extraction was determined to be W. final If W(t) = W(t), then if a reselection is triggered, then W... final (t)=W new .

[0045] Specifically, based on the fused gas feature sequence {x fused The real-time rate of change of the gas characteristic sequence (t) is calculated to quantify the speed of change of the sequence in the near future; the calculation formula is: ; Where L is an initial, fixed window length used to calculate the average of two adjacent time periods, defining the time scale on which the rate of change calculation depends; T sThe sampling period (in seconds) is L; the value of L should cover the smallest time period during which the gas concentration may undergo significant changes, while avoiding excessive influence from transient noise. A typical range is 5 to 30 sampling points. For example, if the sampling period T... s =1 second, L can be 10, representing the average concentration difference between the past 10 seconds and the 10 seconds before that. r(t) represents the time period ( The average rate of change within ) ; the larger |r(t)| is, the more drastic the change in gas concentration.

[0046] A window refers to a continuous data segment from time-series data containing a fixed number of sampling points; its length (i.e., the number of sampling points it contains) is called the window size. Based on the real-time rate of change r(t), a baseline window size W is calculated by mapping it to a nonlinear inverse proportional function. base (t). When the rate of change r(t) is large (rapid concentration change), a smaller window should be used to capture rapid dynamic characteristics; when the rate of change r(t) is small (stable concentration), a larger window can be used to obtain richer contextual information and suppress noise. The calculation formula is: ; Among them, W min and W max These are the preset minimum and maximum window sizes, which define the boundaries of the adaptive window. A typical value for W is... min Set the number of points to 20 to 50 (ensuring sufficient basic information), W max Set the number of points to 200 to 500 (to avoid excessive length leading to computational burden and feature lag); m is the sensitivity coefficient, and the control function ranges from W... max Descending to W min The steepness of the slope (m) is such that the larger the value of m, the more sensitive the window size is to changes in the rate of change; typical values ​​range from 1.0 to 5.0. r0 is the baseline value of the rate of change, which can be set to the historical gas characteristic sequence {x}. fused The long-term average or median of the calculated rate of change sequence {r(t)} represents the "normal" level of change. During initialization, the rate of change sequence can be calculated using data from an initial calibration period (e.g., the first 24 hours after startup), and its average can be used as the initial value of r0. σ r The standard deviation of the rate of change can be estimated online by sliding calculation based on the same historical rate of change data or by using its standard deviation to normalize (r(t)-r0) so that the adjustment is not affected by the absolute dimension of the rate of change; p is a power parameter that controls the effect of the rate of change deviating from the baseline to be nonlinear. When p>1, large rates of change will be further amplified to reduce the window effect. Typical values ​​are 1 (linear) or 2 (quadratic).

[0047] To ensure smooth window size changes and proactively respond to accelerations in the changing trend, the adaptive window size W(t) is calculated by combining the baseline window size with historical window sizes and acceleration information of the rate of change. The calculation formula is as follows: ; Where W(t-1) is the final window size used in the previous time step (at the initial time t=0, W(0) can be preset to W). min With W max (average) ρ is the second derivative of the rate of change r(t), i.e., acceleration, reflecting whether the rate of change itself is accelerating or decelerating. ρ is the inertia coefficient, ranging from [0,1], controlling the degree to which the current window size depends on the historical window size; the closer ρ is to 1, the smoother the window change, but the slower the response speed may be; ρ closer to 0 tends to W. base (t); typically ranges from 0.3 to 0.7. The acceleration sensitivity coefficient, whose sign and absolute value determine the direction and intensity of the effect of acceleration on window size; typically, when acceleration... When the value is positive (the rate of change is accelerating), it indicates that a more drastic change is imminent, and the window should be further reduced. It is usually taken as a negative value (e.g., on the order of −5 to −20).

[0048] To prevent windows calculated from W(t) from having insufficient information under extremely stable or abnormal conditions, a data information content index I(W) is introduced for verification; for the currently calculated window size W (i.e., W(t)), the information content index of the data within this window is calculated: ; Where, μ W and σ W These are the sequences {x} within the window [t−W+1,t]. fused (i)} means and standard deviation; I(W) is essentially a weighted average strength of the “meaningful fluctuations” in the data within the window; the higher the value of I(W), the richer the effective change information contained in the window.

[0049] Set an information threshold I th This threshold can be determined by analyzing the distribution of window information in historical data that effectively supports the identification and prediction tasks, for example, by taking the lower quartile of all historical window I(W) values; if I(W(t)) th If the current adaptive window information is insufficient, the window size needs to be reselected. The goal of reselection is to find a size within the allowed range [W]. min W max ​Within this range, the information content index I(W) can be maximized while minimizing the impact on the current window size W. current (i.e., the window size W of the difference between W(t)) new The calculation formula is as follows: ; Where, λ W To adjust the cost coefficient (a positive number), used to balance maximizing information content and the magnitude of window size change, λ W The larger the value, the more the algorithm tends to select a window size close to the current size, even if its information content may be slightly lower; a typical value can be adjusted experimentally, for example, 0.01×max(I(W)). Finally, the window size W used for feature extraction is determined. final (t), first calculate the baseline value; if no reselection is triggered, then W tmp =W(t); if a reselection is triggered, then W tmp =W new Then, it is rounded and bounded: ; Among them, [W] here tmp The ] indicates the rounding function. The max and min functions ensure that the final window size is between the preset minimum size (at least 1) and the maximum size W. max Positive integers between [a certain range].

[0050] In one embodiment of the present invention, step S2 involves dividing the gas feature sequence according to the adjusted window size and then inputting it into a shared feature extraction network for feature encoding, including the following steps: Based on the determined adaptive window size W final (t), from the fused gas characteristic sequence {x fused A cutoff length of W is taken from (t)} final (t) sequence fragments; the gas feature sequence fragments are input in parallel into a shared feature extraction network consisting of three parallel feature extraction sub-networks to extract spatial features, temporal features and time-frequency features respectively; among them, the spatial feature extraction sub-network consists of one-dimensional convolutional layers and is used to extract the spatial topological relationships between multiple sensors; The temporal feature extraction subnetwork consists of a bidirectional long short-term memory network and a temporal attention module. After processing the input gas feature sequence fragments, the bidirectional long short-term memory network outputs the hidden state at each time step, forming a hidden state sequence. Its temporal attention module is used to calculate the importance weight α of the feature at each time step. t The calculation formula is as follows: ; Among them, h tLet v and W be the hidden states at time t. a b a For learnable parameters, The length of the current gas feature sequence segment; using importance weight α t For the hidden state sequence {h t We perform weighted summation to obtain the weighted time series features; The time-frequency feature extraction subnetwork first converts the gas feature sequence into a time-frequency coefficient matrix through dual-tree complex wavelet transform, and then uses a two-dimensional convolutional network to extract multi-scale time-frequency features from it; Spatial features, weighted temporal features, and time-frequency features are concatenated and then nonlinearly fused and dimensionality reduced through a fully connected layer, outputting a shared feature vector h. shared .

[0051] Specifically, based on the final determined adaptive window size W final (t) (i.e., the length of the feature sequence fragment), from the fused gas feature sequence {x fused In (t)}, the cut-off length is W. final The characteristic sequence segment of (t) consists of W backwards from the current time t. final The data consists of (t) consecutive time points, i.e., the feature sequence segment X. t : ; This sequence fragment X t It is a one-dimensional vector with length W. final (t). The shared feature extraction network consists of three parallel subnetworks that simultaneously process the same input feature sequence fragment X. t Spatial features, temporal features, and time-frequency features are extracted respectively.

[0052] The spatial feature extraction subnetwork is used to extract spatial dependencies and topological patterns among multi-sensor network nodes from the fused time-series data. These spatial dependencies and topological patterns refer to specific correlations between concentration time-series data measured by sensors at different physical locations as gas diffuses in space. Examples include synchronous changes, delayed responses, and intensity gradients. These patterns implicitly reflect the spatial layout of the sensors and the gas diffusion path. Although the feature sequence fragment X... t It is a weighted and fused one-dimensional vector, but each data point is formed by fusing readings from multiple spatially distributed sensors, thus the sequence implicitly contains spatial correlation information from the original sensors. To extract this information from the one-dimensional sequence, this sub-network uses a one-dimensional convolutional layer for processing. Specifically, the feature sequence fragment X... tThe network is directly input into a single layer of one-dimensional convolutional layers. These one-dimensional convolutional kernels slide along the time dimension, learning different local temporal patterns through training. The weight update process of each kernel allows it to capture features in the fused data that characterize specific spatial relationships. For example, one kernel might strongly respond to patterns representing synchronous changes between sensors, while another might be sensitive to patterns representing the time delay required for a signal to propagate from one type of sensor location to another. These learned patterns indirectly encode the spatial topology and connectivity of the sensor network. A typical implementation uses 32 or 64 one-dimensional convolutional kernels, with kernel sizes of 3 or 5, ReLU activation, and can add max-pooling layers for downsampling. After several layers of one-dimensional convolution and nonlinear transformations, the final feature map is flattened into a one-dimensional vector, denoted as F. spatial , which serves as the extracted spatial feature vector.

[0053] The temporal feature extraction subnetwork consists of a bidirectional long short-term memory network (Bi-LSTM) and a temporal attention module, used to capture the long-term temporal dependence and dynamic evolution patterns of gas concentration sequences. The specific implementation process is as follows: The feature sequence fragment X... t The input is fed into a bidirectional LSTM layer. The Bi-LSTM consists of two LSTMs, a forward LSTM and a backward LSTM, processing data from the beginning to the end of the sequence and from the end to the beginning, respectively. The LSTM contains hidden state dimensions, for example, 128. The Bi-LSTM terminates at each time step. Output a hidden state h that incorporates both forward and backward information. t Input the hidden state sequence output by Bi-LSTM into the temporal attention module. , The length of the current gas feature sequence segment; the hidden state h at each time step. t Calculate a scalar importance weight α t This indicates the importance of the features at that moment to the current task (gas identification and concentration prediction); the calculation formula is: ; in, Let d be the hidden state of the Bi-LSTM at time step t. h It is a hidden state dimension; A learnable weight matrix used to map the hidden state to a d a The intermediate representation of a dimension; It is a learnable bias vector; The learnable weight vector is used to scalarize this intermediate representation to obtain an unnormalized attention score; d aThe dimension of the attention mechanism is a hyperparameter, for example, set to 64; the calculated weights α are used. t By performing a weighted summation on the hidden state sequence, a temporal feature vector focusing on key time information is obtained. .

[0054] The time-frequency feature extraction subnetwork is used to analyze the energy distribution of gas concentration sequences at different time and frequency scales to detect periodic patterns, transient events, or anomalies in specific frequency bands. The specific implementation process involves: processing the feature sequence segment X... t Perform dual-tree complex wavelet transform (DTCWT). DTCWT has approximately translation invariance and good direction selectivity, and can generate complex coefficients; perform J-level decomposition (J is usually 3 to 5) to transform the length W... final The characteristic sequence segment X of (t) t The transformation yields a series of complex wavelet coefficients, which are organized into a two-dimensional time-frequency coefficient matrix according to scale (frequency) and location (time). Where Y is the number of time positions; its rows correspond to different scales (frequency bands), and its columns correspond to different time positions; the matrix elements are complex numbers; subsequently, the complex matrix M... tf Convert to two real matrices: amplitude spectrum matrix A = |M tf | and phase spectrum matrix This is used as two input channels; the matrices of these two channels are then input into a lightweight two-dimensional convolutional neural network (2D-CNN); a typical 2D-CNN structure contains 1-2 convolutional layers, with the convolutional kernels sliding along both the scale (frequency) and time dimensions to learn local time-frequency patterns, followed by a ReLU activation function and a max-pooling layer after each layer; finally, the feature map output by the 2D-CNN is flattened into a one-dimensional vector, denoted as F. time-freq , which is used as the extracted time-frequency feature vector.

[0055] The feature vectors extracted by the three parallel sub-networks are concatenated to obtain a high-dimensional feature vector: ; The high-dimensional feature vector F concat The input is a fully connected layer (also known as a dense layer), which undergoes nonlinear transformation and dimension normalization. This fully connected layer introduces nonlinearity using an activation function (such as ReLU or tanh). Its output dimension is the predefined shared feature dimension d. shared (For example, 256 dimensions). The choice of dimension needs to strike a balance between representational power and model complexity. The role of this fully connected layer is to fuse multi-source feature information and compress it into a compact shared feature representation, ultimately obtaining a shared feature vector. This vector integrates information from multiple aspects of gas concentration data, including spatial correlation, temporal dynamics, and time-frequency distribution.

[0056] In one embodiment of the present invention, in step S2, based on the shared features output by the shared feature extraction network, synchronous reasoning is performed through parallel gas type identification branches and gas concentration prediction branches to output the identification result of the current gas type and the gas concentration prediction sequence for future periods, respectively, including the following steps: The gas type recognition branch receives the shared feature vector, outputs a classification probability distribution vector of the gas type through a fully connected network, and is trained using an adaptive focus loss function. The gas category with the highest probability value in the classification probability distribution vector is identified as the current gas type. The modulation factor γ in this loss function... k Based on the frequency of category samples and gas type, the uncertainty of branch prediction is dynamically adjusted: ; Where γ0 is the basic factor, v is the scaling factor, and N c N represents the number of samples for gas category c. total σ represents the total number of samples for all gas categories. c The standard deviation of the predicted probability of the gas type identification branch for that gas category; The gas concentration prediction branch, based on shared feature vectors, uses an encoder-decoder architecture to generate gas concentration prediction sequences for future time periods. Its training process introduces a physical constraint loss L on top of the traditional mean square error loss. physics The forced gas concentration prediction branch results conform to the physical laws of gas diffusion: ; Where o is the time step T in the gas concentration prediction sequence. f Index in The predicted concentration is output by the gas concentration prediction branch, u is the wind speed vector, F is the discrete diffusion-transmission operator based on the diffusion coefficient D and the wind speed vector u, and Δt is the prediction time step. The gas type identification branch and the gas concentration prediction branch are trained synchronously end-to-end through a multi-task joint loss function. The joint loss is a weighted sum of the losses of each task, and the gradient projection mechanism intervenes when a conflict is detected between the gradients of the loss functions of each task on the shared parameters.

[0057] Specifically, the input to the gas type recognition branch is the shared feature vector output by the shared feature extraction network. This branch typically consists of one or more fully connected layers (also known as dense layers). Each fully connected layer performs a linear transformation and non-linear activation on its input: first, a linear mapping is performed using a learnable weight matrix and bias vector, followed by the introduction of non-linearity through an activation function (such as ReLU or tanh); the final layer uses the Softmax activation function, and its number of neurons is consistent with the number of gas categories C to be identified. Specifically, the network will h shared As input, features are extracted and combined step by step through forward propagation, and finally a C-dimensional classification probability distribution vector π=[π1,π2,…,π] is output. C ], where each π c This represents the probability that the gas type recognition branch determines the current input to belong to gas type c, and satisfies the following conditions: The gas type identification branch identifies the gas category with the highest probability. The identification result (i.e., the gas category label) and the corresponding confidence level (i.e., the maximum probability value) These factors together constitute the identification result of the current gas type.

[0058] In the training phase of the gas type recognition branch, to address the issues of imbalanced sample sizes for different gas categories (few samples of certain gas leaks) and varying prediction confidence levels for each category, an improved adaptive focus loss function is employed. This loss function, based on the standard cross-entropy loss, introduces a dynamically adjusted modulation factor γ. c For a training sample (i.e., a feature sequence fragment X) in the gas type recognition branch. t ), its loss L cls Defined as: ; in, These are real category labels. It is an indicator function (when) =1 when =c, otherwise 0). The core lies in the modulation factor γ. c Calculation: ; Among them, γ0 is the basic modulation factor, a positive hyperparameter that controls the gas type recognition branch's response to easily classifiable samples (p). c The degree of attention reduction close to 1), typically ranging from 0.5 to 3.0, for example, 2.0; ν is a scaling factor used to adjust the sample frequency and the uncertainty term relative to γ. c The total influence intensity typically ranges from 0.1 to 1.0; N c The training dataset represents the number of samples for gas category c in the training dataset. The training dataset refers to the collection of historical gas concentration sequence fragments used to train the gas type recognition branch, and a sample refers to one of these fragments; Ntotal The total number of samples for all gas categories in the training dataset; This reflects the rarity of gas category c; the fewer the samples, the larger this value, thus assigning a larger γ value to rarer categories. c This forces the gas type identification branch to focus more on rare samples that are difficult to classify; σ c Let p be the standard deviation of the gas type identification branch's prediction probability for gas category c; this standard deviation is the prediction probability p of the gas type identification branch for all samples belonging to gas category c within a training batch or a sliding time window. c Calculated.

[0059] This adaptive mechanism dynamically adjusts the "focus" of the loss function for each gas category; for categories with few samples (rare) and unstable (uncertain) gas type identification branch predictions, a larger γ is assigned. c This significantly increases its weight in the total loss, thereby more effectively mitigating class imbalance and improving the model's ability to learn difficult and uncertain classes.

[0060] The input to the gas concentration prediction branch is also the shared feature vector h. shared This branch employs an encoder-decoder architecture; the encoder typically consists of one or more fully connected layers used to convert h... shared The mapping is to a context vector; the decoder is typically a recurrent neural network (such as LSTM or GRU) or a temporal convolutional network, which uses the context vector as the initial state and iterates step by step according to time steps to gradually generate the future T. f Gas concentration prediction sequence at each time step .

[0061] In the training of the gas concentration prediction branch, to ensure that the prediction results fit the data and conform to basic physical laws (such as the mass conservation and diffusion effect of gas diffusion), a physical constraint term L is introduced into the training loss. physics This loss term mandates that the predicted concentration sequence approximately satisfy a simplified gas diffusion physics model over time. Its calculation formula is as follows: ; Where o is the time step T in the gas concentration prediction sequence. f Index in; Δt is the predicted concentration value at the 0th time step in the future, output by the decoder; Δt is the time step size of the predicted sequence (in seconds), typically related to the data sampling period T. s Related or identical; Discrete diffusion-output operators based on diffusion coefficient D and wind speed vector v; for example, in a simplified two-dimensional uniform grid diffusion model, F can be expressed as: ; in, It is the discrete Laplace operator (computing the second-order difference in space and simulating diffusion). It is a discrete gradient operator (simulating advection transport); in practical applications, if spatial information is limited, a one-dimensional or point source diffusion model can be used for simplification; the diffusion coefficient D (unit: m² / s) is obtained from a preset gas property database (built by collecting authoritative gas property data offline, such as the NIST chemical database, EPA gas property tables, industry safety data tables, etc.) based on the identified gas type. This database contains the diffusion coefficients of common gases under standard conditions (such as 25°C, 1 atm), with a typical value range of approximately 10. -6 Up to 10 -4 m² / s; the wind speed vector u is provided by real-time measurements from wind speed sensors in the auxiliary environmental sensor network.

[0062] The total training loss L of the gas concentration prediction branch reg The weighted sum of data fitting loss and physical constraint loss: ; in, It is the predicted sequence and the actual future concentration sequence The mean square error between them; λ phy It is the weighting coefficient of the physical constraint term, used to balance data fit and physical consistency. The typical value is between 0.01 and 0.5, and it is determined through cross-validation.

[0063] The entire model (shared feature extraction network, gas type identification branch, and gas concentration prediction branch) is trained end-to-end synchronously using a multi-task joint loss function; this joint loss is a weighted sum of the losses from the two tasks: ; Among them, w cls and w reg These are task weights, which can be fixed hyperparameters (e.g., all set to 1.0) or dynamically adjusted based on task difficulty or uncertainty.

[0064] During the backpropagation process of the entire model training, the gradients of the loss functions of different tasks (i.e., gas type identification and concentration prediction) with respect to shared parameters (i.e., parameters of the shared feature extraction network) will conflict (in opposite directions), leading to optimization difficulties. A gradient projection mechanism is introduced to intervene. In each training batch, the classification task loss L is calculated using the automatic differentiation (Autograd) technique through the backpropagation algorithm. cls and regression task loss L reggradient vector g with the same shared parameters cls and g reg Specifically, following the chain rule, the gradient is calculated layer by layer from the loss function until the parameters of the shared feature extraction network are reached. The cosine similarity between the two gradients is then calculated. If cos(θ) < 0 (i.e., the included angle is greater than 90 degrees), it indicates a gradient direction conflict. When a conflict is detected, one of the gradients (e.g., g) is shifted... reg Projected onto another gradient (g) cls In the direction of the normal plane, to eliminate conflicting components; the projection formula is: Then use the processed gradient (e.g., g) cls and the regression gradient after projection The shared parameters (i.e., the weights and biases of the shared feature extraction network) are updated using a gradient. For branch parameters unique to each task (such as parameters in the gas type identification branch and gas concentration prediction branch that are not included in the shared feature extraction network), their original gradients are used directly for updating.

[0065] In one embodiment of the present invention, step S3 includes the following steps: Based on real-time environmental parameters and leakage source parameters, the physical model prediction sequence for future periods is obtained by solving the gas diffusion physical model. The leakage source parameters are estimated in real time based on sensor observation data through a Bayesian inversion framework. The first uncertainty of the gas concentration prediction sequence is obtained by quantification using uncertainty estimation methods. The second uncertainty of the physical model predicts the sequence. This includes model simplification error, parameter estimation error, and numerical discretization error; The dynamic confidence level τ of the gas concentration prediction sequence is obtained based on the first and second uncertainties. ML The dynamic confidence τ of the sequence predicted by the physical model phys The calculation formula is as follows: ; ; Where, μ ML and μ phys These are the mean values ​​of the gas concentration prediction sequence and the physical model prediction sequence, respectively. ML Fidelity is a measure of the consistency between gas concentration prediction sequences and their historical observations within a time window. phys α and β represent the degree of agreement between the physical model of gas diffusion and fundamental physical laws, respectively. It is a small constant; Based on the dynamic confidence levels of the two prediction sequences, an adaptive weighted fusion method is used to fuse and correct the two prediction sequences, generating a physically constrained corrected gas concentration prediction result.

[0066] Among them, the fusion weight q>1 is the sharpening parameter.

[0067] Specifically, to construct a prediction independent of the data-driven model, serving as a benchmark and physical constraint for subsequent fusion correction, it is necessary to generate a physical model prediction sequence using the physical laws of gas diffusion. A parameterized gas diffusion physical model is employed, such as a Gaussian plume model or a simplified version of computational fluid dynamics (CFD). The core input parameters of this model include two categories: one is real-time environmental parameters measured in real-time by auxiliary sensors, such as wind speed vector u(t), wind direction, and ambient temperature T. amb (t) and atmospheric stability category, etc.; secondly, leakage source parameters that are usually unknown and need to be estimated in real time, mainly including the location of the leakage source s=(x s ,y s ,z s Leakage rate Q s (Mass or volumetric flow rate) and leakage initiation time t0.

[0068] To achieve real-time estimation of leakage source parameters, a sequential Bayesian inversion framework (such as a particle filter or an extended Kalman filter) is employed. First, a state vector θ(t) = [s, Q] containing the unknown parameters to be estimated is defined. s [,t0,…]; The observation data are the historical and current sensor data (i.e., the fused sequence x) upon which the gas concentration prediction branch is based. fused The fusion sequence z(t) is a part of the physical model U, which serves as the observation equation. Given real-time environmental parameters (wind speed, temperature, etc.) and the state vector θ(t), the theoretical concentration values ​​at each sensor location can be calculated. Assuming the observation error follows a Gaussian distribution with zero mean and covariance matrix R, its likelihood function is: ; Based on prior knowledge (such as uniform or Gaussian distributions of equipment location and pipeline pressure), the posterior probability distribution is updated using Bayes' theorem: Finally, using algorithms such as particle filters, the statistics (such as expected or maximum a posteriori estimates) of the posterior probability distribution are calculated to obtain the best estimates of the leakage source parameters. .

[0069] Real-time environmental parameters and obtained leak source parameters Input into the gas diffusion physics model U to calculate the future T f At this moment (T here) f Consistent with the output length of the gas concentration prediction branch (representing the total number of time steps for future predictions), the concentration values ​​in the region of interest (such as the average point of the sensor network coverage area or a specified location) form the physical model prediction sequence: ; First uncertainty of gas concentration prediction sequence (machine learning) The uncertainty primarily stems from the prediction variance inherent in the machine learning model itself, including model parameter uncertainty (such as parameter distribution uncertainty introduced by random initialization, insufficient training iterations, or regularization) and noise inherent in the training data (such as sensor measurement noise and calibration errors). A typical method for estimating uncertainty using deep learning is the Monte Carlo Dropout method for quantification. During the inference phase, the activation states of all Dropout layers within the gas concentration prediction branch (and the shared feature extraction network) are maintained, and Z random forward propagations (e.g., Z=30) are performed to obtain a sample set of Z future concentration prediction sequences. For each time t+l within the future prediction period (l is the index of the future time step, l=1,2,…,T),... f ), calculate the variance of the predicted values ​​of these Z samples at that time, and use it as the prediction variance at that time. Uncertainty of the entire predicted sequence The average of the prediction variances over all time points can be taken, and the corresponding mean of the prediction sequence is denoted as: ; Second uncertainty of the physical model predicts the sequence It is a comprehensive reflection of model simplification error, parameter estimation error, and numerical discretization error. Model simplification error Because physical models approximate real complex diffusion processes (e.g., assuming uniform wind fields and steady-state conditions), an empirical constant or condition-dependent function can be calibrated offline by comparing model predictions with high-fidelity computational fluid dynamics (CFD) simulations or historical high-precision observation data under various typical scenarios. Parameter estimation error Derived from leak source parameter estimates The uncertainty can be directly calculated from the covariance matrix of the parameter estimates from the posterior probability distribution obtained by Bayesian inversion, and then mapped to the variance of the concentration prediction through first-order error propagation analysis. Numerical discrete error Introduced by the numerical methods used in solving the physical model (such as the finite difference method and integral approximation), its magnitude is related to the model's grid resolution, time step, and other settings, and can be estimated a priori based on numerical analysis theory (such as truncation error analysis). The total uncertainty of the physical model's predicted sequence can be approximated as the sum of squares of the aforementioned independent error sources: ; The mean of its corresponding predicted sequence is denoted as: ; Based on the first uncertainty Second uncertainty The dynamic confidence level τ of the gas concentration prediction sequence is obtained. ML The dynamic confidence τ of the sequence predicted by the physical model phys The calculation formula is as follows: ; ; in, It is an approximation of the square of the coefficient of variation, which measures the relative uncertainty of the prediction; It is a very small constant (e.g., 10) -6 ), to prevent division from becoming unstable when μ is close to zero; The larger the value, the less reliable the prediction. or Both are monotonically decreasing functions that map relative uncertainty to the interval [0,1]. The greater the uncertainty, the smaller the value of the exponential term. α and β are adjustment coefficients that control the strength of the influence of uncertainty on the decay of confidence, typically ranging from 0.5 to 5.0. For example, if there is relative confidence in the physical model, β < α can be set. ML Machine learning predicts sequences based on their recent history (such as past W). v (Number of points) Observation data z hist The consistency measure is calculated using the following formula: ; in It is the mean of the posterior predictions (or retrospective predictions) of the entire multi-task learning model (including the gas concentration prediction branch) described in claim 5 for the same historical period, where NMSE is the normalized mean square error and γ is the scaling factor; Consistency ML The closer a value is to 1, the better the multi-task learning model fits the past, and the more reliable its future predictions are.

[0070] Fidelity physThe degree of conformity between the physical model and fundamental physical laws is a static or slowly varying factor based on prior knowledge, used to quantify the applicability of the physical model under current environmental conditions. In this implementation case, Fidelity... phys The calculation comprehensively considers the impact of key environmental parameters such as wind speed and temperature gradient on the model's applicability. The calculation formula is as follows: ; Where v(t) is the wind speed at the current moment, measured in real time by a wind speed sensor, in m / s; v max The maximum wind speed threshold applicable to the physical model is set to 10 m / s; The current temperature gradient is calculated by the temperature sensor array, in °C / m. The maximum temperature gradient threshold applicable to the physical model is set to 5°C / m; a practical application example of its formula is: when the wind speed v(t) = 8 m / s, the temperature gradient... When =3°C / m: ; When environmental parameters exceed the model's applicable range, Fidelity phys The value decreases, and the weights of the physical model are reduced accordingly in the fusion correction. For example, when v(t) > 15 m / s (extreme turbulence) and At >8°C / m (strong temperature inversion), Fidelity phys It can be reduced to below 0.2; in addition, Fidelity phys It may also include checking the reasonableness of the parameter inversion results, such as the leakage rate. Physical probability assessment, if the estimated leakage rate is Beyond the physically reasonable range (e.g.) <0 or Q max =100kg / s is the system's preset maximum possible leakage rate), then for Fidelity phys Multiply by the attenuation factor of 0.5.

[0071] Final output τ ML and τ phys Two dynamic scalars between 0 and 1 represent the dynamic confidence in the machine learning prediction sequence (also the gas concentration prediction sequence) and the physical model prediction sequence, respectively.

[0072] Based on dynamic confidence levels, the two predicted sequences are intelligently fused into a more reliable correction result. The fusion formula is as follows: ; Among them, c corr(t+1) is the corrected concentration prediction value at time n; fusion weight w ML Determined by dynamic trust level: q is the sharpening parameter, a constant greater than 1 (typical values ​​such as q=2, 3, 5), which amplifies the difference between two confidence levels. When q is large, the prediction with the higher confidence level will dominate the fusion; when q is close to 1, the fusion is smoother. For each future prediction time t+l (l=1,2,…,T) f By applying a fusion formula, the final sequence of predicted gas concentrations, corrected for physical constraints, is generated. ; In one embodiment of the present invention, step S4 includes the following steps: Based on the identified gas type, a predefined gas hazard attribute mapping relationship is queried to determine its inherent hazard feature vector H. g Based on the gas concentration prediction results after physical constraint correction, the current concentration risk ratio is calculated. Predicted peak risk ratio Predicting cumulative threshold exceedance: ; Among them, c curr c represents the current gas concentration. pred (t+1) represents the predicted concentration at the l-th future time, C thr (g) and C safe (g) represents the hazard threshold and safety threshold for gas g, respectively, and T represents the hazard threshold and safety threshold for gas g. f To predict the duration, a comprehensive risk baseline value is then calculated: ; Where w is the weight vector of the hazard dimension, and α1, α2, and α3 are the weight coefficients of the concentration risk term; Extract the average rate of change from the future trend of gas concentration prediction results. rate of change acceleration and the proportion of time exceeding the threshold P over And based on these trend characteristics, calculate the dynamic risk correction factor F. trend : ; Where β1, β2, and β3 are adjustment coefficients, and γ1 and γ2 are scaling factors; Based on the comprehensive risk base value R base and dynamic risk correction factor F trend Calculate the final risk score The final risk score is mapped to discrete risk levels based on a preset threshold range [θ1, θ2, θ3]; and based on the risk level and average rate of change... and rate of change acceleration By using predefined hierarchical triggering rules, the corresponding hierarchical warning and control command combinations are selected and executed.

[0073] Specifically, a local data table is predefined to store the inherent hazard properties and safety thresholds of gases. This data table is constructed by collecting authoritative gas property data and safety standards offline. Data sources include, but are not limited to, Chemical Safety Data Sheets (SDS) and Occupational Exposure Limits (OELs) in occupational health standards (such as GBZ 2.1). The data table is indexed by gas type g, and each record contains at least the following fields: gas name or unique identifier, toxicity hazard coefficient, flammability / explosiveness hazard coefficient, environmental persistence or diffusion coefficient, cumulative health effect coefficient, hazard threshold, and safety threshold. For each potentially identifiable gas g, based on its physicochemical properties and safety standards, multiple dimensions of inherent hazard characteristics are quantified to form a vector defining the inherent hazard properties of the gas. ; d represents the number of dimensions of the hazard attribute, a positive integer. Its specific value depends on the definition of the gas's hazardous characteristics. For example, a hazard attribute might be divided into four dimensions: toxicity, flammability, environmental persistence, and cumulative health effects. A typical example of a characteristic dimension (d=4): toxicity hazard coefficient h. g1 For example, normalization can be performed by referring to the reciprocal of IDLH (immediately life-threatening concentration) or TLV (threshold value); the higher the value, the stronger the toxicity; flammability / explosiveness hazard factor h g2 For example, normalization can be performed based on the reciprocal of the lower explosive limit (LEL) or the maximum explosive pressure; environmental persistence or diffusion coefficient h g3 For example, assessing retention risk based on gas density (heavy or light gas) and atmospheric degradation half-life; health cumulative effect coefficient h g4 Higher values ​​are assigned to gases with cumulative toxicity. These coefficients typically take values ​​in the range (0, 10], determined empirically or by formula calculation by consulting Safety Data Sheets (SDS) and industry standards (such as NFPA 704); for example, for chlorine (highly toxic), its h... g1 It is 9.5; for methane (flammable but low toxicity), its h g2 It is 8.0, h g1 It is 1.0.

[0074] Based on current and predicted gas concentrations, calculate the concentration risk index: current concentration risk ratio R. curr The calculation formula is: ; Among them, c curr The physical constraint-corrected gas concentration at the current moment (i.e., c) curr (t);C thr (g) is the hazard threshold for gas g, typically taken as the occupational exposure limit (such as the short-term exposure limit (STEL) in OELs) or the alarm threshold; when R curr A value ≥1 indicates that the current concentration has exceeded the safety limit. Predicted peak risk ratio R peak The calculation formula is: ; in, For the future forecast period T f Internally, the concentration prediction sequence c after physical constraint correction corr The maximum value in the range; this indicator assesses the worst-case scenario that may be reached in the future. Predicted cumulative over-threshold amount S a The calculation formula is: ; Among them, C safe (g) is the safety threshold for gas g, which is usually lower than C. thr (g), for example, the acceptable time-weighted average allowable concentration (TWA); S a The "dose" or cumulative exposure to concentrations exceeding safe levels during the predicted future period was calculated to assess chronic or cumulative hazards. thr (g) and C safe (g) is derived from mandatory industry standards (such as GBZ 2.1, OSHA standards) or internal enterprise safety procedures and is pre-stored in a local data table associated with the gas type g.

[0075] Finally, calculate the comprehensive risk base value R. base The calculation formula is: ; in, This is a hazard dimension weight vector used to adjust the relative importance of different hazard attributes (toxicity, flammability, explosiveness, etc.) in the total risk. It is usually pre-set according to the safety strategy of the application scenario to meet the following requirements. For example, within chemical industrial parks, toxicity is emphasized (w1 is higher); around gas stations, flammability and explosiveness are emphasized (w2 is higher). α1, α2, and α3 are weighting coefficients for the concentration risk term, reflecting different levels of concern regarding current, peak, and cumulative risks. Typically, α1 + α2 + α3 = 1 is satisfied; typical values ​​could be α1 = 0.4 (emphasizing current risk), α2 = 0.4 (emphasizing peak risk), and α3 = 0.2 (considering cumulative risk). R baseIt is a dimensionless number. The larger the value, the higher the baseline risk, which is determined by both the inherent hazard of the gas and the predicted concentration level.

[0076] Based on the predicted future trend of concentration, the comprehensive risk baseline R base Dynamic corrections should be made. Rapidly deteriorating trends should amplify the risk. Extract the corrected concentration prediction sequence {c}. corr Future trend characteristics of}: its average rate of change Calculate the future prediction sequence c corr The linear slope or the average change per unit time. Indicates an expected increase in gas concentration; rate of change acceleration. Calculate the first-order difference mean of the rate of change of the future predicted sequence, or directly fit the second derivative. This indicates that the gas concentration is rising rapidly; the proportion of time exceeding the threshold, P. over For, calculate the future T f At any given time, the predicted concentration exceeds C. thr The proportion of time in (g) .

[0077] The dynamic risk correction factor F was then calculated. trend : ; Where, sigmoid = 1 / (1+e -x ) rate of change Mapped to the interval (0,1); when When it is very large, this term approaches β1; when When the value is negative (concentration decreases), this term approaches 0, meaning it does not increase the risk. tanh(x) will accelerate... Map to the interval (-1, 1); When >0, This increases the risk; When the value is less than 0, this item is negative, slightly reducing the risk and reflecting a mitigating trend. β1, β2, and β3 are adjustment coefficients, controlling the contribution of the average rate of change, acceleration, and the proportion exceeding the threshold to risk correction, respectively; typical values ​​range from 0.1 to 0.5. For example, if special attention is paid to rapid increases, β1=0.3, β2=0.4, and β3=0.2 can be set. γ1 and γ2 are scaling factors used to adjust the input. and The speed at which the sigmoid / tanh function enters the saturation region (the region where the sigmoid / tanh function changes smoothly); typical values ​​can be obtained by analyzing historical data. (recorded as) )and The standard deviation is normalized to around 1 to determine the standard deviation, for example. The final output is F.trend ≥1. The worse the trend (rapid rise, acceleration, long-term exceeding of the threshold), the higher the F value. trend The larger it is, the higher it can reach approximately 1+β1+β2+β3.

[0078] Final Risk Score It integrates gas properties, concentration levels, and trends; it presets risk threshold ranges [θ1, θ2, θ3], where 0 < θ1 < θ2 < θ3; these thresholds are determined through statistical analysis of historical accident data, risk assessment models (such as FMEA), or experience. For example: Low risk (Level I): 0 ≤ R total <θ1 (e.g., θ1=1.0); Medium risk (Level II): θ1≤R total <θ2 (e.g., θ2=3.0); High risk (Level III): θ2≤R total <θ3 (e.g., θ3=8.0); Extremely high risk (Level IV): R total ≥θ3.

[0079] Establish a tiered trigger rule table, whose inputs are risk level and key trend characteristics (such as...). and The output is a combination of commands to be executed, indicating the risk level (positive or negative). Different levels and ranges of alarms are triggered based on the risk level; for example, Level I: Local device indicator lights flash; Level II: Audible and visual alarms activate, sending a text message to the area manager; Level III: Plant-wide broadcast alarm, sending an alarm to the emergency response team and higher management; Level IV: Activation of public emergency broadcast, contacting government emergency departments. Control commands include automatic control and suggested commands; if the system deployed using the method is interlocked with an industrial control system (such as DCS, PLC), automatic control can be executed, such as turning on / increasing the ventilation system (VAV), activating the water curtain or sprinkler system near the leak source, closing upstream valves, or cutting off power; suggested commands provide operational suggestions, such as personnel evacuation routes, recommendations on the protection level of rescue personnel, fire preparedness, etc. An example of triggering logic: The weak risk level is II, and... >0 (concentration increases), triggering instructions include activating audible and visual alarms, sending warning messages, and advising inspection personnel to carry portable detectors to the relevant area for confirmation.

[0080] In one embodiment of the present invention, step S5 includes the following steps: An online incremental learning framework is established for the shared feature extraction network, gas type identification branch, and gas concentration prediction branch. When updating parameters using new time-series data, this framework introduces elastic weight consolidation constraints, and its incremental loss function is: ; Among them, L newThe loss calculated based on the new data, F represents the model parameters saved before fine-tuning. d λ represents the diagonal element of the Fisher information matrix estimated online, λ is the consolidation strength coefficient, and r is the index of the model parameters; the model parameters include trainable parameters in the shared feature extraction network, the gas type identification branch, and the gas concentration prediction branch; The risk level information is quantified into a continuous penalty signal r. risk (t), and quantify the execution effect of the control command into an evaluation value E(a). t ,t+Δ), combining the two to construct the dominance function in reinforcement learning ; Based on the advantage function, a trust region strategy optimization method is adopted to maximize the expected advantage and guide the update of model parameters under the constraint of KL divergence of the output distributions of the old and new models. During the update process, for the two tasks of gas identification and concentration prediction, the uncertainty u of their online prediction is considered. cls (t) and u reg (t), dynamically adjust its weight w in the joint fine-tuning loss. cls (t) and w reg (t), and perform gradient surgery based on gradient cosine similarity; The update process is dynamically triggered based on real-time calculated validation loss and parameter drift metrics, and a self-supervised loss incorporating knowledge distillation from the old model is employed.

[0081] Specifically, based on the newly acquired time-series data, risk level, and execution effect information of control commands, the parameters of the shared feature extraction network, gas type identification branch, and gas concentration prediction branch (the parameters of all models are collectively referred to as model parameters) are jointly fine-tuned and adaptively updated.

[0082] The newly collected time-series data, the corresponding risk levels, and the environmental feedback after the execution of control commands (such as subsequent concentration changes) constitute a new online learning sample set D. online The goal of online learning is to minimize the incremental loss function: ; Among them, L new The loss for new data is calculated using the same method as the multi-task joint loss function L. total Same, but using only newly collected online data D online Perform calculations, that is ; θ r It is the r-th element of all trainable parameters in the current model (shared feature extraction network, gas type identification branch, and gas concentration prediction branch); The model parameters before fine-tuning are obtained by backing up all parameters θ of the current model before starting an online update cycle. λ is the consolidation strength coefficient, used to control the degree of retention of old knowledge; its typical value range is... When the value is small (e.g., 0.1-1), the model tends to adapt to new data; when the value is large (e.g., 10-100), the model tends to retain existing knowledge. r The diagonal elements of the Fisher information matrix estimated online are used to measure the parameter θ. r For the learned task (gas identification and concentration prediction on historical data), parameters with high importance should be kept as constant as possible during updates; use historical data D retained within a sliding window. old (i.e., a set of historical gas concentration sequence fragments and their labels, such as data that has not been updated in the most recent hour) to calculate F r The specific calculation process is as follows: From D old A small batch (mini-batch) of data B is randomly sampled from the dataset. The batch size is denoted as B. M Fix the current model parameters to (i.e., the parameters before fine-tuning), for each sample x in B i Perform forward propagation to obtain the prediction results, and calculate the loss value L on the multi-task joint loss function. old (x i The loss function L is calculated using the backpropagation algorithm. old For each parameter θ r gradient For each parameter θ r Calculate the mean of the squared gradient over the mini-batch B: ; If an online moving average method is used, the diagonal elements are updated according to its formula: ; Where η is the smoothing coefficient (usually between 0.01 and 0.1), used to balance historical information with new batch information; repeat the above steps until D is traversed. old All data (or up to the preset number of iterations) are used to obtain a stable diagonal element estimate F. r .

[0083] In the online learning framework, to transform closed-loop feedback (changes in risk level, actual effects of control commands) into quantifiable signals that can guide model parameter optimization, a dominance function from reinforcement learning is constructed. This function is used to evaluate the quality of control commands triggered by model predictions, thereby guiding the model not only to fit the data but also to make predictions that reduce risk and improve control effectiveness. First, a risk penalty signal r is constructed.risk (t), this signal will calculate the continuous final risk score R in real time. total (t) is mapped to negative rewards (i.e., penalties), with higher risks resulting in greater penalties; a typical design uses a negative logarithmic form: ; Secondly, the quantitative control effect evaluation value E(a) t ,t+Δ), this value is used to evaluate the execution of control command a at time t. t Then, the effect after Δ time is defined as the relative reduction in risk score before and after execution: ; Among them, R total (t+Δ) represents the risk score reassessed after time Δ. A very small constant is used to prevent division by zero; a positive E value indicates reduced risk (positive effect), while a negative value indicates increased risk or ineffective control. This is based on the risk penalty signal r. risk (t) and control effectiveness evaluation value E(a) t Construct the dominance function (t+Δ). The model's context information at the current time step (e.g., shared feature vector h) will be used. shared (t) is considered as the environmental "state" s t The triggered control command is regarded as an "action". t The formula for calculating the dominance function is: ; Where η is the control effect weighting coefficient, used to balance risk penalty and control effect reward, typically ranging from 0.5 to 2.0; V(s t The state-value function is approximated by a small, independent neural network (value function network) used to estimate the state s. t The expected long-term return, V(s) t It can be updated online through temporal difference (TD) learning. Advantage function. When positive, it indicates that the state-action pair is better than the average, and the model should be encouraged to make such predictions; when negative, it should be suppressed.

[0084] To leverage the feedback signal provided by the advantage function and update model parameters in a stable and controlled manner, thereby guiding predictions towards better outcomes (lower risk and more effective control), a trust region-based policy optimization method is employed for guided updates. The entire multi-task learning model is considered as a "policy" π. θIts input is sensor data, and its output is the probability of gas type identification and a future concentration prediction sequence (this sequence directly determines the risk level assessment and the generation of subsequent control instructions). The goal of strategy optimization is to maximize the expected advantage, i.e.: ; To avoid policy performance crashes or the forgetting of learned knowledge due to excessively large parameter update steps, a trust region policy optimization method is adopted. The core of this method is to constrain the difference in output distribution between the old and new policies, ensuring that each update is performed within a "trust region." Specifically, using online data D... online During the update, solve the constrained optimization problem: , The constraints are:

[0085] in, The parameters are the model parameters before the update; δ is the KL divergence constraint threshold, a small positive number (e.g., 0.01 or 0.05) used to control the update magnitude; in practical applications, constrained optimization problems are often solved efficiently using their approximation methods (such as the pruning objective function of proximal policy optimization, PPO). To consolidate existing knowledge when adapting to new data, the final online update objective function is the sum of the policy optimization objective and the incremental loss L. online The weighted combination of elasticity weight consolidation terms: ; Among them, L online For the incremental loss that includes elastic weight consolidation constraints; β θ It is an adjustment coefficient used to balance strategy improvement and loss minimization. Its typical value ranges from 0.1 to 1.0 and can be determined through cross-validation.

[0086] To ensure that the gas type identification and concentration prediction subtasks can dynamically allocate learning resources based on their performance in the current online environment during joint fine-tuning, and to effectively alleviate gradient conflicts between tasks, a dynamic task weight adjustment and gradient surgery mechanism is introduced. First, dynamic task weight adjustment is performed; this mechanism adaptively adjusts the weight of each task in the joint loss based on its prediction uncertainty on the current data. For the gas type identification task, its uncertainty u... cls (t) can be obtained by calculating the entropy of the probability distribution predicted by the model: Alternatively, the prediction variance under Monte Carlo Dropout can be used; for gas concentration prediction tasks, the uncertainty u reg (t) then uses the Monte Carlo Dropout method to calculate the prediction variance. The average value; based on these two uncertainty measures, the joint loss L for the two tasks.new The dynamic weights in the calculation are as follows: ; ; in It is a very small constant used to prevent division by zero; the principle of weight allocation is to assign lower loss weights to tasks with higher current uncertainty in order to avoid the model being overly disturbed by noisy data or unpredictable tasks, thereby balancing multi-task learning.

[0087] Secondly, gradient manipulation is performed to resolve gradient conflicts between tasks; when calculating the gradients of shared parameters (i.e., shared feature extraction network parameters) during backpropagation, the losses from the classification task are calculated separately. gradient g cls and losses from the regression mission gradient g reg Calculate the cosine similarity between these two gradients: ; If cos(θ) < 0 (i.e., the gradient direction conflict is greater than 90 degrees), then one of the gradients (such as g) will be changed. reg Projected onto another gradient (such as g) cls On the normal plane of ), to eliminate conflicting components; the projection correction formula is: ; Then, the corrected gradient (g) is used. cls and the corrected g reg The shared parameters are updated, while the original gradients are used to update the branch parameters unique to each task. This mechanism effectively alleviates the negative transfer problem caused by gradient inversion in multi-task learning, and enables the shared feature extraction network to learn a general feature representation that is beneficial to both tasks.

[0088] Updates are not performed at every time step, but are dynamically triggered based on the following metrics: On a fixed validation dataset D that has not been recently used for updates. val (For example, data from the past 24 hours, divided into hourly intervals) Calculate the loss L val ; Calculate the current parameter θ and the baseline parameter saved from the last update. Relative changes between A complete online update cycle is initiated when any one of the following conditions is met: L val The price rises above the threshold τ for several consecutive evaluation periods (e.g., 3). L (e.g., an increase of 10%), or Δ θ Exceeding the threshold τ θ (e.g., 5%), or the interval since the last update has exceeded the preset maximum interval T. max(e.g., 24 hours).

[0089] During the update process, in addition to the elastic weight consolidation loss, a knowledge distillation loss is also introduced, which enables the current model (student) to mimic the output of the old model (teacher) before the update, in order to retain its original generalization ability; this loss is defined as: ; The first term is the classification probability distribution vector π in gas type identification. old and π new The KL divergence between the two models, the second term being the gas concentration prediction sequence c generated by the old and new models. pred The mean squared error between them. This loss term will be added to L. online In, and through an adjustable hyperparameter λ distill (For example, values ​​ranging from 0.01 to 0.5) are weighted, and the coefficient gradually decays as the online learning process progresses.

[0090] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.

Claims

1. A gas identification and concentration prediction method based on multi-task learning, characterized in that, Includes the following steps: S1: Collect time-series data of the target gas through a multi-source sensor network, and use a dynamic weight allocation mechanism to fuse the time-series data to generate a fused gas feature sequence; S2: Based on the real-time change rate of the gas feature sequence, the window size for feature extraction is adaptively adjusted; the gas feature sequence is divided according to the adjusted window size and then input into a shared feature extraction network for feature encoding; based on the shared features output by the shared feature extraction network, synchronous reasoning is performed through parallel gas type identification branches and gas concentration prediction branches to output the identification result of the current gas type and the gas concentration prediction sequence for future periods, respectively. S3: The gas concentration prediction sequence for the future time period is fused and corrected with the calculation results based on the gas diffusion physics model to generate a gas concentration prediction result corrected by physical constraints. S4: Based on the gas type identification result and the gas concentration prediction result after physical constraint correction, assess the gas leakage risk level; based on the risk level and the future trend of gas concentration prediction results, trigger graded early warning and control commands. S5: Based on the new time-series data collected online, the risk level, and the execution effect information of the control instructions, the parameters of the shared feature extraction network, the gas type identification branch, and the gas concentration prediction branch are jointly fine-tuned and adaptively updated.

2. The gas identification and concentration prediction method based on multi-task learning according to claim 1, characterized in that, S1 includes the following steps: Construct a multi-source sensor network that includes various gas sensors and auxiliary environmental sensors to synchronously collect time-series concentration data of the target gas; For each time t, a comprehensive dynamic weight is calculated for each sensor, which incorporates the signal quality index Q based on the signal-to-noise ratio. i (t) Accuracy index A based on historical consistency i (t) and the inter-sensor correlation penalty term C used to suppress redundant information i (t); Comprehensive dynamic weight w i The formula for calculating (t) is: ; Where i and j are sensor indices, i,j=1,2,…,N, N is the total number of sensors, x i (t) represents the original measurement value of sensor i at time t, and α, β, and η are adjustment parameters; By utilizing integrated dynamic weights, time-series data from multiple sensors are fused to obtain the fused feature value x at time t. fused (t), generating the fused gas feature sequence {x fused (t)}: ; Where x i (t) represents the original measurement value of sensor i at time t.

3. The gas identification and concentration prediction method based on multi-task learning according to claim 1, characterized in that, In step S2, the data window size for feature extraction is adaptively adjusted based on the real-time rate of change of the gas feature sequence, including the following steps: Based on the fused gas feature sequence {x fused Calculate the real-time rate of change r(t) of the gas characteristic sequence: ; Among them, T s Where L is the sampling period and L is the initial window length; Based on the real-time rate of change r(t) of the gas feature sequence, the baseline window size W for feature extraction is calculated using a nonlinear inverse proportional function. base (t): ; Among them, W min and W max These are the preset minimum and maximum window sizes, respectively; m is the sensitivity coefficient; r0 is the baseline value of the rate of change; σ r This is an estimate of the standard deviation of the rate of change, where p is a power parameter; Set the reference window size W base By combining the window size and acceleration information of the rate of change of the previous time step (t), the adaptive window size W(t) for feature extraction is calculated: ; in, The inertia coefficient, Let r(t) be the second derivative of the rate of change. The acceleration sensitivity coefficient; For a given window size W, calculate the data information content index I(W) under that window size: ; Where, μ W and σ W These represent the gas characteristic sequences {x} within the window. fused The mean and standard deviation of (i)}; When I(W) is lower than the preset threshold I th At that time, reselect the window size W that maximizes the data information content index I(W) while minimizing the adjustment cost. new : ; Where λ W To adjust the cost coefficient, W current The currently used window size; Finally, the adaptive window size used for feature extraction was determined to be W. final If W(t) = W(t), then if a reselection is triggered, then W... final (t)=W new .

4. The gas identification and concentration prediction method based on multi-task learning according to claim 3, characterized in that, In step S2, the gas feature sequence is divided according to the adjusted window size and then input into a shared feature extraction network for feature encoding, including the following steps: Based on the determined adaptive window size W final (t), from the fused gas characteristic sequence {x fused A cutoff length of W is taken from (t)} final (t) sequence fragments; the gas feature sequence fragments are input in parallel into a shared feature extraction network consisting of three parallel feature extraction sub-networks to extract spatial features, temporal features and time-frequency features respectively; among them, the spatial feature extraction sub-network consists of one-dimensional convolutional layers and is used to extract the spatial topological relationships between multiple sensors; The temporal feature extraction subnetwork consists of a bidirectional long short-term memory network and a temporal attention module. After processing the input gas feature sequence fragments, the bidirectional long short-term memory network outputs the hidden state at each time step, forming a hidden state sequence. Its temporal attention module is used to calculate the importance weight α of the feature at each time step. t The calculation formula is as follows: ; Among them, h t Let v and W be the hidden states at time t. a b a For learnable parameters, The length of the current gas feature sequence segment; using importance weight α t For the hidden state sequence {h t We perform weighted summation to obtain the weighted time series features; The time-frequency feature extraction subnetwork first converts the gas feature sequence into a time-frequency coefficient matrix through dual-tree complex wavelet transform, and then uses a two-dimensional convolutional network to extract multi-scale time-frequency features from it; Spatial features, weighted temporal features, and time-frequency features are concatenated and then nonlinearly fused and dimensionality reduced through a fully connected layer, outputting a shared feature vector h. shared .

5. The gas identification and concentration prediction method based on multi-task learning according to claim 4, characterized in that, In step S2, based on the shared features output by the shared feature extraction network, synchronous reasoning is performed through parallel gas type identification branches and gas concentration prediction branches to output the identification result of the current gas type and the gas concentration prediction sequence for future periods, including the following steps: The gas type recognition branch receives the shared feature vector, outputs a classification probability distribution vector of the gas type through a fully connected network, and is trained using an adaptive focus loss function. The gas category with the highest probability value in the classification probability distribution vector is identified as the current gas type. The modulation factor γ in this loss function... k Based on the frequency of category samples and gas type, the uncertainty of branch prediction is dynamically adjusted: Where γ0 is the basic factor, v is the scaling factor, and N is the scaling factor. c N represents the number of samples for gas category c. total σ represents the total number of samples for all gas categories. c The standard deviation of the predicted probability of the gas type identification branch for that gas category; The gas concentration prediction branch, based on shared feature vectors, uses an encoder-decoder architecture to generate gas concentration prediction sequences for future time periods. Its training process introduces a physical constraint loss L on top of the traditional mean square error loss. physics The forced gas concentration prediction branch results conform to the physical laws of gas diffusion: ; Where o is the time step T in the gas concentration prediction sequence. f Index in The predicted concentration is output by the gas concentration prediction branch, u is the wind speed vector, F is the discrete diffusion-transmission operator based on the diffusion coefficient D and the wind speed vector u, and Δt is the prediction time step. The gas type identification branch and the gas concentration prediction branch are trained synchronously end-to-end through a multi-task joint loss function. The joint loss is a weighted sum of the losses of each task, and the gradient projection mechanism intervenes when a conflict is detected between the gradients of the loss functions of each task on the shared parameters.

6. The gas identification and concentration prediction method based on multi-task learning according to claim 1, characterized in that, S3 includes the following steps: Based on real-time environmental parameters and leakage source parameters, the physical model prediction sequence for future periods is obtained by solving the gas diffusion physical model. The leakage source parameters are estimated in real time based on sensor observation data through a Bayesian inversion framework. The first uncertainty of the gas concentration prediction sequence is obtained by quantification using uncertainty estimation methods. The second uncertainty of the physical model predicts the sequence. This includes model simplification error, parameter estimation error, and numerical discretization error; The dynamic confidence level τ of the gas concentration prediction sequence is obtained based on the first and second uncertainties. ML The dynamic confidence τ of the sequence predicted by the physical model phys The calculation formula is as follows: ; ; Where, μ ML and μ phys These are the mean values ​​of the gas concentration prediction sequence and the physical model prediction sequence, respectively. ML Fidelity is a measure of the consistency between gas concentration prediction sequences and their historical observations within a time window. phys α and β represent the degree of agreement between the physical model of gas diffusion and fundamental physical laws, respectively. It is a small constant; Based on the dynamic confidence levels of the two prediction sequences, an adaptive weighted fusion method is used to fuse and correct the two prediction sequences, generating a physically constrained corrected gas concentration prediction result. ; Among them, the fusion weight q>1 is the sharpening parameter.

7. The gas identification and concentration prediction method based on multi-task learning according to claim 1, characterized in that, S4 includes the following steps: Based on the identified gas type, a predefined gas hazard attribute mapping relationship is queried to determine its inherent hazard feature vector H. g Based on the gas concentration prediction results after physical constraint correction, the current concentration risk ratio is calculated: ; Predicted peak risk ratio: ; Predicting cumulative threshold exceedance: ; Among them, c curr c represents the current gas concentration. pred (t+1) represents the predicted concentration at the l-th future time, C thr (g) and C safe (g) represents the hazard threshold and safety threshold for gas g, respectively, and T represents the hazard threshold and safety threshold for gas g. f To predict the duration; and then calculate the comprehensive risk base value. ; Where w is the weight vector of the hazard dimension, and α1, α2, and α3 are the weight coefficients of the concentration risk term; Extract the average rate of change from the future trend of gas concentration prediction results. rate of change acceleration and the proportion of time exceeding the threshold P over And based on these trend characteristics, calculate the dynamic risk correction factor F. trend : ; Where β1, β2, and β3 are adjustment coefficients, and γ1 and γ2 are scaling factors; Based on the comprehensive risk base value R base and dynamic risk correction factor F trend Calculate the final risk score The final risk score is mapped to discrete risk levels based on a preset threshold range [θ1, θ2, θ3]; and based on the risk level and average rate of change... and rate of change acceleration By using predefined hierarchical triggering rules, the corresponding hierarchical warning and control command combinations are selected and executed.

8. The gas identification and concentration prediction method based on multi-task learning according to claim 1, characterized in that, S5 includes the following steps: An online incremental learning framework is established for the shared feature extraction network, gas type identification branch, and gas concentration prediction branch. When updating parameters using new time-series data, this framework introduces elastic weight consolidation constraints, and its incremental loss function is: ; Among them, L new The loss calculated based on the new data, F represents the model parameters saved before fine-tuning. d λ represents the diagonal element of the Fisher information matrix estimated online, λ is the consolidation strength coefficient, and r is the index of the model parameters; the model parameters include trainable parameters in the shared feature extraction network, the gas type identification branch, and the gas concentration prediction branch; The risk level information is quantified into a continuous penalty signal r. risk (t), and quantify the execution effect of the control command into an evaluation value. Combining the two to construct the advantage function in reinforcement learning ; Based on the advantage function, a trust region strategy optimization method is adopted to maximize the expected advantage and guide the update of model parameters under the constraint of KL divergence of the output distributions of the old and new models. During the update process, for the two tasks of gas identification and concentration prediction, the uncertainty u of their online prediction is considered. cls (t) and u reg (t), dynamically adjust its weight w in the joint fine-tuning loss. cls (t) and w reg (t), and perform gradient surgery based on gradient cosine similarity; The update process is dynamically triggered based on real-time calculated validation loss and parameter drift metrics, and a self-supervised loss incorporating knowledge distillation from the old model is employed.