Simulation circuit few-sample fault diagnosis method based on twin network
Through the simulation circuit with few samples based on twin networks, the twin network model is used to calculate feature vectors and loss function training, the soft fault diagnosis problem of simulated circuits is solved, and the accuracy and robustness of the identification of few samples are improved.
Patent Information
- Application Number
- CN202411300223.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2024-12-13
AI Technical Summary
The prior art is difficult to effectively diagnose soft faults in analog circuits, especially under the condition of small sample data, which leads to low quality of diagnostic models and cannot be applied to engineering practice.
Using a simulation circuit with few samples based on twin networks, the feature vector is calculated by collecting samples, making support sets and sample pair sets, and the twin network model combined with Swin-Transformer model and CNN model is used to calculate the feature vector, and compare losses and cross-entropy loss The combination of model training is carried out to improve the accuracy of identification of the categories of faults in few samples.
More accurate feature extraction and model training are achieved, and the identification accuracy and diagnostic robustness of the fault categories of few sample circuits are improved.
Smart Images

Figure CN119128523A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of analog circuit fault diagnosis, and in particular to an analog circuit small sample fault diagnosis method based on a twin network. Background Art
[0002] With the rapid development of the electronics industry, the integration and complexity of electronic devices have achieved significant growth. These devices play an extremely important role in key areas such as aerospace, transportation, medical care and communications. Although analog circuits account for less than 20% of electronic equipment, the failures they cause are as high as 80% of the total circuit failures. Among them, hard faults (that is, the complete failure of the circuit) are usually easier to identify, while soft faults are usually caused by slight deviations in component parameters, resulting in performance degradation, but they are difficult to be accurately diagnosed due to their hidden nature. The nonlinear characteristics of analog circuits and the existence of component tolerances cause fault states to overlap with each other, further increasing the difficulty of identifying soft faults. In addition, the diversity of analog circuit fault characteristics and the fact that circuit parameters are greatly affected by uncertain factors also make it more challenging to evaluate the health of analog circuits.
[0003] In actual analog circuit systems, it is very expensive to obtain fault data samples. Some fault types occur less frequently and infrequently, but they also have a significant impact on electronic equipment. However, ordinary machine learning research requires the use of a large number of data sets for repeated training. In most cases, the quality of the diagnostic model trained with a small number of samples is low. Therefore, most current analog circuit fault diagnosis uses multi-sample data training models, and lacks research on the case of few samples, making it difficult to apply to engineering practice. Therefore, it is very necessary to design an analog circuit few-sample fault diagnosis method based on twin networks. Summary of the invention
[0004] The purpose of the present invention is to provide a few-sample fault diagnosis method for analog circuits based on twin networks, so as to more accurately extract the feature vectors of samples and speed up the training process of the model, so as to improve the accuracy of identifying circuit fault categories of few samples.
[0005] To achieve the above object, the present invention provides the following solutions:
[0006] A method for diagnosing a few-sample fault of an analog circuit based on a twin network comprises the following steps:
[0007] Collect samples of simulated circuit fault categories;
[0008] Create a support set based on the sample;
[0009] Create a sample pair set based on the samples, and divide the sample pair set into a training set and a test set;
[0010] Calculate the feature vector of the sample pair set through the twin network model;
[0011] The twin network model is trained through the loss function to obtain a trained network model;
[0012] Determine the fault category of the sample to be diagnosed based on the trained network model and support set.
[0013] Optionally, a support set is prepared according to the samples, and the specific steps are: for each fault category, 5 samples are respectively extracted to form a support set.
[0014] Optionally, a sample pair set is prepared according to the sample, and the specific steps include:
[0015] Randomly select 2 / 3 of the samples in each fault category and pair them up to form similar sample pairs;
[0016] The remaining 1 / 3 samples of each fault category are paired with 1 / 3 samples randomly selected from the remaining fault categories to form non-similar sample pairs;
[0017] The order of similar sample pairs and non-similar sample pairs is disrupted to obtain a sample pair set.
[0018] Optionally, the twin network model is formed by combining a Swin-Transformer model and a CNN model; the Swin-Transformer model has built-in W-MSA and SW-MSA; W-MSA is used for the calculation of the window attention mechanism, and SW-MSA is used for the calculation of the sliding window attention mechanism.
[0019] Optionally, the Siamese network model has two input branches with the same architecture; the neuron weights of the two input branches with the same architecture are shared with each other.
[0020] Optionally, the specific steps of constructing the loss function include:
[0021] The eigenvector is copied to obtain a first eigenvector and a second eigenvector;
[0022] Calculate the contrast loss of the first eigenvector;
[0023] Calculate the cross entropy loss of the second eigenvector;
[0024] The contrast loss and cross entropy loss are linearly superimposed to obtain the loss function.
[0025] Optionally, the contrast loss is calculated as: Among them, m is the preset safety distance, the value of Y is 0 or 1, d is the Euclidean distance between sample pairs in the sample pair set, and X a and X bare two samples of a sample pair in the sample pair set, L c is the comparison loss.
[0026] Optionally, the cross entropy loss is calculated as: in, The value range is 0.1~1, (1-p t ) γ is the modulation factor, the value range of γ is 0~5, p t is the predicted probability of the network model for the category, z i is the second eigenvector, K is the dimension of the second eigenvector, L f is the cross entropy loss.
[0027] Optionally, the loss function is calculated as: L = λL c +L f ; Where L is the loss function and λ is the adjustment coefficient of contrast loss.
[0028] Optionally, the fault category of the sample to be diagnosed is determined according to the trained network model and the support set, and the specific steps include:
[0029] Input the fault samples to be diagnosed and the support set into the trained network model;
[0030] The average Euclidean distance between the fault samples to be diagnosed and the samples in the support set is calculated through the trained network model;
[0031] The fault category of the sample to be diagnosed is determined based on the average Euclidean distance.
[0032] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects: the present invention provides a twin network-based analog circuit few-sample fault diagnosis method, the method comprising: collecting samples of analog circuit fault categories; making a support set based on the samples; making a sample pair set based on the samples, and dividing the sample pair set into a training set and a test set; calculating the feature vector of the sample pair set through the twin network model; training the twin network model through a loss function to obtain a trained network model; and judging the fault category of the sample to be diagnosed based on the trained network model and the support set. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0034] Figure 1This is a flow chart of a method for diagnosing a few-sample fault of an analog circuit based on a twin network according to an embodiment of the present invention;
[0035] Figure 2 It is a structural diagram of a feature extraction module according to an embodiment of the present invention;
[0036] Figure 3 A flow chart is constructed for the loss function of an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0039] like Figure 1 As shown, an embodiment of the present invention provides a method for diagnosing a few-sample fault of an analog circuit based on a twin network, comprising the following steps:
[0040] Step 100: Collect samples of analog circuit fault categories; the specific steps are: use PSPICE software to simulate the experimental circuit, select the output end of the analog circuit as the test point, and obtain the circuit pulse response signal, and analyze it through Monte-Carlo to generate multiple groups of sample signals for each fault category.
[0041] Step 200: Create a support set based on the samples. The specific steps are: for each fault category, extract 5 samples from each fault category to form a support set. There are m circuit fault categories.
[0042] Step 300: Create a sample pair set according to the sample, and divide the sample pair set into a training set and a test set;
[0043] Specifically, each circuit fault category is defined as n i (i=0,1,...,12) samples, and generate N sample pairs from them, The number of samples is the number of samples remaining after step 200. The specific steps include:
[0044] Randomly select 2n / 3 samples from each fault category and pair them up to form similar sample pairs;
[0045] The remaining n / 3 samples of each fault category are paired with n / 3 samples randomly selected from the remaining (m-1) fault categories to form non-similar sample pairs;
[0046] The order of similar sample pairs and non-similar sample pairs is disrupted to obtain a sample pair set.
[0047] This sample pairing method improves the robustness of diagnosing unbalanced circuit faults, so that samples of the minority circuit fault category are well distinguished from samples of the same category and samples of different categories semantically.
[0048] Step 400: Calculate the feature vector of the sample pair set through the twin network model; the specific steps are: input the two samples of each sample pair into the twin network model at the same time, and calculate the feature vectors of the two samples respectively through the feature extraction module of the twin network model.
[0049] Specifically, the Siamese network model is formed by combining the Swin-Transformer model and the CNN model.
[0050] Specifically, Figure 2 As shown in FIG. 1 , the feature extraction module consists of three convolutional layers, two pooling layers, and two Block submodules of the Swin-Transformer model. The pooling layers are all maximum pooling layers with a size of 2 and a stride of 2. The feature extraction module can be used to calculate the feature vector of the original fault sequence sample with an input length of 960.
[0051] More specifically, the Block submodule of the Swin-Transformer model has built-in W-MSA and SW-MSA. The window step size of W-MSA is 15, which is used to calculate the attention of all windows. SW-MSA is used to calculate the sliding window attention mechanism. The specific steps are: the initial 7 (half the window step size) data points of the input sequence are translated to the end of the entire sequence, and then the W-MSA calculation is performed on the new sequence to ensure mutual communication between windows. This step is performed four times in total.
[0052] Specifically, the twin network model has two input branches with the same architecture; the neuron weights of the two input branches with the same architecture are shared with each other. The parameter settings in step 400 are shown in Table 1:
[0053] Table 1 Parameter setting table
[0054]
[0055] Among them, the number of heads is a preset parameter when calculating self-attention.
[0056] Step 500: Train the twin network model through the loss function to obtain a trained network model;
[0057] Specifically, the specific steps of constructing the loss function are as follows Figure 3 As shown, including:
[0058] Step 501: copy the feature vector into two copies;
[0059] Step 502: Calculate the contrast loss of a feature vector; the calculation formula is:
[0060]
[0061] Among them, m is the preset safety distance, and Y represents the feature vector of the two samples (X a ,X b ) is matched, matched is 1 and unmatched is 0, d is the Euclidean distance between sample pairs in the sample pair set, L c is the contrast loss. The calculation formula of Euclidean distance is:
[0062]
[0063] When the Euclidean distance is less than m, the contrast loss will become 0, which makes X a With X b They are similar but not identical, which ensures the generalization ability of the model.
[0064] Step 503: Calculate the cross entropy loss (Focal Loss) of another feature vector;
[0065] Specifically, the cross entropy loss is dynamically scaled. Through a dynamic scaling factor, it can dynamically reduce the weight of easily distinguishable samples during training, thereby quickly focusing on those difficult-to-distinguish samples; its calculation formula is:
[0066]
[0067] in, The value range is 0.1~1, (1-p t ) γ is the modulation factor, the value range of γ is 0~5, p t is the predicted probability of the network model for the category, z i is the second eigenvector, K is the dimension of the second eigenvector, L f is the cross entropy loss.
[0068] More specifically, Used to adjust the ratio between sample cross entropy losses and used on foreground categories (small sample fault categories) Use on background category The modulation factor is used to reduce the loss contribution of easily distinguishable samples, whether foreground or background categories, p t The larger it is, the easier it is to distinguish the fault samples of this category, and the smaller the modulation factor is.
[0069] Step 504: Linearly superimpose the contrast loss and the cross entropy loss to obtain a loss function. The loss function is calculated as:
[0070] L=λL c +L f ;
[0071] Wherein, L is the loss function, and λ is the adjustment coefficient of the contrast loss. In this embodiment, λ is on the order of 0.01.
[0072] Step 600: Determine the fault category of the sample to be diagnosed based on the trained network model and support set.
[0073] Specifically, the fault category of the sample to be diagnosed is determined according to the trained network model and the support set. The specific steps include:
[0074] Input the fault samples to be diagnosed and the support set into the trained network model;
[0075] The average Euclidean distance between the fault samples to be diagnosed and the samples in the support set is calculated through the trained network model;
[0076] The fault category of the sample to be diagnosed is determined based on the average Euclidean distance.
[0077] The beneficial effects of the present invention are as follows:
[0078] 1) It can more accurately extract the feature vector of the sample and speed up the model training process;
[0079] 2) Improved the accuracy of circuit fault classification identification for a small number of samples;
[0080] 3) Improved robustness in diagnosing unbalanced circuit faults.
[0081] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0082] The present invention uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only used to help understand the method and core ideas of the present invention. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for fault diagnosis of analog circuits with few samples based on twin networks, characterized in that: The steps include: Collect samples of simulated circuit fault categories; Creating a support set based on the sample; Creating a sample pair set based on the samples, and dividing the sample pair set into a training set and a test set; Calculating the feature vector of the sample pair set through a twin network model; Training the twin network model through a loss function to obtain a trained network model; The fault category of the sample to be diagnosed is determined according to the trained network model and the support set.
2. The analog circuit few-sample fault diagnosis method based on twin network according to claim 1, characterized in that: A support set is prepared according to the samples, and the specific steps are: for each fault category, 5 samples are respectively extracted to form the support set.
3. The analog circuit few-sample fault diagnosis method based on twin network according to claim 1, characterized in that: The sample pair set is prepared according to the sample, and the specific steps include: Randomly select 2 / 3 of the samples in each fault category and pair them up to form similar sample pairs; The remaining 1 / 3 samples of each fault category are paired with 1 / 3 samples randomly selected from the remaining fault categories to form non-similar sample pairs; The order of the similar sample pairs and the non-similar sample pairs is disrupted to obtain the sample pair set.
4. The analog circuit few-sample fault diagnosis method based on twin network according to claim 1, characterized in that: The twin network model is formed by combining a Swin-Transformer model and a CNN model; the Swin-Transformer model has built-in W-MSA and SW-MSA; the W-MSA is used for the calculation of the window attention mechanism, and the SW-MSA is used for the calculation of the sliding window attention mechanism.
5. The analog circuit few-sample fault diagnosis method based on twin network according to claim 1, characterized in that: The twin network model has two input branches with the same architecture; the neuron weights of the two input branches with the same architecture are shared with each other.
6. The analog circuit few-sample fault diagnosis method based on twin network according to claim 1, characterized in that: The specific steps of constructing the loss function include: Copying the eigenvector to obtain a first eigenvector and a second eigenvector; Calculating the contrast loss of the first feature vector; Calculating the cross entropy loss of the second feature vector; The contrast loss and the cross entropy loss are linearly superimposed to obtain the loss function.
7. The analog circuit few-sample fault diagnosis method based on twin network according to claim 6, characterized in that: The calculation formula of the contrast loss is: Among them, m is the preset safety distance, the value of Y is 0 or 1, d is the Euclidean distance between sample pairs in the sample pair set, and X a and X b are two samples of a sample pair in the sample pair set, L c is the comparison loss.
8. The analog circuit few-sample fault diagnosis method based on twin network according to claim 7, characterized in that: The calculation formula of the cross entropy loss is: in, The value range is 0.1~1, (1-p t ) γ is the modulation factor, the value range of γ is 0~5, p t is the predicted probability of the network model for the category, z i is the second eigenvector, K is the dimension of the second eigenvector, L f is the cross entropy loss.
9. The analog circuit few-sample fault diagnosis method based on twin network according to claim 8, characterized in that: The calculation formula of the loss function is: L = λL c +L f ; Where L is the loss function and λ is the adjustment coefficient of contrast loss.
10. The analog circuit few-sample fault diagnosis method based on twin network according to claim 1, characterized in that: Determining the fault category of the sample to be diagnosed according to the trained network model and the support set, the specific steps include: Inputting the fault sample to be diagnosed and the support set into the trained network model; Calculate the average Euclidean distance between the fault sample to be diagnosed and the samples in the support set by using the trained network model; The fault category of the sample to be diagnosed is determined according to the average Euclidean distance.
Citation Information
Patent Citations
Rolling bearing fault diagnosis method
CN114091553A
Motor bearing fault diagnosis method based on twin neural network small sample learning
CN115270883A
Supercharged boiler fault diagnosis method based on small sample learning and training method and testing method of fault diagnosis model
CN115935277A
