A natural gas pipeline multi-operating condition fault diagnosis method and system based on Bayesian adversarial attack and single source domain migration

By combining Bayesian adversarial attack and single-source domain migration technology in gas pipeline fault diagnosis, diversified attack samples are generated and decision-making boundaries are expanded, the problem of generalization of the model in multiple unknown target domains is solved, and the accuracy and reliability of multi-condition fault diagnosis is improved.

CN118656728BActive Publication Date: 2025-05-16NORTHEAST GASOLINEEUM UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410717954.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2025-05-16
Estimated Expiration
2044-06-04

AI Technical Summary

Technical Problem

The prior art is difficult to train models on a single source domain and generalize and perform tasks in multiple unknown target domains, especially in multi-condition fault diagnosis of natural gas pipelines, model performance is prone to degradation under different operating conditions.

Method used

Using Bayesian adversarial attack and single-source domain migration methods, through adversarial learning of Bayesian generators, discriminators and classifiers, diversified attack samples are generated to simulate unknown multi-case data, and the decision boundary is expanded through margin difference loss to improve the generalization performance of the model.

Benefits of technology

The identification accuracy and reliability of the multi-condition fault diagnosis model of natural gas pipelines in multi-condition scenarios is improved, the dependence on actual operational data is reduced, and the robustness and generalization ability of the model are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656728B_ABST
    Figure CN118656728B_ABST
Patent Text Reader

Abstract

A method and system for fault diagnosis of a natural gas pipeline based on a Bayesian adversarial attack and a single-source domain migration, belonging to the field of mechanical fault detection and diagnosis technology. The core of the method is to use transfer learning technology to solve the problem of insufficient generalization ability of existing deep reasoning models when processing pipeline fault diagnosis tasks under different working conditions. The main steps are as follows: an attack sample generator is constructed based on a Bayesian network, aiming to generate attack samples that can make the reasoning model make wrong decisions by adding a cleverly designed small perturbation to the input sample, so as to explore and analyze the vulnerabilities of the reasoning model; a domain discriminator is constructed based on a Bayesian network, aiming to assist in generating highly concealed attack samples through adversarial learning with the generator, that is, there is almost no visible difference with the original sample; a classifier is constructed based on a Bayesian network, by expanding the distance between the attack sample and the original decision boundary of the reasoning model, the posterior distribution of the network parameters of the constraint reasoning model is adjusted in the direction of a higher attack sample score, thereby enhancing the adaptability and robustness of the model in the face of different domain perturbations. Through the above steps, the present invention effectively solves the problem of increased risk of missed reports and false reports caused by the poor generalization ability of traditional deep learning models under different working conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a natural gas pipeline multi-operating condition fault diagnosis method and system based on Bayesian counterattack, relates to the fault diagnosis technology of natural gas pipelines, and belongs to the technical field of mechanical fault detection and diagnosis. Background Art

[0002] Compared with other modes of transportation such as roads, railways, waterways and aviation, pipeline transportation has become the preferred means of natural gas transportation due to its advantages such as low cost, low loss and large transportation volume. However, high-pressure natural gas is flammable and explosive. During large-scale, long-distance and continuous transportation, any damage or leakage of the pipeline may cause significant economic losses and may trigger public safety accidents. At present, more than half of the pipelines in my country have exceeded the prescribed service life and show serious corrosion. These aging pipelines pose a significant safety hazard. Therefore, in order to ensure the safety and stability of natural gas transportation, it is necessary to comprehensively monitor and monitor the pipeline operation performance, and take corresponding maintenance or replacement measures in a timely manner.

[0003] Due to its significant advantages in intelligence and automation, data-driven deep learning models have recently made remarkable achievements in the field of fault diagnosis. Deep learning models usually assume that training data and test data satisfy the principle of independent and identical distribution. This means that the data distribution characteristics and laws learned by the model during training should be consistent with the test data in actual application. However, due to changes in factors such as pipeline materials, working environment, and operating conditions, pipeline transportation status usually presents multi-condition characteristics. The data under different working conditions have significantly different statistical characteristics, resulting in certain differences in distribution characteristics. For data-driven fault diagnosis models, the difference in distribution under different working conditions means that even if the model has been fully trained under a certain working condition, it is likely to have performance degradation under another working condition. In response to this problem, how to establish a diagnostic model with good generalization ability has very important practical engineering significance. In essence, the simplest way is to establish multiple diagnostic models for different working conditions, but this will obviously significantly increase the workload and timeliness of diagnostic modeling, and will also increase the complexity and cost of model maintenance.

[0004] At present, the use of transfer learning technology to learn and analyze multi-condition data is considered to be a more effective strategy. Transfer learning, as an advanced cross-domain learning method, can effectively use the knowledge of the source domain to solve problems in the new domain (target domain) by narrowing the differences between different domains. The existing standard transfer learning model requires the simultaneous acquisition of source and target domain data before training to identify and reduce the distribution differences between the two domains during the training process. However, considering that natural gas pipelines involve confidential information about oil field energy, once leaked, it will affect national security. Protecting this sensitive information means that it is extremely difficult to obtain target domain data.

[0005] Therefore, it is imperative to provide a single-source domain generalization technology that can train a model on a single source domain and enable it to generalize and perform tasks in multiple unknown target domains for natural gas pipeline multi-condition fault diagnosis. In the prior art, no one has proposed combining Bayesian adversarial attacks and single-source domain migration to achieve multi-condition fault diagnosis of natural gas pipelines. Summary of the invention

[0006] The technical problems to be solved by the present invention are:

[0007] In view of the shortcomings of the existing technology, a natural gas pipeline multi-condition fault diagnosis method and system based on Bayesian adversarial attack and single-source domain migration are provided, which can improve the generalization performance of the diagnosis model by simulating unknown multi-condition data through pseudo-domain enhancement, reduce the dependence on actual operation data, improve the accuracy of the intelligent fault diagnosis model, and realize the effective diagnosis of multi-condition faults of natural gas pipelines.

[0008] The technical solution adopted by the present invention to solve the above technical problems is:

[0009] A method for multi-operating-condition fault diagnosis of a natural gas pipeline based on Bayesian adversarial attack and single-source domain migration, the method comprising the following steps:

[0010] Step 1: Collect natural gas pipeline monitoring signals and build a training data set

[0011] Use the natural gas pipeline network monitoring system to obtain pipeline negative pressure wave monitoring signals and acoustic wave monitoring signals, and use any domain signal to build a training set in is the i-th original pipeline sample, is the i-th sample label, N s is the sample size.

[0012] Step 2: Build a Bayesian generator to increase domain perturbations by maximizing classification error to ensure the effectiveness of the attack

[0013] In order to stabilize the training of the Bayesian generator and improve the diversity of attack samples, this paper introduces uncertainty by marginalizing the weights of the generator network using the Bayesian learning method. In order to infer the posterior distribution of the generator network parameters, the following conditional posterior distribution can be sampled:

[0014] p(θ g |x s ,θ d ,θ c )∝exp(-U attack (θ d ,θ c ;x s ,θ g ))p(θ g |α g ) (1) Among them, p(θ g |x s ,θ d ,θ c ) is the posterior distribution of the generator network parameters, p(θ g |α g ) is the prior distribution of the generator network parameters; θ g ~p(θ g ) is the network parameter of the generator g, θ d ~p(θ d ) is the network parameter of the discriminator d, θ c ~p(θ c ) is the network parameter of classifier c; α g is a hyperparameter. attack (θ d ,θ c ;x s ,θ g ) is the loss function of the generator, and its specific form is:

[0015]

[0016] Among them, G(x s θ g ) is the attack sample; J g is the number of mini-batch samples of the generator, M is the number of domain labels, and N is the number of category labels; d,m is the domain label, y c,n is the fault class label.

[0017] Step 3: Establish a Bayesian discriminator and ensure the concealment of the attack through adversarial learning with the generator

[0018] To infer the posterior distribution of the discriminator network parameters, we can sample from the following conditional posterior distribution:

[0019] p(θ d |x s ,θ g )∝exp(-U discriminate (θ g ;x s ,θ d ))p(θ d |α d ) (3) Among them, p(θ d |x s ,θ g ) is the posterior distribution of the discriminator network parameters, α d is a hyperparameter. discriminate (θ g ;x s ,θ d ) is the loss function of the discriminator, and its specific form is:

[0020]

[0021] Among them, J d is the number of mini-batch samples for the discriminator.

[0022] Step 4: Build a Bayesian classifier to expand the decision boundary of the original classifier, resist attacks, and improve generalization

[0023] The defense strategy designed by the present invention includes two parts. The first part is the classification loss based on cross entropy. First, it is necessary to construct the joint distribution p(X s , Y s , X a , Y a ), and then optimize the classification loss to accurately identify each sample in the joint distribution, that is:

[0024] p(θ c |x s , x a ,θ g )∝exp(-U defense (θ c ))p(θ c |α c ) (5) Among them, p(θ c |x s , x a ,θ g ) represents the posterior distribution of the classifier network parameters, α c is a hyperparameter. defense (θ c ) is the loss function of the classifier, and its specific form is:

[0025]

[0026] in, represents any sample in the joint distribution. The second part is the margin difference loss. Margin is defined as the minimum distance from the data point to the decision boundary. The use of margin difference loss can expand the distance between the attack sample and the original decision boundary of the classifier, constraining the posterior distribution of the classifier network parameters to adjust in the direction of higher attack sample scores, so as to enhance the adaptability and robustness of the model in the face of distribution differences under different working conditions. The regularized loss based on margin difference can be characterized as:

[0027]

[0028] in, and Respectively represent the attack sample distribution p(X a ) related migration classifier margin and pre-trained classifier margin, f represents the pre-trained classifier. The specific calculation formula of margin is:

[0029]

[0030] Among them, ρ c (x a ,y a ) is the decision boundary of the classifier, which is calculated as:

[0031]

[0032] Among them, y′ a For the classifier to attack sample x a Given the correct classification label, y′ a For the classifier to attack sample x a The wrong classification label given. Φ ρ (ρ c (x a ,y a )) is a piecewise function, which is used to promote the classifier to produce a large positive margin value, that is, to make the score of the correct category as high as possible than the scores of other categories. Its specific form is:

[0033]

[0034] Among them, ρ is the lower bound of the margin.

[0035] Step 5: Use the Stochastic Gradient Hamiltonian Monte Carlo (SGHMC) method to sample and estimate the posterior distribution of weights

[0036] First, a network parameter optimizer is built based on SGHMC, and then the Bayesian generator, Bayesian discriminator and Bayesian classifier are trained alternately.

[0037] Step 6: Obtain a single-source domain migration diagnosis model to complete pipeline network fault type identification

[0038] The single-source domain transfer diagnosis model training is completed through steps 1-4, and the model performance evaluation is completed through the set test data (from the pipeline with different operating conditions from the training data).

[0039] A natural gas pipeline multi-condition fault diagnosis system based on Bayesian adversarial attack and single-source domain migration, the system has a program module corresponding to the steps of the technical solution, and executes the steps in the above-mentioned natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single-source domain migration during operation.

[0040] A computer-readable storage medium stores a computer program, wherein the computer program is configured to implement the steps of the natural gas pipeline multi-operating condition fault diagnosis method based on Bayesian adversarial attack and single-source domain migration when called by a processor.

[0041] A natural gas pipeline multi-condition fault diagnosis device, the natural gas pipeline multi-condition fault diagnosis comprising at least one processor and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single-source domain migration, thereby realizing multi-condition fault diagnosis of the natural gas pipeline.

[0042] The present invention has the following beneficial technical effects:

[0043] The method and system for multi-condition fault diagnosis of natural gas pipelines based on Bayesian adversarial attack and single-source domain migration provided by the present invention provide a single-source domain generalization technology, which can train a model on a single source domain and enable it to generalize and perform tasks in multiple unknown target domains, greatly improving the recognition accuracy and reliability of multi-condition fault diagnosis of natural gas pipelines in multi-condition scenarios. The present invention provides a domain generalization strategy based on a single source domain in a domain adaptive algorithm. This strategy can train a model on a single source domain when target domain data is missing, and enable it to generalize and perform tasks in multiple unknown target domains.

[0044] The core of the single-source domain generalization algorithm is to extract common features from source domain samples while excluding those features that may cause the model to overfit a specific source domain environment to enhance the robustness of the model. In this process, the present invention observes that the attack defense strategy and domain generalization are essentially similar in principle, and both aim to enhance the robustness of the model in the face of unknown and changing conditions. First, although the unknown target domain data shares the same semantic information with the source domain samples, their distribution is different, which causes the diagnostic model based on source domain training to often misclassify the target domain data. This phenomenon is similar to the situation in which the original sample is slightly perturbed in the attack scenario, resulting in the misjudgment of the diagnostic model. Therefore, the first conclusion is drawn: for the diagnostic model, both the attack sample and the target domain data violate the independent and identically distributed assumption. Furthermore, the purpose of single-source domain generalization is to make the diagnostic model perform better in the target domain by eliminating inter-domain differences, while the defense strategy aims to build a robust diagnostic model that can accurately identify even in the face of attacks. Based on this, the second conclusion is obtained: both the defense strategy and the single-source domain generalization are aimed at improving the generalization ability and transferability of the diagnostic model to handle data samples that violate the independent and identically distributed assumption. Therefore, during the training process of the diagnostic model, all target domain data that are misidentified in the test phase are regarded as attack samples that appear infinitely, and these samples weaken the diagnostic performance of the model through domain perturbations. At the same time, single-source domain generalization essentially defends against this natural attack by reducing domain differences and improving diagnostic accuracy, thereby enhancing the model's resistance to unknown changes and generalization ability. In summary, based on the idea of ​​attack defense, the present invention proposes a natural gas pipeline fault diagnosis model based on Bayesian Single Domain Generalization (BSDG) to overcome the challenge of small samples.

[0045] The contribution of this invention is that it considers a more general and practical domain adaptation problem, that is, the target domain data is not required in the transfer learning process, and proposes a new perspective to deal with this general domain generalization problem through attack and defense strategies. This invention is one of the few attempts to apply the attack and defense framework to single-source domain generalization for pipeline fault diagnosis. The algorithm proposed in this invention constructs the domain generalization problem as a two-stage adversarial process and solves it through carefully designed attack and defense strategies. This work is expected to inspire new ideas and open up new paths for research in the field of pipeline fault diagnosis; a Bayesian single-source domain generalization algorithm for natural gas pipeline fault diagnosis is proposed. Within the Bayesian reasoning framework, the algorithm first uses weighted marginalized generators and discriminators to construct diverse attack samples, aiming to simulate the uncertainty and dynamics of domain deviation. Furthermore, the algorithm introduces a defense mechanism based on margin difference, which enhances the resistance to pseudo-target sample domain difference attacks by expanding the decision boundary of the source domain model, thereby providing an effective solution to the small sample problem; In order to verify the effectiveness of the proposed BSDG algorithm in small sample natural gas pipeline fault diagnosis, the present invention selects a variety of advanced comparison algorithms and conducts a detailed comparative analysis from multiple dimensions such as diagnostic performance, training stability and significant differences. The experimental results show that the BSDG algorithm exhibits superior performance in processing domain generalization fault diagnosis tasks.

[0046] Compared with the existing technology, it has the following advantages and effects:

[0047] 1) Different from the traditional intelligent fault diagnosis technology based on deep learning algorithm, the present invention mainly focuses on the problem of model performance degradation under multiple working conditions that is urgently needed in the field of pipeline fault diagnosis. By providing targeted solutions, the accuracy and practicality of the intelligent fault diagnosis model are improved.

[0048] 2) Different from the standard multi-condition fault diagnosis model built based on the transfer learning strategy, the present invention introduces an attack and defense framework to generate attack samples to simulate the vulnerabilities of the multi-condition target domain explanation fault diagnosis model, and further designs defense strategies for the key points of performance degradation to improve the generalization performance of the model, effectively improving the recognition accuracy of the model in multi-condition scenarios while avoiding the need for a large amount of operation data.

[0049] 3) The present invention establishes a generator, a discriminator and a classifier based on the Bayesian network, introduces uncertainty by marginalizing network parameters, effectively enhances the diversity of attack samples, and makes it better simulate the multi-condition distribution of the real world. In addition, the Bayesian network can effectively alleviate the overfitting problem by introducing prior knowledge on the weights and updating it to the posterior distribution, which helps the classifier to flexibly adapt to new situations and data changes.

[0050] 4) Considering the actual application of current intelligent fault diagnosis technology, this method has practical application value and has achieved certain application results. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 is a flowchart of a multi-operating condition fault diagnosis process according to an embodiment of the present invention; Figure 2 is a network structure diagram of an embodiment of the present invention; Figure 3 is a graph of loss convergence and verification accuracy of an embodiment of the present invention; Figure 4 This is a flowchart for generalization based on Bayesian single-source domain; Figure 5 This is a partial photo of the HD-II console and pipeline platform. DETAILED DESCRIPTION

[0052] The present invention will be further described below in conjunction with the accompanying drawings:

[0053] In order to enable those skilled in the art to better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application.

[0054] Figure 1 It is a flowchart of the multi-condition fault diagnosis process of a natural gas pipeline based on Bayesian adversarial attack in the technical solution of the present invention, and the overall process is implemented by Pytorch language programming.

[0055] In the attack defense framework, this paper uses Bayesian reasoning and margin difference as key tools to build a single source domain generalization model for natural gas pipeline fault diagnosis tasks. Figure 4 As shown, it includes two stages: attack and defense.

[0056] This paper designs an attack strategy based on Bayesian Generative Adversarial Networks (BGAN). The key idea is to generate attack samples with domain perturbations through BGAN, and improve the success rate of the attack by misleading the update direction of the classifier network parameters. Specifically, BGAN consists of two parts: a Bayesian Generator and a Bayesian Discriminator. The generator attempts to generate attack samples similar to source domain samples to deceive the discriminator, while the discriminator strives to improve its ability to identify attack samples. Through this adversarial process, the generator successfully learns and outputs attack samples that are difficult to distinguish from source domain samples. The basic framework of the BGAN model comes from Ian Goodfellow et al.

[13] GAN was proposed in 2014. However, the standard GAN optimization goal can easily fall into mode collapse, that is, the feedback given by the discriminator cannot fully guide the generator to produce diverse samples, resulting in the generator tending to focus on generating only a few samples.

[0057] In order to stabilize BGAN training and improve the diversity of attack samples, the present invention adopts Bayesian learning method, that is, introducing uncertainty by marginalizing the weights of generator and discriminator networks. In neural networks, all weights can be represented by highly multi-modal posterior distributions, rather than just one fixed value as usual. Each mode in the posterior distribution of network weights may correspond to a different generator, and each generator has a specific data generation behavior. Therefore, unlike the standard GAN, BGAN constructs a collection of generator networks, which effectively enhances the diversity of attack samples, so that unknown target domains can be simulated more comprehensively and accurately. In addition, the collection of discriminator networks can amplify adversarial signals and further enhance the discriminator's recognition ability in the face of complex attack scenarios.

[0058] Domain generalization mainly focuses on how to use source domain samples to train a diagnostic model so that it can be generalized to any unknown target domain. According to statistics of existing research work, domain generalization is mainly divided into two settings: Single-Source Domain Generalization (SSDG) and Multi-Source Domain Generalization (MSDG). In the SSDG setting, the model is only trained on a single source domain and is expected to be generalized to any unknown target domain; in the MSDG setting, the model is trained on multiple source domains and enhances the generalization ability to unknown target domains by improving the adaptability to the distribution differences of multiple source domains. However, the MSDG setting usually requires the collection of samples from three or more source domains to improve the generalization performance, a requirement that is often difficult to meet in the field of pipeline fault diagnosis. Therefore, the present invention mainly focuses on the SSDG setting.

[0059] Single-source domain generalization: Different from the MSDG setting, the distribution differences between multiple source domains can be learned to improve the adaptability of the model. Due to the lack of relevant information in the target domain, most existing studies in the SSDG setting focus on using data augmentation techniques to generate diverse pseudo-target domain data. For example, Cugu et al. simulate new domains by applying consistent visual attention to different views of the same sample and changing the training set samples. Su et al. generate more diverse and informative enhanced samples by combining global and local position scale transformations and using saliency information to guide the enhancement process. Zheng et al.

[10] The standard data augmentation (conversion or inversion) with learnable parameters is conceptualized as a semantic transformation, and the semantic transformation is further used to enhance the source domain samples. Li et al. used a domain extension subnetwork to gradually generate multiple domains to simulate various photometric and geometric transformations in unseen domains, thereby expanding the coverage of the source domain. However, existing research on domain generalization based on data augmentation lacks a clear definition of the pseudo-target domain, which often leads to excessive differences (no correlation) or small differences (no domain difference) between pseudo-domain samples and real samples, thereby affecting the migration performance and even causing negative migration. In order to solve this problem, the present invention introduces an attack and defense strategy, which defines the path of pseudo-target domain enhancement by using existing attack samples, ensuring that the pseudo-domain samples retain the correlation with the source domain and introduce sufficient domain differences to simulate the potential target domain, thereby improving the generalization ability and migration performance of the model.

[0060] Bayesian neural network: In a standard neural network, each weight and bias is set to a fixed value. These values ​​are learned and adjusted through an optimization process on a training set. In contrast, the weights and biases of a Bayesian neural network are regarded as probability distributions, and the optimization goal is to estimate the posterior distribution of the weights, which enables it to have the ability to estimate uncertainty, robustness to overfitting, and the ability to resist attacks. However, estimating the posterior distribution of weights is often difficult to implement directly. The main work currently focuses on techniques such as variational inference, local reparameterization, and Markov chain Monte Carlo. Considering the need for generating sample diversity, the present invention uses stochastic gradient Hamiltonian Monte Carlo (SGHMC) sampling to estimate the posterior distribution of weights, thereby avoiding the influence of the asymmetric deviation of KL divergence on methods such as variational approximation.

[0061] After analysis, it was found that all target domain data exhibited the following characteristics: 1) The feature distribution is different from that of the source domain samples; 2) The semantic information is the same as that of the source domain samples. This means that although the target domain and the source domain differ in discriminative features, their overall trends and category spaces remain consistent. In view of this feature, the present invention adopts adversarial attacks similar to the principle of domain adaptation as a research framework. This type of attack deceives the model into making wrong decisions by adding cleverly designed tiny perturbations to the input samples. The principles of adversarial attack design perturbations include: 1) Concealment: The perturbation usually needs to be small enough that there is almost no visible difference between the modified sample and the original sample; 2) Effectiveness: The perturbation must be effective enough to cause the deep learning model to make incorrect classifications; 3) Transferability: The perturbation should have a certain degree of transferability, which means that adversarial samples that are effective on one model can also have misleading effects on other models; 4) Diversity: Diverse perturbations can more comprehensively test the model's resistance to various attacks, help reveal possible weaknesses in the model, and thus promote the development of more robust models.

[0062] Based on the above description, the present invention assumes that there is a set of domains that share a label space and are related represents the available source domain, represents the unknown target domain. In the source domain, the sample label pairs in the sample space follow the joint distribution p(X, Y), where X and Y represent samples and labels respectively. The purpose of domain generalization is to use all sample label pairs in the source domain. To learn a classification model c:X→Y. The purpose of the classification model is to generalize to unknown target domains with superior performance. In order to achieve this goal, the present invention designs the BSDG algorithm under the framework of attack and defense strategy.

[0063] The implementation process of BSDG's attack strategy is as follows. Figure 1 The provided natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack includes the following steps:

[0064] Step 1: Collect natural gas pipeline monitoring signals and build a training data set

[0065] Use the natural gas pipeline network monitoring system to obtain pipeline negative pressure wave monitoring signals and acoustic wave monitoring signals, and use any domain signal to build a training set in is the i-th original pipeline sample, is the i-th sample label, N s is the sample size.

[0066] Step 2: Build a Bayesian generator to increase domain perturbations by maximizing classification error to ensure the effectiveness of the attack

[0067] In order to stabilize the training of the Bayesian generator and improve the diversity of attack samples, this paper introduces uncertainty by marginalizing the weights of the generator network using the Bayesian learning method. In order to infer the posterior distribution of the generator network parameters, the following conditional posterior distribution can be sampled:

[0068] p(θ g |x s ,θ d ,θ c )∝exp(*U attack (θ d ,θ c |X s ,θ g ))p(θ g |α g ) (1)

[0069] Among them, p(θ g |x s ,θ d ,θ c ) is the posterior distribution of the generator network parameters, p(θ g |α g ) is the prior distribution of the generator network parameters; θ g ~p(θ g ) is the network parameter of the generator g, θ d ~p(θ d ) is the network parameter of the discriminator d, θ c ~p(θ c ) is the network parameter of classifier c; α g is a hyperparameter. attack (θ d ,θ c |c s ,θ g ) is the loss function of the generator, and its specific form is:

[0070]

[0071] Among them, G(x s θ g ) is the attack sample; J g is the number of mini-batch samples of the generator, M is the number of domain labels, and N is the number of category labels; d,m is the domain label, y c,n is the fault class label.

[0072] Step 3: Establish a Bayesian discriminator and ensure the concealment of the attack through adversarial learning with the generator

[0073] To infer the posterior distribution of the discriminator network parameters, we can sample from the following conditional posterior distribution:

[0074] p(θ d |x s ,θ g )∝exp(-U discriminate (θ g ;x s ,θ d ))p(θ d |α d ) (3)

[0075] Among them, p(θ d |x s ,θ g ) is the posterior distribution of the discriminator network parameters, α d is a hyperparameter. discriminate (θ g ;x s ,θ d ) is the loss function of the discriminator, and its specific form is:

[0076]

[0077] Among them, J d is the number of mini-batch samples for the discriminator.

[0078] Step 4: Build a Bayesian classifier to expand the decision boundary of the original classifier, resist attacks, and improve generalization

[0079] The defense strategy designed by the present invention includes two parts. The first part is the classification loss based on cross entropy. First, it is necessary to construct the joint distribution p(X s , Y s , X a , Y a ), and then optimize the classification loss to accurately identify each sample in the joint distribution, that is:

[0080] p(θ c |x s , x a ,θ g )∝exp(-U defense (θ c ))p(θ c |α c ) (5)

[0081] Among them, p(θ c |x s , x a ,θ g ) represents the posterior distribution of the classifier network parameters, α cis a hyperparameter. defense (θ c ) is the loss function of the classifier, and its specific form is:

[0082]

[0083] in, represents any sample in the joint distribution. The second part is the margin difference loss. Margin is defined as the minimum distance from the data point to the decision boundary. The use of margin difference loss can expand the distance between the attack sample and the original decision boundary of the classifier, constraining the posterior distribution of the classifier network parameters to adjust in the direction of higher attack sample scores, so as to enhance the adaptability and robustness of the model in the face of distribution differences under different working conditions. The regularized loss based on margin difference can be characterized as:

[0084]

[0085] in, and Respectively represent the attack sample distribution p(X a ) related migration classifier margin and pre-trained classifier margin, f represents the pre-trained classifier. The specific calculation formula of margin is:

[0086]

[0087] Among them, ρ c (x a ,y a ) is the decision boundary of the classifier, which is calculated as:

[0088]

[0089] Among them, y′ a For the classifier to attack sample x a Given the correct classification label, y′ a For the classifier to attack sample x a The wrong classification label given. Φ ρ (ρ c (x a ,y a )) is a piecewise function, which is used to promote the classifier to produce a large positive margin value, that is, to make the score of the correct category as high as possible than the scores of other categories. Its specific form is:

[0090]

[0091] Among them, ρ is the lower bound of the margin.

[0092] Step 5: Use the Stochastic Gradient Hamiltonian Monte Carlo (SGHMC) method to sample and estimate the posterior distribution of weights

[0093] First, a network parameter optimizer is built based on SGHMC, and then the Bayesian generator, Bayesian discriminator and Bayesian classifier are trained alternately.

[0094] Step 6: Obtain a single-source domain migration diagnosis model to complete pipeline network fault type identification

[0095] The single-source domain transfer diagnosis model training is completed through steps 1-5, and the model performance evaluation is completed through the set test data (from the pipeline with different operating conditions from the training data).

[0096] In step 1, the pipeline negative pressure wave monitoring signal and the acoustic wave monitoring signal are obtained, and the specific process of using any domain signal to construct a training set is as follows: first, the negative pressure wave monitoring signal and the acoustic wave monitoring signal are obtained from the monitoring system, and then the samples with a length of 1024 are obtained through downsampling operation, and the obtained samples are denoised, and finally the negative pressure wave signal and the acoustic wave signal are stored in two domains. In step 2, the hyperparameter α g Determined by cross-validation; the relationship between the network parameters of generator g, discriminator d, and classifier c is: The output of the discriminator is used to adjust the update direction of the generator, and the output of the generator is used to improve the generalization performance of the classifier. In step 3, the hyperparameter α d Determined by cross-validation. In step 4, the margin lower bound ρ is related to the model accuracy and is determined through multiple experiments. In step 5, the Bayesian network parameter optimizer is constructed using the stochastic gradient Hamiltonian Monte Carlo method to achieve alternating optimization of the generator, discriminator, and classifier. The Bayesian network parameter optimizer is constructed using the stochastic gradient Hamiltonian Monte Carlo method (SGHMC) to achieve alternating optimization of the generator, discriminator, and classifier. The specific process is:

[0097] According to the previous round of iteration process, the current parameter θ that needs to be updated is obtained g ,θ d ,θ c :

[0098] and

[0099] Then start the attack training loop:

[0100] Start SGHMC's J g training, from the source domain distribution p(X s ) in the sample J g Source domain samples Update the parameter posterior distribution p(θ) through K iterations of SGHMC g |x s ,θ d ),

[0101]

[0102] Bundle Add to the parameter set and end the loop;

[0103] Start SGHMC's J d Iteration training:

[0104] Sample J from the source domain distribution d Source domain samples Update the parameter posterior distribution p(θ) through K iterations of SGHMC d |x s ,θ g )

[0105]

[0106] Bundle Add to the parameter set to end the attack training loop;

[0107] Restart the defense training cycle:

[0108] From the joint field distribution p(X s , X a ) in the sample J c Enhanced samples Update the parameter posterior distribution p(θ) through K iterations of SGHMC c |x s , x a ,θ g )

[0109]

[0110] End the defensive training cycle;

[0111] In the above formula, α is the momentum decay coefficient of SGHMC, η is the learning rate; v = ∈M -1 r is the kinetic energy term of SGHMC; 2αηI represents the variance. The specific algorithm is as follows:

[0112]

[0113]

[0114] Example

[0115] The effectiveness of the method of the present invention is verified by taking natural gas pipeline fault diagnosis as an example.

[0116] 1. Experimental Setup

[0117] The training data used in this invention are respectively collected from the pressure sensor in the ZJ-CSDG pipeline simulation platform and the acoustic sensor in the HD-II pipeline simulation platform. The total length of the ZJ-CSDG pipeline simulation platform is 180.2m, and the flow rate is 10m 3 / h, sampling frequency 1024Hz. Negative pressure wave data were collected under three working pressures, namely the high pressure (HP) domain in the range of 0.565MPa-0.595MPa, the medium pressure (HP) domain in the range of 0.425MPa-0.455MPa, and the high pressure (HP) domain in the range of 0.275MPa-0.305MPa. The experimental data under each pressure condition simulated four health states of the pipeline by adjusting the valve opening, namely large leakage, medium leakage, small leakage and normal condition.

[0118] HD-II pipeline simulation platform (such as Figure 5 As shown) total length 160m, pressure 0.5Mpa, flow rate 60m 3 / h, 10 leakage points. According to the pipeline fault type, four pipeline health conditions are set, including large leakage (LL), medium leakage (ML), small leakage (SL) and normal (NC). Considering the fault sampling frequency, the intercepted sample length must contain at least one cycle of the fault frequency, so 1024 sampling points are intercepted from the original signal to form a sample.

[0119] The multi-condition fault diagnosis model consists of a Bayesian generator, a Bayesian discriminator, and a Bayesian classifier. The network structure is as follows: Figure 2 As shown in the figure, during the training process of the multi-condition fault diagnosis model, the total number of iterations is 5000; in each cycle, the discriminator is trained 10 times, the generator is trained 1 time, and the batch size is 128.

[0120] 2. Evaluation of diagnostic results

[0121] In order to comprehensively evaluate the performance of the BSDG algorithm, the present invention conducts experiments in the scenarios of multi-source domain generalization and single-source domain generalization.

[0122] 1) Generalized diagnosis results in multiple source domains

[0123] Table 1 shows the results of multi-source domain generalization diagnosis. It can be found from the table that the BSDG algorithm proposed in the present invention surpasses the other 7 comparison algorithms with a significant advantage. Specifically: ERM, as a comparison algorithm without any domain adaptation operation, may show relatively stable performance in specific tasks, but it does not show satisfactory diagnosis results in domain generalization tasks; compared with the optimal domain adaptation algorithm CORAL, the accuracy of the BSDG algorithm is improved by 16.7%. This means that the standard distribution alignment method is difficult to generalize the ability to reduce distribution differences to any unknown target domain; compared with the optimal domain generalization algorithm SSAA, the accuracy of the BSDG algorithm is improved by 9.7%. On the one hand, the Bayesian neural network effectively improves the diversity and authenticity of attack samples by constructing a set containing multiple generators; on the other hand, the Bayesian neural network combined with margin loss effectively resists the domain perturbations contained in the attack samples, expands the decision boundary of the classifier, and further reduces the distribution difference between the attack samples and the source domain samples.

[0124] By comparing the performance with 7 fault diagnosis models, the performance of the multi-condition fault diagnosis model of the present invention can be demonstrated, and the experimental results are shown in Tables 1-3. Table 1 shows the generalized diagnosis results in multiple source domains. The experimental results show that compared with the optimal comparison algorithm 7, the accuracy of the algorithm of the present invention is improved by 9.7%. On the one hand, the Bayesian neural network effectively improves the diversity and authenticity of attack samples by constructing multiple generator sets; on the other hand, the Bayesian neural network combined with margin loss effectively resists the domain perturbations contained in the attack samples, expands the decision boundary of the classifier, and further narrows the distribution difference between the attack samples and the source domain samples.

[0125] 2) Generalization diagnosis results of single source domain

[0126] Tables 2 and 3 verify the diagnostic performance of the BSDG algorithm and the comparison algorithm in the single-source domain generalization task. Among them, Table 2 lists the migration tasks between three different domains in NPWD. Table 3 records the migration tasks between different domains in NPWD and AWD. Tables 2 and 3 verify the diagnostic performance of the algorithm of the present invention and the comparison algorithm in the single-source domain generalization task. Among them, Table 2 lists the migration tasks between three different domains in NPWD. Table 3 records the migration tasks between different domains in NPWD and AWD. The algorithm of the present invention achieved the highest accuracy in both task settings. In Table 3, the average accuracy of the proposed BSDG algorithm on 6 tasks is 68.56%, which is 27.9% higher than the second-ranked SSAA algorithm. The experimental results show that the introduction of Bayesian neural networks better helps the generator to accurately simulate different unknown target domain features in real scenes, and the use of margin difference loss also allows the classifier to flexibly and effectively respond to frequent distribution changes, improving the adaptability and robustness of the classifier to multiple domain perturbations.

[0127] Table 1. Experimental results of multi-source domain generalization (%). The best results are marked in bold.

[0128]

[0129] Table 2. Results of single-source domain generalization experiments (negative pressure wave data). The best results are marked in bold.

[0130]

[0131] Table 3. Results of single-source domain generalization experiments (acoustic wave data and negative pressure wave data). The best results are marked in bold.

[0132]

[0133] 3. Stability performance evaluation

[0134] In order to verify the stability of the proposed algorithm, the present invention records the training loss and verification accuracy of the multi-source domain generalization task (HP+MP+LP)→AW and the single-source domain generalization task HP→LP, as shown in Figure 3 shown. Figure 3 (a) shows that in the above two tasks, the training loss of the algorithm of the present invention decreases rapidly to a very small value with a stable trend. In addition, Figure 3 (b) shows that the verification accuracy of the algorithm of the present invention can quickly reach a high value during the training process. Therefore, it can be found that the algorithm of the present invention can stably generalize the diagnostic knowledge of the source domain to the unknown target domain.

[0135] 4. Significance Analysis

[0136] In order to verify the effectiveness of the proposed algorithm in improving the generalization effect of the domain, the present invention performs a paired sample t-test on the results of the single-source domain generalization to quantitatively verify the significant improvement brought by the proposed BSDG algorithm compared with the strong contrast algorithm. The paired sample t-test is a parametric statistical method used to compare the average values ​​of the results from the same group of samples after being processed by two algorithms. The steps of conducting the test include: first, calculating the difference in the diagnostic results of each sample under the processing of the two algorithms; second, calculating the average and standard deviation of these differences; then, dividing the average of the differences by their standard errors to obtain the t value. Finally, the p-value in the t-distribution table is calculated according to the degrees of freedom to determine whether there is a statistically significant difference in the means of the diagnostic results of the two algorithms. If the p-value is less than the significance level set in advance, it is considered that there is a significant difference in the means of the diagnostic results of the two algorithms. As a rule of thumb, the present invention sets the significance threshold to 0.05, that is, p≤0.05 means that the BSDG algorithm shows a significant performance improvement, and p>0.05 means that the BSDG algorithm has similar performance to the contrast algorithm.

[0137] The experimental results in Table 1, Table 2, and Table 3 are named Case 1, Case 2, and Case 3. The statistical results show that the performance of the BSDG algorithm is similar to that of the SSAA algorithm only in Case 2, but it is much better than the comparison algorithm in other scenarios.

[0138] Table 4 Paired sample t test significance test

[0139]

[0140] 1 “+” indicates that the proposed algorithm has significantly better performance than the comparison algorithm, and “-” indicates that the performance is similar

[0141] The present invention proposes a novel natural gas pipeline fault diagnosis method based on Bayesian single-source domain generalization. First, in the non-directional attack stage, through adversarial learning between the Bayesian generator and the Bayesian discriminator, diversified and smooth perturbations are introduced into the source domain samples, so as to construct pseudo-target domain samples that are approximately true, which are used to mislead the judgment results of the classifier. Furthermore, in the model defense stage, the margin difference loss is used to expand the distance between the pseudo-domain samples and the original decision boundary of the classifier, thereby forming a new decision boundary that can contain all unknown samples. Through the attack and defense strategy, the BSDG algorithm can learn feature representations with obvious discrimination and high transferability from pseudo-domain samples, and then effectively generalize to any unknown target domain in the real scene. Experimental results show that compared with the current advanced methods, the BSDG algorithm proposed in this study shows significant performance advantages in the application scenarios of multi-source domain and single-source domain generalization.

[0142] In summary, the method proposed in the present invention can not only solve the small sample problem in the field of natural gas pipeline fault diagnosis, but also its diagnostic performance and stability are better than the existing comparative methods, effectively reducing the risk of missed reports and false reports, and improving the accuracy of pipeline fault diagnosis. The method of the present invention has been verified by simulation experiments and practical applications, and the technical effects and practicality claimed by the present invention have been verified.

[0143] The method of the present invention has been verified through simulation experiments and practical applications, and the technical effects claimed by the present invention have been verified.

[0144] The algorithm (method) proposed in the present invention is the underlying technical core of the present invention, and various products can be derived based on the algorithm.

[0145] Based on the algorithm (method) proposed in the present invention, a natural gas pipeline multi-condition fault diagnosis system based on Bayesian adversarial attack and single-source domain migration is developed using a programming language. The system has program modules corresponding to the steps of the above-mentioned technical solution, and executes the steps in the above-mentioned natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single-source domain migration during operation.

[0146] The computer program of the developed system (software) is stored on a computer-readable storage medium, and the computer program is configured to implement the steps of the above-mentioned natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single-source domain migration when called by a processor. That is, the present invention is materialized on a carrier to become a computer program product.

[0147] A natural gas pipeline multi-condition fault diagnosis device, the seismic information processing device includes at least one processor, and a memory connected to the at least one processor in communication, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the above-mentioned natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single-source domain migration, and realize multi-condition fault diagnosis of natural gas pipelines. The natural gas pipeline multi-condition fault diagnosis device is used as a terminal product of the present invention.

[0148] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0149] The computer programs (also referred to as programs, software, software applications, or codes) of the present invention include machine instructions for programmable processors, and these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used in the present invention, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or device (e.g., disk, optical disk, memory, programmable logic device PLD) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0150] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, they are all within the scope of protection of the present invention.

Claims

1. A multi-condition fault diagnosis method for natural gas pipelines based on Bayesian adversarial attack and single-source domain migration, characterized in that The implementation process is: Step 1: Collect natural gas pipeline monitoring signals and build a training data set: Use the natural gas pipeline network monitoring system to obtain pipeline negative pressure wave monitoring signals and acoustic wave monitoring signals, and use any domain signal to build a training set in is the i-th original pipeline sample, is the i-th sample label, N s is the sample size; Step 2: Build a Bayesian generator to increase domain perturbations by maximizing the classification error to ensure the effectiveness of the attack: The generator is constructed using a Bayesian network, and attack samples are generated by maximizing the class label classification loss and minimizing the domain label discrimination loss. The Bayesian learning method is used to marginalize the weights of the generated network to introduce uncertainty, which is used to stabilize the training of the Bayesian generator and improve the diversity of attack samples. Infer the posterior distribution of the generator network parameters, sampling from the following conditional posterior distribution: p(θ g |x s ,i d ,i c )∝exp(-U attack (i d ,i c |x s ,i g ))p(θ g |a g ) (1) Among them, p(θ g |x s ,θ d ,θ c ) is the posterior distribution of the generator network parameters, p(θ g |α g ) is the prior distribution of the generator network parameters; θ g ~p(θ g ) is the network parameter of the generator g, θ d ~p(θ d ) is the network parameter of the discriminator d, θ c ~p(θ c ) is the network parameter of classifier c; α g is a hyperparameter; U attack (θ d ,θ c |x s ,θ g ) is the loss function of the generator, and its specific form is: in, is the attack sample; J g is the number of mini-batch samples of the generator, M is the number of domain labels, and N is the number of category labels; d,m is the mth domain label, y c,n is the nth fault class label; Step 3: Establish a Bayesian discriminator and ensure the concealment of the attack through adversarial learning with the generator: A domain discriminator based on a Bayesian network is established to assist in generating highly concealed attack samples, infer the posterior distribution of the discriminator network parameters, and sample from the following conditional posterior distributions: p(θ d |x s ,i g )∝exp(-U discriminate (i g ;x s ,i d ))p(θ d |a d ) (3) Among them, p(θ d |x s ,θ g ) is the posterior distribution of the discriminator network parameters, α d is a hyperparameter; U discriminate (θ g ;x s ,θ d ) is the loss function of the discriminator, and its specific form is: Among them, J d is the number of mini-batch samples for the discriminator; Step 4: Build a Bayesian classifier to expand the decision boundary of the original classifier, resist attacks, and improve generalization: The designed defense strategy consists of two parts. The first part is the classification loss based on cross entropy. First, we need to construct the joint distribution p(X s ,Y s ,X a ,Y a ), and then optimize the classification loss to accurately identify each sample in the joint distribution, that is: p(θ c |x s ,x a ,i g )∝exp(-U defense (i c ))p(θ c |a c ) (5) Among them, p(θ c |x s ,x a ,θ g ) represents the posterior distribution of the classifier network parameters, α c is a hyperparameter; U defense (θ c ) is the loss function of the classifier, and its specific form is: in, represents any sample in the joint distribution; the second part is the margin difference loss; the margin is defined as the minimum distance from the data point to the decision boundary. The use of margin difference loss can expand the distance between the attack sample and the original decision boundary of the classifier, constraining the posterior distribution of the classifier network parameters to adjust in the direction of higher attack sample scores, so as to enhance the adaptability and robustness of the model when facing distribution differences in different working conditions; The defense strategy based on margin loss is used to improve the recognition accuracy of the classifier for samples of different working conditions; the regularization loss based on margin difference can be characterized as: in, and Respectively represent the attack sample distribution p(X a ) related migration classifier margin and pre-trained classifier margin, f represents the pre-trained classifier; the specific calculation formula of the margin is: Among them, ρ c (x a ,y a ) is the decision boundary of the classifier, which is calculated as: Among them, y′ a For the classifier to attack sample x a Given the correct classification label, y′ a For the classifier to attack sample x a The wrong classification label given; Φ ρ (ρ c (x a ,y a )) is a piecewise function, which is used to promote the classifier to produce a large positive margin value, that is, to make the score of the correct category as high as possible than the scores of other categories. Its specific form is: Among them, ρ is the lower bound of the margin; Step 5: Use the stochastic gradient Hamiltonian Monte Carlo method SGHMC sampling to estimate the weight posterior distribution: The Bayesian network parameter optimizer is constructed using the stochastic gradient Hamiltonian Monte Carlo method to achieve alternating optimization of the generator, discriminator, and classifier. First, the network parameter optimizer is constructed based on SGHMC, and then the Bayesian generator, Bayesian discriminator, and Bayesian classifier are trained alternately. Step 6: Obtain the single-source domain migration diagnosis model and complete the pipeline network fault type identification: The single-source domain transfer diagnosis model training is completed through steps 1-5, and the model performance evaluation is completed through the set test data, which comes from a pipeline with different operating conditions from the training data.

2. According to claim 1, a natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single source domain migration is characterized in that: In step 1, the specific process of obtaining the pipeline negative pressure wave monitoring signal and the sound wave monitoring signal and using any domain signal to construct a training set is as follows: first, the negative pressure wave monitoring signal and the sound wave monitoring signal are obtained from the monitoring system respectively, and then a sample of length 1024 is obtained through a downsampling operation, and the obtained samples are denoised, and finally the negative pressure wave signal and the sound wave signal are stored in two domains.

3. A natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single source domain migration according to claim 1 or 2, characterized in that: In step 2, the hyperparameter α g Determined by cross-validation; the relationship between the network parameters of generator g, the network parameters of discriminator d, and the network parameters of classifier c is: The output of the discriminator is used to adjust the update direction of the generator, and the result of the generator is used to improve the generalization performance of the classifier.

4. According to claim 3, a natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single source domain migration is characterized in that: In step 3, the hyperparameter α d Determined by cross validation.

5. According to claim 4, a natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single source domain migration is characterized in that: In step 4, the margin lower bound ρ is related to the model accuracy and is determined through multiple experiments.

6. A natural gas pipeline multi-operating condition fault diagnosis method based on Bayesian adversarial attack and single source domain migration according to claim 5, characterized in that: In step 5, a Bayesian network parameter optimizer is constructed using the stochastic gradient Hamiltonian Monte Carlo method to achieve alternating optimization of the generator, discriminator, and classifier.

7. A natural gas pipeline multi-operating condition fault diagnosis method based on Bayesian adversarial attack and single source domain migration according to claim 6, characterized in that: The Bayesian network parameter optimizer is constructed using the stochastic gradient Hamiltonian Monte Carlo method SGHMC to achieve alternating optimization of the generator, discriminator, and classifier. The specific process is as follows: According to the previous round of iteration process, the current parameter θ that needs to be updated is obtained g ,θ d ,θ c : Then start the attack training loop: Start SGHMC's J g training, from the source domain distribution p(X s ) in the sample J g Source domain samples Update the parameter posterior distribution p(θ) through K iterations of SGHMC g |x s ,θ d ), Bundle Add to the parameter set and end the loop; Start SGHMC's J d Iteration training: Sample J from the source distribution d Source domain samples Update the parameter posterior distribution p(θ) through K iterations of SGHMC d |x s ,θ g ) Bundle Add to the parameter set to end the attack training loop; Restart the defense training cycle: From the joint field distribution p(X s ,X a ) in the sample J c Enhanced samples Update the parameter posterior distribution p(θ) through K iterations of SGHMC c |x s ,x a ,θ g ) End the defensive training cycle; In the above formula, α is the momentum decay coefficient of SGHMC, η is the learning rate; v = ∈M -1 r is the kinetic energy term of SGHMC; 2αηI represents the variance.

8. A natural gas pipeline multi-operating condition fault diagnosis system based on Bayesian adversarial attack and single source domain migration, characterized by: The system has a program module corresponding to the steps of any one of claims 1 to 7, and executes the steps in the above-mentioned natural gas pipeline multi-condition fault diagnosis method based on Bayesian adversarial attack and single-source domain migration when running.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is configured to implement the steps of the natural gas pipeline multi-operating condition fault diagnosis method based on Bayesian adversarial attack and single-source domain migration described in any one of claims 1 to 7 when called by a processor.

10. A natural gas pipeline multi-operating condition fault diagnosis device, characterized by: The multi-condition fault diagnosis of the natural gas pipeline includes at least one processor and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the multi-condition fault diagnosis method for the natural gas pipeline based on Bayesian adversarial attack and single-source domain migration as described in any one of claims 1-7, so as to realize multi-condition fault diagnosis of the natural gas pipeline.