A power grid fault recording data enhancement method and system based on improved TS-GAN
By generating power grid fault recording data through the improved TS-GAN, the problem of insufficient power grid fault sample data is solved, the accuracy of the fault diagnosis model is improved, and the safety and stability of the power grid are ensured.
Patent Information
- Application Number
- CN202510919243.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-07-04
AI Technical Summary
The amount of grid fault sample data is small and unbalanced, resulting in low accuracy of fault diagnosis models. In particular, small sample faults such as three-phase short circuit faults caused by single-phase ground short circuit faults are difficult to identify, which may lead to misoperation of protection devices and affect grid stability.
An improved time series generative adversarial network (TS-GAN) is used to enhance fault recording data. Through preprocessing, feature extraction, generative discrimination and model training, simulation samples are generated to expand training data. The global and local attention mechanisms are combined to strengthen feature learning and ensure the temporal consistency and accuracy of the generated data.
The diagnostic capability of the fault diagnosis model is improved, the accuracy and stability of power grid fault identification are enhanced, and the security and stability of the power grid are enhanced.
Smart Images

Figure CN120408045B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data enhancement, in particular to a power grid fault recording data enhancement method and system based on improved TS-GAN. BACKGROUND
[0002] With the structure and operation of the power system becoming more and more complex, once the power grid fault occurs, a simple fault may evolve into a more serious developing fault if the fault cannot be removed quickly. These faults are relatively difficult to be distinguished by conventional fault diagnosis methods due to the small number of samples. If these faults cannot be identified and isolated in time, it may lead to the misoperation of protection devices and circuit breakers, thereby causing secondary impact on the power grid. Especially, the single-phase grounding short-circuit fault leading to three-phase short-circuit fault, the single-phase grounding short-circuit fault leading to two-phase grounding short-circuit fault, and the two-phase short-circuit grounding fault developing into three-phase short-circuit fault. These small sample faults usually refer to the evolution of a single fault into other types of faults, and analyzing only the waveforms at the time of fault occurrence often cannot effectively distinguish the fault. In addition, the existence of these small sample data often leads to insufficient training of the diagnosis model and affects the discrimination rate of the model.
[0003] In order to solve the problem of low discrimination accuracy in the case of small sample faults, an improved TS-GAN-based power grid fault recording data enhancement method is needed. The fault recording data is preprocessed and input into the designed TS-GAN model for training to generate simulation samples for subsequent model training. SUMMARY
[0004] In order to solve the problem of small amount of fault sample data and data imbalance when faults occur in different power grids, the present application provides an improved TS-GAN-based power grid fault recording data enhancement method and system. With the advantage of time series generation adversarial network in sample enhancement, small sample faults are data enhanced and used for training subsequent models.
[0005] In the first aspect, the present application provides an improved TS-GAN-based power grid fault recording data enhancement method, which adopts the following technical scheme:
[0006] An improved TS-GAN-based power grid fault recording data enhancement method, comprising:
[0007] Obtaining small sample fault recording data;
[0008] Preprocessing the obtained small sample fault recording data;
[0009] Extracting features of the small sample fault recording data by using an improved TS-GAN-based fault generation model;
[0010] The extracted features are generated and discriminated faults by using a fault generation model based on an improved TS-GAN;
[0011] The model is trained by using small sample fault recording data as samples;
[0012] The trained model is evaluated and optimized;
[0013] The optimized model is used for data enhancement of power grid fault recording data.
[0014] Further, the pre-processing of the obtained small sample fault recording data includes: for a real recording sequence with 2400 sampling points, each sampling point is gradually sampled from the starting point of the recording, so as to expand a single real fault data sequence into a set of training data sets containing multiple sampling points, each segment corresponds to a continuous time point in the original sequence, for increasing the number and diversity of training data, wherein in the fault recording data, the electrical quantity indicators constitute a time series process , wherein represents a discrete time point, represents a fault characteristic parameter, is a fault parameter space, and a trajectory sequence is a discrete set, and the electrical quantity state can be represented as If the model generates the electrical quantity of the fault recording data as , and the model is subject to a probability distribution , then the probability distribution generated by the model is , which needs to be close to the sequence distribution in the real scene ; in the data generation model , the performance is represented by parameters , represents a model parameter space, and satisfies:
[0015] ,
[0016] wherein: represents the distance between different distributions.
[0017] Furthermore, the improved TS-GAN fault generation model is used to extract features from small sample fault recording data, including first incorporating a global attention mechanism (GLFM), using the features of the sequence extracted by the multi-head attention layer to further learn a more complex nonlinear mapping through a feedforward layer with a multi-layer perceptron, so that the model learns a richer representation, and finally extracting the local correlation features of the sequence through the attention layer. The information captured by each layer is fused through residual connections between the multi-head self-attention layer, the feedforward layer, and the convolutional attention layer. In the first layer, the standard WGAN uses random vectors to generate a synthetic spectrogram, and the second layer converts the synthetic image generated by the first layer into an accurate synthetic time series by introducing a conditional WGAN.
[0018] Furthermore, the improved TS-GAN fault generation model is used to extract features from small sample fault recording data, and the attention mechanism embedded in the lightweight architecture is used to enable the model to have dynamic feature selection capabilities, autonomously focusing on key signal changes during the fault occurrence period. First, the query matrix is calculated. With the key matrix of To obtain the similarity, we then divide by and through The function normalizes it to obtain the score matrix ; Then the score matrix and value matrix Multiply and calculate the attention matrix :
[0019] ,
[0020] Input of the attention matrix After linear transformation, the output of this layer is expressed as:
[0021] ,
[0022] in, are learnable network weight parameters.
[0023] Furthermore, the improved TS-GAN-based fault generation model is used to generate fault discrimination on the extracted features, including using a discriminator to evaluate the input latent coding sequence and determine whether it comes from the real data distribution, wherein the discriminator first uses the function Scoring the hidden code sequence, It indicates the probability that the sequence belongs to the real fault sequence, outputs the binary classification result through feature comparison, and then uses the encoding layer to convert the random sequence Convert to latent code ; Secondly, conditional distribution calculation by modeling the Markov dependence of the hidden states, to represent the temporal dynamics in the hidden encoding sequence, and the second layer further approximates the true conditional distribution by re-computing to ensure that the generated hidden encoding sequence is close to the distribution of the actual fault sequence.
[0024] Further, the method of using the improved TS-GAN-based fault generation model to generate and discriminate faults based on the extracted features further comprises using a generator to generate original fault samples, wherein, first, an encoding layer is used to convert a random sequence into a hidden encoding ; second, a conditional distribution is calculated by modeling the Markov dependence of the hidden states to ensure the temporal coherence of the generated sequence, so that the generated fault sequence hidden encoding has similar probability characteristics to the real sequence, to represent the temporal dynamics in the hidden encoding sequence, and the second layer further approximates the true conditional distribution by re-computing to ensure that the generated hidden encoding sequence is close to the distribution of the actual fault sequence.
[0025] Further, the method of training the model by using small sample fault recording data as samples comprises performing contrastive learning by calculating the similarity of the samples to distinguish similar samples and dissimilar samples, so as to enable the model to obtain more discriminative feature representations. The training process of the contrastive learning comprises, in each iteration, randomly selecting samples from the training set, and generating samples for each sample by applying a random augmentation strategy to the sample. For any sample, only its augmented version is regarded as a positive sample, and the remaining 2n-2 samples in the batch are regarded as negative samples, thereby constructing a contrastive learning task. Then, all samples are encoded using a generalized linear feature mapping (GLFM) to obtain low-dimensional feature representations. Finally, a loss function is used to calculate the similarity of positive and negative sample pairs by using a normalized temperature scaling strategy to calculate the contrastive loss to achieve discriminative learning in the feature space, wherein the contrastive loss is defined as:
[0026] ,
[0027] In the formula: represents a contrastive learning coefficient, is a similarity function, the cosine similarity z is used as the similarity function, and represents the dot product between and after L2 regularization.
[0028] Further, the evaluation and optimization of the trained model comprises objective analysis of the generated fault samples by three indicators, specifically including: quantifying the difference between the generated fault samples and the simulation samples by L distance; measuring the similarity between the two samples by brightness, contrast and structural information; and evaluating the signal quality of the generated samples by peak signal ratio of the generated samples, wherein, for two fault samples and The structural similarity index is expressed as:
[0029] ,
[0030] In the formula: is the mean value of the sample ; is the mean value of the generated sample ; is the variance of the sample ; is the variance of the generated sample ; is the covariance of and .
[0031] Further, the evaluation and optimization of the trained model also comprises analysis of the similarity between the real electrical quantity and the generated electrical quantity from the time domain and the frequency domain, wherein in the time domain, the parameters of the generated small sample fault sequence are quantified by the Hellinger distance HD and the mean absolute error MAE to quantify the similarity, and in the frequency domain, the local frequency spectrum difference between the generated data and the real data is calculated, and the average frequency spectrum error The similarity between each generated fault sequence and the real fault sequence is analyzed and expressed as:
[0032] ,
[0033] ,
[0034] In the formula: represents the frequency domain representation of the generated data, represents the frequency domain representation of the real fault sequence, represents the spectrum of the real fault sequence most similar to the generated fault sequence , and are the serial numbers of the generated fault sequence and the real fault sequence respectively, is the spectrum segmentation serial number, represents the number of generated samples, is the number of real samples, is the sum of the number of spectrum segments.
[0035] Further, the evaluation and optimization of the trained model further comprises adopting a t-SNE dimension reduction method, projecting 1000 randomly extracted samples to a two-dimensional plane while maintaining the topological relationship of high-dimensional data, verifying the data distribution fitting ability of the generated model under the same training parameters by analyzing the distribution coincidence degree of TS-GAN generated samples and real samples in two-dimensional space, wherein, in a given parameter space, a circular neighborhood with a radius d is constructed centered on each sample point; then the number of sample points contained in each neighborhood is counted, and the average value of the statistical results of all sample points is taken; divide the average value by the density of instance points in the parameter interval to obtain the Rispley's function value when the distance is , which is expressed as:
[0036] ,
[0037] In the formula: is the area of the parameter interval; is the number of parameter interval sample points; is the distance between different sample points; characterizes the positional relationship between the sample point and the circle.
[0038] In a second aspect, a power grid fault recording data enhancement system based on an improved TS-GAN includes:
[0039] A data acquisition module configured to acquire small sample fault recording data;
[0040] A preprocessing module configured to preprocess the acquired small sample fault recording data;
[0041] A feature extraction module configured to perform feature extraction on the small sample fault recording data using a fault generation model based on an improved TS-GAN;
[0042] A fault generation module configured to generate and discriminate faults using the extracted features using a fault generation model based on an improved TS-GAN;
[0043] A training module configured to train the model using small sample fault recording data as samples;
[0044] An optimization module configured to evaluate and optimize the trained model;
[0045] An enhancement module configured to perform data enhancement on power grid fault recording data using the optimized model.
[0046] In a third aspect, the present application provides a computer readable storage medium, wherein a plurality of instructions are stored, the instructions being adapted to be loaded by a processor of a terminal device and to execute the improved TS-GAN-based power grid fault recording data enhancement method.
[0047] In a fourth aspect, the present application provides a terminal device, comprising a processor and a computer readable storage medium, the processor being configured to implement instructions, and the computer readable storage medium being configured to store a plurality of instructions, the instructions being adapted to be loaded by the processor and to execute the improved TS-GAN-based power grid fault recording data enhancement method.
[0048] In summary, the present application has the following beneficial technical effects:
[0049] Firstly, by analyzing the causes and properties of small sample data, and by virtue of the excellent ability of TS-GAN in sample generation and expansion, a small sample fault generation model is used for extraction and learning fusion for model training and obtaining a large number of small sample faults. Secondly, by generating fault samples containing small sample data based on TS-GAN, and combining with subsequent models, the diagnostic ability of the fault diagnosis model is better improved, thereby improving the overall accuracy of the research method.
[0050] The TS-GAN itself is improved by fusing a convolutional self-attention layer and a multi-head self-attention layer to strengthen the learning of local feature differences, so as to help the generator more accurately and comprehensively capture the local and global features of the time series, and ensure that the discriminator pays attention to the overall distribution characteristics of the multivariate time series while not reducing the synthesis quality of a single variable in the channel, and better test the diagnostic ability of the fault diagnosis model. BRIEF DESCRIPTION OF DRAWINGS
[0051] Figure 1 is an improved TS-GAN model architecture diagram of embodiment 1 of the present application.
[0052] Figure 2 is a small sample data generation diagram based on TS-GAN of embodiment 1 of the present application.
[0053] Figure 3 is a fault generation diagram of embodiment 1 of the present application.
[0054] Figure 4 is a real fault sequence distribution of embodiment 1 of the present application.
[0055] Figure 5 is a generated fault sequence distribution diagram of embodiment 1 of the present application.
[0056] Figure 6 is an example point distribution Rispley's K curve diagram of embodiment 1 of the present application. DETAILED DESCRIPTION
[0057] The application will be further described in detail below with reference to the accompanying drawings.
[0058] Example 1
[0059] Referring to Figure 1 , the power grid fault recording data enhancement method based on improved TS-GAN of the embodiment comprises:
[0060] The embodiment adopts the actual fault recording data set of Dongfang Electronics to obtain three-phase current and three-phase voltage data. Four kinds of faults including A, B, C and ground faults are simulated. The simulated data is combined with the real power grid fault recording data. According to the extracted small sample faults 1853 in the real fault recording data, the small sample fault types are divided into three categories. In the real power grid fault occurrence scene, the scene instances with fault recording duration within 400 ms account for more than 90%. For each actual occurrence instance, 2400 sample data points are collected within 200 milliseconds before and after the fault occurrence time point, so as to construct the data set of the real small sample fault. If the data amount in the extracted fault recording is insufficient, it will be manually supplemented to 2400 data points according to the trend of the sequence.
[0061] S1 data processing,
[0062] The fault recording data in this data set covers electrical parameters at each time point. This data processing method ensures the integrity and accuracy of the data set, and can effectively supplement the data even in the case of insufficient original data amount, thereby laying a foundation for the reliability of subsequent model training. In this way, researchers can more accurately capture the specific situation of power grid faults, thereby improving the safety and stability of the power grid. When the sampling frequency is large, the electrical quantity sequence can be estimated from the adjacent sample points. Therefore, the following data is measured by time:
[0063] ,
[0064] as the input data of TS-GAN.
[0065] In the fault recording data, the electrical quantity index constitutes a time series process , where represents a discrete time point, represents a fault characteristic parameter, is a fault parameter space. These parameters obey the probability distribution , and the trajectory sequence is a discrete set, which realizes the discrete representation of the continuous process. Since the trajectory sequence is a discrete set, the electrical quantity state can be represented as , if the model generates fault recording data electrical quantities , and it obeys the probability distribution , then the probability distribution generated by the model , needs to be close to the sequence distribution in the real scene . The performance in the data generation model is represented by the parameter , represent the model parameter space) satisfies the following formula:
[0066] ,
[0067] In the formula: represent the distance between the different distributions.
[0068] The input sequence sampling frequency of the generation model is set to 2000 Hz in this paper. For a real recording sequence with 2400 sampling points, step-by-step sampling is performed for each sampling point starting from the recording start point, thereby expanding a single real fault data sequence into a training data set containing multiple sampling points. Each segment corresponds to consecutive time points in the original sequence. This method can significantly increase the amount and diversity of training data. This sliding window method not only improves data utilization, but also enhances the model's ability to learn and predict under different conditions, thereby better simulating actual power grid fault conditions. This method ensures that the model can more accurately understand and capture the time dynamic characteristics of power grid faults, improving the model's robustness and generalization ability, ultimately contributing to improved power grid safety and stability.
[0069] S2 TS-GAN model architecture improvement,
[0070] The basic architecture of TS-GAN applied in this paper consists of two WGANs (Wasserstein Generative Adversarial Networks): standard WGAN and conditional WGAN. In this paper, WGAN uses the Wasserstein distance to measure the similarity between two probability distributions, which is used to simulate the true distribution of synthetic data. Through this double-layer TS-GAN architecture, time series data can be effectively generated.
[0071] Improvements are made to the traditional TS-GAN structure model, as shown in Figure 3 , first of all, the global attention mechanism GLFM is integrated, the features extracted by the multi-head attention layer are further learned to more complex nonlinear mappings through the feedforward layer with multiple layers of perceptron, so that the model learns more rich representations. Finally, the local correlation features of the sequence are extracted through the attention layer, and the information captured by each layer is fused through residual connection between the multi-head self-attention layer, the feedforward layer and the convolutional attention layer.
[0072] Figure 1 The TS-GAN model architecture is improved.
[0073] In the first layer, the standard WGAN generates synthetic spectrograms using random vectors. This process produces preliminary synthetic data that, while similar to real data, is not yet accurate enough. The second layer converts the synthetic images generated by the first layer into more accurate synthetic time series by introducing a conditional WGAN. The conditional WGAN plays a crucial role in this process, further optimizing and adjusting the generated data based on specific conditions to make it closer to actual time series data.
[0074] Through this two-stage approach, TS-GAN not only generates high-quality synthetic time series data but also significantly improves the accuracy and reliability of subsequent model recognition. This method allows researchers to better simulate and analyze power grid failures, thereby enhancing the safety and stability of the power grid.
[0075] The embedding of the attention module enables the model to dynamically select features and focus on key signal changes during fault periods. This lightweight architecture has the following advantages over traditional deep networks: it reduces the number of parameters and can shorten the average diagnostic response time. Relying solely on the eigenvalues of random matrices for data analysis without considering the eigenvectors may result in the omission of key information from the signal.
[0076] The multi-head attention calculation used in the GLFM module is as follows:
[0077] First, calculate the query matrix and the key matrix : to obtain the similarity, then divide by , and normalize it through the function to obtain the score matrix :
[0078] (3-1)
[0079] Then, multiply the score matrix with the value matrix to calculate the attention matrix :
[0080] (3-2)
[0081] The input of the attention matrix undergoes linear transformation to obtain the output of this layer, where are learnable network weight parameters.
[0082] (3-3)
[0083] The calculation process of the convolutional self-attention layer is as follows, where Indicates that the convolution kernel size is One-dimensional convolution. First, the input of the previous layer Divide the whole into multiple local blocks , and then use a one-dimensional convolution operation to learn each local block of .in:
[0084] (3-4)
[0085] Where: Represents the convolution kernel Positional weight; Indicates the convolution kernel size; Indicates the channel size of input and output; Represents the feature position on the local block The feature tensor of .
[0086] During the experiment, choose The convolution kernel is used to focus on short-term temporal correlation. This short-term correlation is more critical to the local details of the sequence.
[0087] calculate and dot product of , and then divided by the key vector Square root of dimension ,use The function normalizes it and compares it with the value matrix Multiply to get the attention matrix between the slice and the block :
[0088] (3-5)
[0089] The convolutional self-attention layer uses Perform convolution operations on different groups of convolution kernels and calculate the attention matrix ,Will The final output of this layer is obtained after linear transformation :
[0090] (3-6)
[0091] S3 Fault recording generation model based on improved TS-GAN,
[0092] In the data generation process, the generator first generates an image using a random noise vector (following a normal distribution) and a text feature vector. The generated image then continuously improves during training, gradually approaching the real image. The discriminator determines whether the input image is a real sample (or an image generated by the generator).
[0093] The network structure includes: the input layer receives real images and generated images, combining them with input text features; convolutional layers extract image features through multiple layers of convolution and use leaky or ReLU activation functions to prevent gradient vanishing; feature fusion combines text features with temporal features; this can be achieved through concatenation or a weighted fusion using an attention mechanism; the fully connected layer, after a series of convolution and pooling layers, outputs the final judgment result. Finally, the output layer outputs a probability value, indicating that the sample is a real sample. TS-GAN training is adversarial, with the generator and discriminator trained alternately in two stages.
[0094] The core of TS-GAN lies in the accurate modeling of time series conditional probability. , the model focuses on capturing the current state With historical data Conditional dependencies According to the probability model theory, the joint distribution can be decomposed into Generative Model The optimization goal is to make the approximate conditional distribution At any time Both are close to the true conditional distribution ,Fault Generation Model satisfy:
[0095] (3-7)
[0096] To ensure the model's ability to learn the dynamic characteristics of fault sequences, this paper adopts the hidden encoding space design in the TS-GAN framework. This encoding space can effectively characterize the conditional distribution characteristics of fault sequences and provide the necessary temporal information modeling capabilities for the generative model. The basic structure is as follows Figure 2 As shown in the figure, multi-level Gated Recurrent Unit (GRU) connections are used between modules. This specialized architecture of recurrent neural networks is designed specifically for modeling time series data. Through an improved gating system (reset gates and update gates), it dynamically regulates the information transmission path, effectively alleviating the long-term dependency learning difficulties of traditional RNNs and demonstrating excellent time series modeling capabilities in sequence analysis tasks.
[0097] Figure 2 The TS-GAN-based small sample data generation model calculation process is shown.
[0098] As shown in Figure 2 :
[0099] a loss function set;
[0100] a component loss;
[0101] discrimination outputs respectively representing generated sequences and real sequences;
[0102] reconstructed sequences;
[0103] auxiliary discrimination parameters;
[0104] hidden encodings respectively representing generated and real data. Through this design, the model can focus on the time dynamic characteristics of the fault sequence data, and not pay too much attention to the static features. Moreover, the model can better simulate and predict the connection of sample points in the power grid fault. Each module uses multi-level GRU to process sequence data, thereby enhancing the model's understanding and processing ability of time series.
[0105] In the fault sample generation model, the core component of the generation model includes:
[0106] (1) Encoder : Establishes the mapping of the time sequence feature space to the hidden space , encodes the original sequence into a low-dimensional representation through a function;
[0107] (3-8)
[0108] (2) State recursion calculation: The hidden state at each time inherits historical information and fuses the current input;
[0109] (3-9)
[0110] (3) Decoder : Through calculation, realize the inverse transformation of the hidden space to the feature space, output the reconstructed sequence, and this two-way mapping mechanism completely retains the time sequence dynamic characteristics of the sequence.
[0111] (3-10)
[0112] The calculation process of the discriminator and the generator of the TS-GAN model is completed in the hidden encoding space, and the specific calculation steps are:
[0113] (1) The main task of the discriminator is to evaluate the input hidden encoding sequence and determine whether it comes from the real data distribution. The discriminator first scores the hidden encoding sequence through the function The output score ranges from 0 to 1, representing the probability that the sequence belongs to the real fault sequence. The core function of this module is to perform discriminant analysis on the hidden encoding of real fault sequences and generated sequences, and output a binary classification result through feature comparison. This design realizes the quantitative evaluation of the distribution difference of the encoding space of the two types of sequences.
[0114] (2) The generator adopts a double-layer cascading architecture, and its operation mechanism is as follows: First, the encoding layer converts the random sequence into hidden encoding ; second, the conditional distribution is calculated , which ensures the time sequence coherence of the generated sequence by modeling the Markov dependence of the hidden state. This design makes the generated fault sequence hidden encoding have similar probability characteristics as the real sequence. The second layer further approximates the real conditional distribution by calculating again, ensuring that the generated hidden encoding sequence is as close as possible to the distribution of the actual fault sequence. This design not only ensures that the model can capture the time dynamic characteristics of the real fault sequence, but also improves the training effect of the model.
[0115] In the model application stage, according to the structure shown in Figure 3 , a data generation model is established, and a time series set corresponding to four different fault types is created. These data sets cover various fault conditions from normal samples to small fault samples, providing diverse samples for subsequent model training. After completing model training, enter the small sample data generation stage. In this stage, the trained model is used to generate new small sample fault sequences to verify the effectiveness and accuracy of the model. This method not only improves the model's ability to learn and predict under complex conditions, but also ensures its adaptability and robustness to actual power grid fault data. Ultimately, this helps to improve the safety and stability of the power grid.
[0116] Figure 3 Generate a fault generation diagram.
[0117] S4 Model training,
[0118] TS-GAN is a model for generating time series data. Below is an overview of the basic training steps and related formulas of the TS-GAN model. Training Steps Data Preparation Preprocess the time series data, including normalization, detrending, and de-periodicity, to prepare for model training. Model Structure Design The generator is responsible for generating sequences similar to real time series. The main function of the discriminator is to distinguish between real data and data generated by the generator. It generally uses a convolutional neural network (CNN) or other classification network. To improve the robustness of the model, this paper introduces the following learning methods:
[0119] The principle of contrastive learning is to calculate the similarity of samples, thereby distinguishing similar samples from dissimilar samples. This helps the model obtain more discriminative feature representations. The training process of contrastive learning is as follows: In each iteration, randomly select samples, and apply random enhancement strategies (such as geometric transformation, color perturbation, etc.) to each sample to generate samples ( Original samples+ enhanced samples); secondly, for any sample, only its enhanced version is regarded as a positive sample, and the remaining 2n-2 samples in the batch are regarded as negative samples, thereby constructing a contrastive learning task; then, the generalized linear feature map (GLFM) model is used to encode all samples to obtain their low-dimensional feature representation; finally, the
[74] The loss function calculates the similarity of positive and negative sample pairs through the normalized temperature scaling strategy and calculates the contrast loss , this loss function achieves discriminative learning in feature space by maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs. The definition of contrast loss is shown in formula (3-12):
[0120] (3-12)
[0121] Where: represents the contrastive learning coefficient, is the similarity function. The cosine similarity z is used as the similarity function, which represents the L2 regularization. and The dot product between is defined as shown in formula (3-13):
[0122] (3-13)
[0123] Where: express norm.
[0124] The loss function defines an adversarial loss function, and a typical loss function is as follows:
[0125] The discriminator loss function is shown in (3-14):
[0126] (3-14)
[0127] The generator loss is shown in (3-15):
[0128] (3-15)
[0129] In the formula: is the prediction of the discriminator for real data, is the fake data generated by the generator, is the real data distribution.
[0130] Hyperparameter tuning adjusts learning rate, batch size, network structure, and other hyperparameters according to training results to achieve the best generation effect. After training is completed, new time series data is generated using the generator, and the authenticity and usability of the generated data are evaluated through visualization, statistical testing (such as KS test), and other methods. The training of TS-GAN involves an adversarial process between the generator and the discriminator, and by alternately optimizing their loss functions, the generator can generate time series that are increasingly close to real data. The specific structure parameters are shown in Tables 1 and 2.
[0131] Table 1 Model parameters of the generator part
[0132] Neural network layer name Input vector dimension Output vector dimension Linear layer (16,100) (16,1500) Positional encoding layer (16,1500) (16,150,10) Normalization layer - - Global-local fusion module (16,150,10) (16,150,10) Dropout = 0.7 - - Feed forward block (16,11,50) (16,11,50) Conv2d (16,150,10) (16,3,1,150)
[0133] Table 2 Model parameters of the discriminator part
[0134] Neural network layer name Input vector dimension Output vector dimension Positional embedding (16,31,150) (16,11,50) Multi-headed self-attention (16,150,10) (16,11,50) Normalization layer (LN) Dropout = 0.7 - - Feed forward block (16,11,50) (16,11,50) Classification head (16,11,50) (16,1)
[0135] The model training adopts the steps of alternately training the generator and the discriminator: first, fix the generator and train the discriminator, then use real data and generated data to calculate the loss and update the weights, second, fix the discriminator and train the generator, optimize the quality of the generated data through the loss of the generator, and the discriminator will not be able to effectively distinguish the authenticity of the samples and achieve Nash equilibrium.
[0136] This section will analyze and verify the generation results from the aspects of authenticity and coverage, and compare them with the generation results of other baseline models to evaluate the credibility of the generated small sample fault data.
[0137] Parameter settings
[0138] The model parameters are updated by the Adam optimizer for hyperparameter tuning. The F1 score is used as the evaluation criterion for the model parameters. The model training and comparative experiments in this paper are carried out on a Windows system, using Python language based on the PyTorch framework. The experimental environment configuration is as follows: the RTX 3090 graphics card with CUDA 11.3 driver is used for GPU acceleration calculation.
[0139] S5-1 generating model evaluation indicators,
[0140] In the process of generating fault samples, artificial judgment is often limited by subjective factors. Therefore, in order to more objectively evaluate the performance of the model in generating fault samples, it is necessary to quantitatively compare with the fault samples generated by the simulation model. This paper aims to objectively analyze the generated fault samples through three indicators: 1) L distance is used to quantify the difference between the generated fault samples and the simulation samples. Through this indicator, the accuracy of the generated samples can be effectively evaluated. The smaller the L distance, the closer the generated samples are to the simulation samples in terms of features; 2) Structural Similarity (SSIM) is used to measure the similarity between the two samples in terms of brightness, contrast and structural information. The higher the SSIM value, the higher the similarity between the generated samples and the simulation samples in terms of structure, thus reflecting the good expression ability of the generated samples for fault features. 3) Peak Signal Noise Ratio (PSNR) is used to evaluate the signal quality of the generated samples. The higher the ratio of signal to noise, the better the generated samples perform in terms of noise resistance. Higher PSNR values represent that the generated samples inherit the characteristics of the true signal.
[0141] Let the input data sample be , the generated data sample be , and the distance between the two be The distance can be represented by formula (3-16), The distance represents the generation effect of the sample:
[0142] (3-16)
[0143] In time series data, the data at different time points can be considered similar to the pixels in an image, and the three elements of SSIM can also correspond to certain characteristics of time series data. Specifically: the mean value of time series data can be used to represent the average value in the entire time period; the contrast can be measured by calculating the standard deviation of the data, reflecting the volatility of the data in the time series; the structural similarity is measured by covariance. For two fault samples and The structural similarity index is shown as formula (3-17):
[0144] (3-17)
[0145] In the formula:
[0146] - the mean value of the sample ;
[0147] - the mean value of the production sample ;
[0148] - the variance of the sample ;
[0149] - the variance of the generated sample ;
[0150] - and the covariance.
[0151] and are constants used to maintain stability, and to avoid a denominator of 0, are often taken and . is the dynamic range of the pixel value, and is generally taken . The closer to 1, the more similar the two data samples are, and when the two time series data are exactly the same, the value of 1 is taken.
[0152] The peak signal ratio is a commonly used objective standard for evaluating the quality of generated data, the larger the value, the stronger the anti-noise ability of the generated sample number, and the expression is shown as formula (3-15):
[0153] (3-18)
[0154] In the formula: - the maximum value of the sequence information, - the mean square error of the data points.
[0155] S5-2 Sample authenticity evaluation,
[0156] In real power grid operation, various electrical quantities are collected and summarized by fault recording devices in real time. To ensure that the electrical quantities in the generated small sample fault sequence still meet the real fault recording constraint conditions, the generated fault sequence and the real fault sequence have high similarity, and the average similarity test and the frequency domain analysis test are carried out respectively:
[0157] (1) Overall similarity,
[0158] In this study, the similarity between the real and generated electrical quantities is analyzed from both time and interval aspects. In the time aspect, the parameters of the generated small sample fault sequence are quantified by the Hellinger distance (HD) and the mean absolute error (MAE) to measure the similarity. HD is used as a measure of overall similarity, with a value range of [0, 1], and the smaller the value, the higher the similarity between the two probability distributions. MAE reflects the average similarity of each corresponding interval in multiple intervals, and its value is also in the range of [0, 1], and the smaller the value, the higher the similarity. At the same time, the small sample fault sequence generated based on the Monte Carlo sampling (MCS) algorithm is used as a comparison to verify the similarity between the generated data and the real data through the calculation of HD and MAE. This analysis method provides strong support for evaluating the performance of the generation model and its application in actual fault diagnosis.
[0159] (3-19)
[0160] (3-20)
[0161] where, and are the electrical quantity distributions generated by different generation models, and are the electrical quantity sequences in a corresponding interval of the generated sequence.
[0162] The average similarity of the fault sequence samples generated by the two data enhancement methods the difference degree of the sample points in the key time interval in the corresponding interval and the average difference degree of all key intervals of the fault sequence can be defined as:
[0163] (3-21)
[0164] (3-22)
[0165] (3-23)
[0166] where, is the number of sequence parameters.
[0167] The overall similarity experimental data analysis shows that the similarity between the electrical quantities generated by the TS-GAN model and the real sequence is higher, and the The value reached 79.7%, which was higher than the 74.1% of the comparative model. The distribution similarity effect of the 8 parameters of the electrical quantity sequence generated by the TS-GAN model was better than that of the comparative model, and the most obvious was the shape feature parameter of the current sequence . Moreover, the difference between the fault sequence generated by the TS-GAN model and the real fault sequence in the partial interval segment was also smaller, with a minimum difference of 1.23%, which was smaller than the 3.02% of the comparative model. Among them, the minimum sample difference of the improved TS-GAN model in the current generation reached 0.58%, which had higher authenticity.
[0168] Table 3 Average degree similarity analysis
[0169]
[0170] In order to screen out sequences with better similarity to real electrical quantity sequences from the generated scene, the average Frechet distance between the generated fault sample sequence and its most similar real fault recording sequence was calculated as the maximum difference value. The average Frechet distance between the generated fault sequence and its most similar signal sequence in the fault recording sequence data generated based on the improved TS-GAN model was calculated: 0.11 based on the improved TS-GAN model, which was reduced by 0.01 compared with the comparative model. The experiment showed that more than 83.2% of the generated fault samples fell within the range of the most similar real fault sequence, which further proved the authenticity of the generated fault sequence.
[0171] (2) Frequency domain analysis
[0172] In order to verify whether the improved TS-GAN model can effectively capture the dynamic change law of electrical quantity in real power grid operation, the frequency domain analysis was carried out on the generated electrical quantity and compared with the MCS algorithm. According to formula (3-21), the average spectral error between the generated fault sequence and the real fault sequence was calculated , so as to evaluate the overall similarity of the spectrum. The most similar real fault sequence of each generated fault sequence was searched, and in order to calculate the local spectral difference between the generated data and the real data, formula (3-22) was introduced to calculate the average spectral error , and the similarity between each generated fault sequence and the real fault sequence was analyzed:
[0173] (3-24)
[0174] (3-25)
[0175] In the formula: represents the frequency domain representation of the generated data, represents the frequency domain representation of the real fault sequence, representing the generated fault sequence the spectrum of the most similar real fault sequence, and the sequence number of the generated fault sequence and the real fault sequence, respectively, the spectrum segment number, representing the number of generated samples, the number of real samples, the sum of the number of spectrum segments.
[0176] Table 4 Similarity of generated sequences
[0177]
[0178] As shown in Table 4, the experimental data shows that the generated electrical quantity sequence in , the spectrum of the error of the real fault sequence is controlled within 8%, the proposed fault sequence generation model can effectively learn the dynamic characteristics of the real electrical quantity sequence, and the generated simulation data has high spectral consistency with the real fault data. The transverse comparison shows that the sequence spectrum error generated by the improved TS-GAN model is significantly lower than that of the MCS algorithm, especially when the best matching real data is used, the error of TS-GAN is further reduced to below 6.5%. This difference highlights the advantage of TS-GAN in the fault data generation task, which more finely captures the distribution characteristics of the real data through the adversarial training mechanism as follows.
[0179] S5-3 Sample coverage evaluation,
[0180] To verify the coverage effect of the generated samples and the real samples, this section of the paper uses the dimensionality reduction visualization method to observe different electrical quantity sequences. As an important tool in the field of data visualization, t-SNE (t-distributed Stochastic Neighbor Embedding) realizes the effective conversion of high-dimensional data to low-dimensional representation through the dimensionality reduction process optimized by distribution. Its generated two-dimensional or three-dimensional scatter plot can clearly reflect the topological structure of the original data, greatly facilitating the exploratory analysis of complex data sets.
[0181] The t-SNE technology realizes the joint dimensionality reduction mapping of two samples, providing an effective visual analysis means for the evaluation of the generated model. The consistency degree of the distribution of the generated samples and the real samples in the low-dimensional space objectively reflects the restoration ability of the model to the characteristics of the original data, and is an important reference basis for model optimization.
[0182] First, randomly select samples and specify the sample size, set the shape as where by calculating the average value of each sample in the time dimension is one-dimensional; next, the t-SNE algorithm is used to process from 27 dimensions to 2 dimensions. The study uses the t-SNE dimension reduction technology to project 1000 randomly selected samples to a two-dimensional plane while maintaining the topological relationship of high-dimensional data. As shown in the experimental results of Figure 4 and Figure 5 , by analyzing the distribution coincidence of TS-GAN generated samples and real samples in two-dimensional space, the data distribution fitting ability of the generation model under the same training parameters is effectively verified.
[0183] Figure 4 is the distribution of the collected real fault sequence, Figure 5 is the generated fault sequence distribution graph.
[0184] As shown in Figure 4 and Figure 5 , the time sequence relationship of each group of electrical quantity sequence is presented in the form of scatter points. By clustering analysis on these time sequence distributions and drawing probability density contour maps, it can be observed that the generated small sample data presents a more extensive distribution characteristic in the parameter space than the real fault recording data coverage. In addition, the generated data covers some fault scenarios not recorded in the real data set, indicating that it has stronger diversity generation ability.
[0185] As shown in equation (3-26), the Rispley's function as a spatial point pattern analysis method, its calculation process can be divided into the following steps: first, in the given parameter space, a circular neighborhood with a radius of d is constructed with each sample point as the center; then the number of sample points contained in each neighborhood is counted, and the average value of the statistical results of all sample points is taken; finally, the average value is divided by the spatial density of sample points in the study area, so as to eliminate the influence of sample size on the analysis results. This standardization processing makes the K function can effectively evaluate the aggregation or dispersion characteristics of point distribution in a certain spatial scale. Divide the average value by the density of instance points in the parameter interval to obtain the Rispley's function value when the distance is , the calculation formula is as follows:
[0186] (3-26)
[0187] In the formula: is the area of the parameter interval; is the number of parameter interval sample points; is the distance between different sample points; characterizes the position relationship between the sample point and the circle, and:
[0188] (3-27)
[0189] The value range of the selected radius is , respectively, the value of the Rispely's K function corresponding to the sample point distribution generated by the improved TS-GAN model is calculated. As shown in , the Ripley's K function curves of three different data sets are compared: (1) the sample point distribution of the real fault recording data; (2) the scene sample point distribution generated by the comparison model; (3) the reference sample point uniformly distributed in the parameter space. Through the comparative analysis of the four groups Figure 6 function curves, the differences in the spatial distribution characteristics of different data sets can be quantitatively evaluated.
[0190] Figure 6 As shown in the figure, the Rispley's K curve of the example point distribution.
[0191] It is found that, in the same parameter range Figure 6 , the spatial aggregation degree of the uniformly distributed example points is the lowest, which meets the theoretical expectation. Further analysis shows that: when is small, the distribution of the real fault data is more scattered than the scene example points generated by the improved TS-GAN model; when is large, the distribution of the sample points generated by the improved TS-GAN model is more scattered than the real fault sample points. In addition, the real fault data presents local aggregation characteristics in the parameter space, and is only distributed in part of the area, while the sample points generated by the improved TS-GAN are more uniformly distributed, but show higher aggregation in a small range. Compared with the MCS algorithm, the improved TS-GAN has obvious advantages in the uniformity of parameter space coverage. Through the above analysis, compared with the real sample data, the sample coverage range generated by the TS-GAN model is larger, and the sample generated by the improved TS-GAN data enhancement model presents more optimal uniform distribution characteristics in the parameter space. Compared with the real fault data, this model can generate more unseen samples, which significantly expands the scene coverage range. Quantitative analysis shows that the
[0192] and values of the generated sample data are reduced by an average of 17.83% and 16.37% (average value) compared with the real data, which indicates that under the same evaluation criteria, the fault data generated by the improved TS-GAN model meets the preset rule requirements. Table 5 Generation sequence distribution interval
[0193]
[0194] Electrical quantity parameter Parameter interval growth rate % Electrical quantity parameter Parameter interval growth rate % I a ]] 7.82 U a ]]> 6.93 I b ]] 23.73 U b ]]> 16.38 I c ]] 6.00 U C ]]> 22.13 [io] 3.57 12.21 Electrical quantity parameter
[0195] By comparing the distribution intervals of key fault sequence parameters in the generated data and the real data, it is found that the fault parameter intervals of the generated scenarios are significantly expanded. The statistical results show that the growth rate of the parameter distribution interval is up to 89.79%, and the average growth rate is 19.44%. This phenomenon shows that the proposed generation method can effectively expand the distribution range of electrical quantity parameters, produce fault sequence variants not recorded in the real data, and thus significantly improve the diversity and scenario coverage ability of the generated data.
[0196] Embodiment 2
[0197] The embodiment provides a power grid fault recording data enhancement system based on an improved TS-GAN, comprising:
[0198] The data acquisition module is configured to:
[0199] A computer readable storage medium, wherein a plurality of instructions are stored, the instructions are suitable for being loaded and executed by a processor of a terminal device, and the instructions are suitable for being loaded and executed by the processor of the terminal device.
[0200] A terminal device, comprising a processor and a computer readable storage medium, the processor is used to implement instructions, and the computer readable storage medium is used to store a plurality of instructions, the instructions are suitable for being loaded and executed by the processor, and the instructions are suitable for being loaded and executed by the processor of the terminal device.
[0201] The above are preferred embodiments of the present application, and are not intended to limit the protection scope of the present application, therefore: any equivalent changes made on the basis of the structure, shape, principle of the present application should be covered within the protection scope of the present application.
Claims
1. A method for enhancing power grid fault recording data based on improved TS-GAN, characterized in that: include: Obtain small sample fault recording data; Preprocess the acquired small sample fault recording data; The improved TS-GAN-based fault generation model is used to extract features from small sample fault recording data. The fault generation model based on the improved TS-GAN is used to generate faults based on the extracted features; Use small sample fault recording data as samples for model training; Evaluate and optimize the trained model; Use the optimized model to enhance the power grid fault recording data; The obtained small sample fault recording data is preprocessed, including for a real recording sequence with 2400 sampling points, starting from the recording starting point, gradually sampling each sampling point, thereby expanding a single real fault data sequence into a set of training data sets containing multiple sampling points, each segment corresponds to a continuous time point in the original sequence, which is used to increase the quantity and diversity of training data, wherein, in the fault recording data, the electrical quantity index constitutes a time series process ,in represents a discrete time point, represents the fault characteristic parameter, is the fault parameter space, trajectory sequence is a discrete set, the electrical quantity state can be expressed as , if the model generates the electrical quantity of the fault recording data as , and it obeys the probability distribution , then the probability distribution generated by the model is , needs to be close to the sequence distribution in the real scene ; In the data generation model The performance is as parameters , Represents the model parameter space, satisfying: , in: A measure representing the distance between dissimilar distributions; The improved TS-GAN fault generation model is used to extract features from small sample fault recording data. The method includes first incorporating a global attention mechanism (GLFM), using the features of the sequence extracted by the multi-head attention layer to further learn a more complex nonlinear mapping through a feedforward layer with a multi-layer perceptron, so that the model learns a richer representation. Finally, the attention layer extracts the local correlation features of the sequence, and the residual connection between the multi-head self-attention layer, the feedforward layer, and the convolutional attention layer is used to fuse the information captured by each layer. In the first layer, a standard WGAN uses random vectors to generate a synthetic spectrogram. The second layer converts the synthetic image generated by the first layer into an accurate synthetic time series by introducing a conditional WGAN. The improved TS-GAN fault generation model is used to extract features from small sample fault recording data. The method also includes embedding a lightweight architecture attention mechanism to enable the model to have dynamic feature selection capabilities and autonomously focus on key signal changes during the fault occurrence period. First, the query matrix is calculated. With the key matrix of To obtain the similarity, we then divide by and through The function normalizes it to obtain the score matrix ; Then the score matrix and value matrix Multiply and calculate the attention matrix : , Input of the attention matrix After linear transformation, the output of this layer is expressed as: , in, is a learnable network weight parameter; The improved TS-GAN-based fault generation model is used to generate discriminative faults from the extracted features, including using a discriminator to evaluate the input latent coding sequence and determine whether it comes from the real data distribution, wherein the discriminator first uses the function d: t H→[0, 1] scores the hidden code sequence, It indicates the probability that the sequence belongs to the real fault sequence, outputs the binary classification result through feature comparison, and then uses the encoding layer to convert the random sequence Convert to latent code ; Secondly, conditional distribution calculation , by modeling the Markov dependencies of hidden states to ensure the temporal coherence of the generated sequence, Representing the temporal dynamic characteristics in the hidden coding sequence, the second layer further approximates the true conditional distribution by recalculating , ensuring that the generated latent code sequence is close to the distribution of the actual fault sequence; The model training is performed by using small sample fault recording data as samples, including performing comparative learning by calculating the similarity of samples, thereby distinguishing similar samples from dissimilar samples, and promoting the model to obtain more discriminative feature representations. The training process of comparative learning includes randomly selecting from the training set in each iteration. samples, and a random enhancement strategy is applied to each sample to generate samples, for any sample, only its enhanced version is regarded as a positive sample, and the remaining 2n−2 samples in the batch are regarded as negative samples, thereby constructing a contrastive learning task; then all samples are encoded using the generalized linear feature map GLFM to obtain a low-dimensional feature representation; finally, the The loss function calculates the similarity of positive and negative sample pairs through the normalized temperature scaling strategy and calculates the contrast loss , achieving discriminative learning in feature space, The contrast loss is defined as: , Where: represents the contrastive learning coefficient, is the similarity function, Cosine similarity is used as the similarity function.
2. The method for enhancing power grid fault recording data based on improved TS-GAN according to claim 1, characterized in that: The evaluation and optimization of the trained model includes objectively analyzing the generated fault samples through three indicators, specifically: using L distance to quantify the difference between the generated fault sample and the simulated sample; measuring the similarity between the two samples through brightness, contrast and structural information; and using the peak signal ratio of the generated sample to evaluate the signal quality of the generated sample. and , and its structural similarity index is expressed as: , Where: For samples The mean of For production samples The mean of For samples variance; To generate samples variance; for and The covariance of .
3. The method for enhancing power grid fault recording data based on improved TS-GAN according to claim 2 is characterized in that: The evaluation and optimization of the trained model also includes analyzing the similarity between the real electrical quantity and the generated electrical quantity from two aspects: time domain and frequency domain. In the time domain, the parameters of the generated small sample fault sequence are quantified using the Hellinger distance HD and the mean absolute error MAE. In the frequency domain, the local spectrum difference between the generated data and the real data is calculated, and the average spectrum error is calculated by Analyze the similarity between each generated fault sequence and the real fault sequence, which is expressed as: , , Where: represents the frequency domain representation of the generated data, represents the frequency domain representation of the real fault sequence, Represents the fault sequence generated The spectrum of the most similar real fault sequence, and are the serial numbers of the generated fault sequence and the real fault sequence respectively, is the spectrum segment number, represents the number of generated samples, is the actual sample size, is the sum of the number of spectrum segments.
4. The method for enhancing power grid fault recording data based on improved TS-GAN according to claim 3 is characterized in that: The evaluation and optimization of the trained model also includes using the t-SNE dimensionality reduction method to project 1000 randomly selected samples onto a two-dimensional plane while maintaining the topological relationship of the high-dimensional data. By analyzing the distribution overlap between the TS-GAN generated samples and the real samples in the two-dimensional space, the data distribution fitting ability of the generated model under the same training parameters is verified. In the given parameter space, a circular neighborhood with a radius of d is constructed with each sample point as the center; then the number of sample points contained in each neighborhood is counted, and the statistical results of all sample points are averaged; the average value is divided by the instance point density in the parameter interval to obtain the distance Rispley's Function Value , expressed as: , Where: is the area of the parameter interval; is the number of sample points in the parameter area; is the distance between different sample points; Characterizes the positional relationship between the sample point and the circle.
5. A power grid fault recording data enhancement system based on improved TS-GAN, executing the power grid fault recording data enhancement method based on improved TS-GAN according to claim 1, characterized in that: include: The data acquisition module is configured to acquire small sample fault recording data; The preprocessing module is configured to preprocess the acquired small sample fault recording data; The feature extraction module is configured to extract features from small sample fault recording data using a fault generation model based on an improved TS-GAN; The fault generation module is configured to generate fault discrimination based on the extracted features using the fault generation model based on the improved TS-GAN; The training module is configured to perform model training using small sample fault recording data as samples; The optimization module is configured to evaluate and optimize the trained model; The enhancement module is configured to perform data enhancement on the power grid fault recording data using the optimized model.
Citation Information
Patent Citations
Multi-view collaborative enhancement method for fault recording data of overhead transmission line
CN118094093A
Large thermal power generating unit blower surge fault early warning method based on multi-head attention generative adversarial network
CN119825733A