Voltage sag data enhancement method and system based on improved generative adversarial network
By improving the generation of voltage subsidence data that is close to real, the problem of insufficient voltage subsidence data is solved, the diversity and quantity of data is improved, and the model training effect is improved.
Patent Information
- Application Number
- CN202510437843.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-07-25
AI Technical Summary
Traditional voltage drop detection and prediction methods are difficult to effectively learn various types of characteristics when the voltage drop data sample distribution is unbalanced and the number is insufficient, resulting in poor prediction results.
The improved generation adversarial network (GAN) is used to generate near-real voltage drop data, and the adversarial training is carried out by training the generator network and the discriminator network, generating and adding a voltage drop historical data set to increase the data volume.
By generating voltage drop data close to the real one, the problem of limited voltage drop data is solved, the diversity and quantity of data is improved, and the model training effect is improved.
Smart Images

Figure CN120372285A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data augmentation, and particularly to a voltage sag data augmentation method and system based on an improved generative adversarial network. Background Art
[0002] Voltage sag is a common electrical phenomenon in power systems, referring to a short-term voltage drop caused by faults or other reasons, usually lasting from a few milliseconds to a few seconds. Voltage sag has an important impact on the stable operation of electrical equipment, the production process, and the safety of power systems.
[0003] Traditional voltage sag detection and prediction methods mainly rely on rule-based algorithms and statistical models. Among them, statistical models, such as time series analysis, regression analysis, etc., rely on historical data for trend prediction. However, due to the extremely unbalanced distribution of voltage sag data samples (e.g., the proportion of single-phase fault sags is much higher than other types), and the fact that the distribution characteristics of sag events vary greatly in different seasons and regions, traditional methods require a large amount of sample data for model training. When the sample quantity distribution is unbalanced or small, it is difficult to fully learn the characteristics of each type, and the prediction effect of statistical models is not good. Therefore, how to solve the problem of limited voltage sag data needs to be solved urgently. Summary of the Invention
[0004] The embodiments of this application provide a voltage sag data augmentation method and system based on an improved generative adversarial network. By training the improved generative adversarial network to generate voltage sag data close to the real ones, a large amount of voltage sag data can be obtained, solving the problem of limited voltage sag data.
[0005] In a first aspect, the embodiments of this application provide a voltage sag data augmentation method based on an improved generative adversarial network, including:
[0006] Obtain a voltage sag historical data set and a first improved generative adversarial network; the first improved generative adversarial network includes a first generator network and a first discriminator network;
[0007] Select training data and test data from the voltage sag historical data set to obtain a first training data set and a first test data set;
[0008] Randomly generate voltage sag data according to the first training data set through the first generator network to obtain first voltage sag data;
[0009] Perform adversarial training on the first improved generative adversarial network using the first training data set and the first voltage sag data until the first improved generative adversarial network meets a preset training termination condition, to obtain a second improved generative adversarial network; the second improved generative adversarial network includes a second generator network and a second discriminator network;
[0010] Input the first test data set into the second generator network to obtain second voltage sag data; add the second voltage sag data to the voltage sag historical data set.
[0011] In a second aspect, an embodiment of the present application provides a voltage sag data enhancement system based on an improved generative adversarial network, including: an acquisition unit and a data enhancement unit, where:
[0012] The acquisition unit is configured to acquire a voltage sag historical data set and a first improved generative adversarial network; the first improved generative adversarial network includes a first generator network and a first discriminator network; select training data and test data from the voltage sag historical data set to obtain a first training data set and a first test data set;
[0013] The data enhancement unit is configured to randomly generate voltage sag data according to the first training data set through the first generator network to obtain first voltage sag data; perform adversarial training on the first improved generative adversarial network using the first training data set and the first voltage sag data until the first improved generative adversarial network meets a preset training termination condition, to obtain a second improved generative adversarial network; the second improved generative adversarial network includes a second generator network and a second discriminator network; input the first test data set into the second generator network to obtain second voltage sag data; add the second voltage sag data to the voltage sag historical data set.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and are configured to be executed by the processor, and the programs include instructions for performing the steps in the first aspect of the embodiments of the present application.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program for electronic data exchange, and the computer program causes a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application.
[0016] Fifth aspect, embodiments of the present application provide a computer program product, where the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application. The computer program product may be a software installation package.
[0017] Implementing the present application has the following beneficial effects:
[0018] It can be seen that the voltage sag data enhancement method based on the improved generative adversarial network described in the present application obtains a voltage sag historical data set and a first improved generative adversarial network; selects training data and test data from the voltage sag historical data set to obtain a first training data set and a first test data set; randomly generates voltage sag data according to the first training data set through the first generator network to obtain first voltage sag data; performs adversarial training on the first improved generative adversarial network with the first training data set and the first voltage sag data until the first improved generative adversarial network meets a preset training termination condition to obtain a second improved generative adversarial network; inputs the first test data set into the second generator network to obtain second voltage sag data; adds the second voltage sag data to the voltage sag historical data set; by training the improved generative adversarial network to generate voltage sag data close to the real ones, a large amount of voltage sag data can be obtained, and adding these voltage sag data to the voltage sag historical data set solves the problem of limited voltage sag data. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background art, the drawings required to be used in the embodiments of the present application or the background art will be described below.
[0020] Figure 1 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
[0021] Figure 2 is a flowchart of a voltage sag data enhancement method based on an improved generative adversarial network provided by an embodiment of the present application;
[0022] Figure 3 is a schematic structural diagram of an improved generative adversarial network provided by an embodiment of the present application;
[0023] Figure 4 is a schematic structural diagram of a first generator network provided by an embodiment of the present application;
[0024] Figure 5 is a schematic structural diagram of a first discriminator network provided by an embodiment of the present application;
[0025] Figure 6It is a training flow chart of an improved generative adversarial network provided by an embodiment of the present application;
[0026] Figure 7 It is a block diagram of the functional units of a voltage sag data enhancement system based on an improved generative adversarial network provided by an embodiment of the present application;
[0027] Figure 8 It is a schematic structural diagram of another electronic device provided by an embodiment of the present application. Detailed implementation manners
[0028] In order to enable those skilled in the art to better understand the solution of 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. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0029] Terms such as "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices.
[0030] It should be understood that the term "and / or" in this article is only a description of the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article indicates that the associated objects before and after are in an "or" relationship. The "multiple" that appears in the embodiments of the present application refers to two or more.
[0031] The "at least one (piece)" or its similar expression in the embodiments of the present application refers to any combination of these items, including any combination of single items (pieces) or plural items (pieces), referring to one or more, and multiple refers to two or more. For example, at least one (piece) of a, b or c can represent the following seven situations: a, b, c, a and b, a and c, b and c, a, b and c. Each of a, b, and c can be an element or a set containing one or more elements.
[0032] In the embodiments of the present application, the "connection" that appears refers to various connection methods such as direct connection or indirect connection, etc., to achieve communication between devices. The embodiments of the present application do not make any limitations on this.
[0033] Referring to "embodiments" in this context means that the specific features, structures, or characteristics described in conjunction with the embodiments may be included in at least one embodiment of the present application. The phrase appears in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0034] The electronic devices described in the embodiments of the present application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, handheld computers, laptop computers, video matrices, monitoring platforms, mobile internet devices (MID), or wearable devices, etc. The above are only examples, not an exhaustive list, including but not limited to the above devices.
[0035] Of course, the above electronic device may also be a server, for example, a cloud server.
[0036] The relevant content, concepts, meanings, technical problems, technical solutions, beneficial effects, etc. involved in the embodiments of the present application are described below.
[0037] First, some professional terms involved in the present application are explained:
[0038] Voltage sag data: It refers to the phenomenon that the effective value of the supply voltage suddenly drops and then rises and recovers in a short period of time. According to the definition of the Institute of Electrical and Electronics Engineers (IEEE), the root mean square value of its voltage decreases to between 0.1 and 0.9 times the rated voltage, and the duration is from 0.5 cycle to 1 minute. Voltage sag data is the relevant data recording this voltage change process, including information such as voltage amplitude, duration, and occurrence time. These data are of great significance for the fault analysis of power systems, the assessment of power quality, and the guarantee of the normal operation of equipment.
[0039] Generative adversarial network (GAN): It is a deep learning model composed of two neural networks, a generator network and a discriminator network. The generator network attempts to generate realistic data samples, while the discriminator network attempts to distinguish whether the input data is a real sample or a fake sample generated by the generator network. The two continuously improve their performance through adversarial training until the generator network can generate data that is realistic enough to pass for real.
[0040] Improved Generative Adversarial Network (Improved GAN): It is optimized and improved based on the traditional GAN to meet specific task requirements or solve some problems existing in the traditional GAN, such as unstable training, mode collapse, etc. In the scenario of voltage sag data augmentation, the improved generative adversarial network may have been adjusted in terms of network structure, loss function design, training strategy, etc., enabling it to better learn the feature distribution of voltage sag data and generate voltage sag data closer to the real situation.
[0041] Loss function: It is a function used to measure the difference between the model's prediction result and the true label. In machine learning and deep learning, the goal of training a model is to minimize the value of the loss function by adjusting the model's parameters. For a generative adversarial network, there are usually a loss function for the generator network and a loss function for the discriminator network. The loss function of the generator network measures the ability of the generator network to generate fake samples that are misjudged as real samples by the discriminator network, and its goal is to make the discriminator network judge the generated samples as real samples as much as possible; the loss function of the discriminator network measures the ability of the discriminator network to distinguish real samples and generated samples, and its goal is to accurately distinguish real samples and fake samples. By minimizing these loss functions, the generator network and the discriminator network continuously improve their respective performances.
[0042] Feature map: It is the intermediate output result of deep learning models such as improved GAN when processing data such as images and signals. In the convolutional layer, the convolutional kernel (filter) performs a convolutional operation on the input data to extract different features, and the output of each convolutional kernel is a feature map. The feature map can be regarded as a feature representation of the input data, which contains the feature information of the input data at different scales and positions. As the number of network layers increases, the features represented by the feature map become more and more abstract and advanced. In voltage sag data processing, the feature map may be used to represent different features of voltage sag data, such as amplitude change features, time series features, etc.
[0043] Backpropagation algorithm: It is one of the core algorithms for training neural networks in deep learning. Its basic idea is to calculate the gradient of the loss function with respect to each parameter in the network, and then update the parameters according to the direction and magnitude of the gradient, so that the value of the loss function gradually decreases. Specifically, the backpropagation algorithm first performs forward propagation, passing the input data into the neural network to obtain the output result, and then calculates the loss value between the output result and the true label. Then, starting from the loss function, the partial derivative (i.e., gradient) of the loss function with respect to each parameter is calculated backward using the chain rule. Finally, according to the gradient descent method, the parameters are updated in the opposite direction of the gradient. By continuously repeating this process, the parameters of the network are continuously optimized, and the performance of the model is also continuously improved.
[0044] Adam Optimizer: It is an optimization algorithm with an adaptive learning rate, combining the advantages of the adaptive gradient algorithm and the root mean square propagation algorithm. When training a neural network, it can adaptively adjust the learning rate of each parameter, making the training process more stable and efficient. The Adam optimizer dynamically adjusts the learning rate by calculating the first moment estimate (mean) and the second moment estimate (variance) of the gradient. In each iteration, it calculates the adaptive learning rate for each parameter based on the first moment and second moment estimates of the gradient, and then uses this learning rate to update the parameters. Compared with the traditional Stochastic Gradient Descent (SGD) algorithm, the Adam optimizer can converge faster and perform better when dealing with datasets of different scales and complex network structures. In this application, the Adam optimizer can be used to update and improve the parameters of the generator network and the discriminator network in the generative adversarial network.
[0045] Please refer to Figure 1 , Figure 1 which is a schematic structural diagram of an electronic device provided by an embodiment of this application. It can be seen that the electronic device may include: a communication module, a model training module, a data augmentation module, etc., which are not limited here. Among them:
[0046] The communication module is responsible for data transmission and interaction. On the one hand, it can obtain the voltage sag historical dataset from an external data source (for example, the database of the power system), input it into the electronic device, and provide the basic data for subsequent data processing and model training. On the other hand, it can output the voltage sag data after data augmentation to other devices or systems for further analysis and application, such as for the training of the fault diagnosis model of the power system.
[0047] The model training module is used to train the improved generative adversarial network. It can randomly select training data and test data from the voltage sag historical dataset to generate a first training dataset and a first test dataset, and input the first training dataset into the improved generative adversarial network. During the training process, the model training module adjusts the parameters of the generator network and the discriminator network, calculates the loss function using the backpropagation algorithm, and uses methods such as the Adam optimizer to update the network parameters according to the value of the loss function, so that the generator network can generate samples closer to the real voltage sag data until the improved generative adversarial network meets the preset training termination condition, and a trained improved generative adversarial network is obtained.
[0048] The data augmentation module is used to generate new voltage sag data through a trained improved generative adversarial network to achieve the purpose of data augmentation. It can input the first test data set into the generator network of the trained improved generative adversarial network to generate a large amount of voltage sag data, and then add these newly generated voltage sag data to the voltage sag historical data set. Thus, the number of voltage sag data is increased, and the problem of limited voltage sag data is solved.
[0049] Please refer to Figure 2 , Figure 2 which is a flowchart of a voltage sag data augmentation method based on an improved generative adversarial network provided by an embodiment of the present application, and can be applied to an electronic device as shown in Figure 1 . The method includes but is not limited to the following steps:
[0050] S201. Obtain a voltage sag historical data set and a first improved generative adversarial network; the first improved generative adversarial network includes a first generator network and a first discriminator network.
[0051] In an embodiment of the present application, each historical data in the voltage sag historical data set may include at least one of the following: sag occurrence time, sag duration, sag depth, sag occurrence location, phase information, power system operation parameters, sag device information, etc., which are not limited herein.
[0052] In a specific embodiment, the electronic device may obtain the voltage sag historical data set from the Internet, or the electronic device may be communicatively connected to the power system, obtain authorization from the power system, access the system database of the power system, and obtain the voltage sag historical data set from the system database. Then, the architecture of the improved generative adversarial network can be designed according to the characteristics of the voltage sag data and the requirements of data augmentation to obtain the first improved generative adversarial network.
[0053] It should be noted that in an embodiment of the present application, unless otherwise specified, the model refers to the first improved generative adversarial network.
[0054] In a certain embodiment, please refer to Figure 3 , Figure 3 which is a schematic structural diagram of an improved generative adversarial network provided by an embodiment of the present application; it can be seen that the first improved generative adversarial network may include: a first generator network and a first discriminator network.
[0055] In a certain embodiment, please refer to Figure 4 , Figure 4 which is a schematic structural diagram of a first generator network provided by an embodiment of the present application; it can be seen that the first generator network may include: a first convolutional module and a first fully connected module.
[0056] Among them, the first convolutional module consists of three convolutional layers: the convolutional kernel size of each convolutional layer is 5×5×5, the stride is 2, and the number of convolutional kernels is 64; the convolutional kernel size of 5×5×5 represents the size of the convolutional kernel in three dimensions, which can extract local features from the input data; the stride of 2 means that when the convolutional kernel moves on the input data, it moves 2 units each time, which will reduce the size of the feature map. 64 convolutional kernels can extract 64 different features from the input data, thereby increasing the richness of features. After the three convolutional layers, three fully connected layers are connected. These three fully connected layers form the first fully connected module, and each fully connected layer contains 128 nodes. The role of the fully connected layer is to integrate and transform the features extracted by the convolutional layer to obtain the final output.
[0057] In one embodiment, please refer to Figure 5 , Figure 5 which is a schematic structural diagram of a first discriminator network provided by an embodiment of the present application; it can be seen that the first discriminator network may include: a second convolutional module, an attention module, and a target fully connected module.
[0058] Among them, the second convolutional module contains four convolutional layers, and the size and stride of the convolutional layer are the same as those of the convolutional layer of the first generator network, that is, the convolutional kernel size is 5×5×5, the stride is 2, and the number of convolutional kernels is 64; the working principle of the second convolutional module is the same as that of the first convolutional module, and will not be elaborated here.
[0059] The attention module is connected behind the second convolutional module to further optimize the feature extraction process; the attention module can automatically learn the importance of each feature in the input data, and by assigning different weights to different features, emphasize the important features and ignore the unimportant features. For example, in voltage sag data, it can focus on key features such as sag depth and duration, improve the sensitivity of the first discriminator network to these key information, and thus more accurately judge the category of the data.
[0060] The target fully connected module is connected behind the attention module. The target fully connected module may include one or more fully connected layers, and each fully connected layer contains 128 nodes. The target fully connected module can summarize all the features extracted by the second convolutional module and the attention module, and through operations such as weighted summation, map them to multiple output nodes, each node corresponding to a category, output the probability of this category, obtain multiple probabilities, and determine the probability value that the input data is real data according to these multiple probabilities, and finally output this probability value to judge the authenticity of the input data.
[0061] S202. Select training data and test data from the voltage sag historical dataset to obtain a first training dataset and a first test dataset.
[0062] In the embodiments of the present application, a preset number (e.g., 1000 pieces) of data can be randomly selected from the voltage sag historical dataset. Then, these data can be divided according to the ratio of 70%-80% for training and 20%-30% for testing. For example, if there are 1000 pieces of voltage sag historical data, 700-800 pieces of data can be randomly selected as the first training dataset, and the other 200-300 pieces of data can be used as the first test dataset.
[0063] S203. Randomly generate voltage sag data according to the first training dataset through the first generator network to obtain first voltage sag data.
[0064] In the embodiments of the present application, the first generator network can refer to the first training dataset and randomly generate voltage sag data similar to the data in the first training dataset to obtain first voltage sag data.
[0065] Optionally, the first training dataset includes n training samples, and each training sample includes m feature information; both m and n are integers greater than 1; in step S203, the step of randomly generating voltage sag data according to the first training dataset through the first generator network to obtain first voltage sag data may include the following steps:
[0066] S31. Construct a high-dimensional input space according to the m feature information of each of the n training samples.
[0067] S32. Randomly generate first noise through a preset noise generation method.
[0068] S33. Determine constraint conditions according to the n training samples and the high-dimensional input space.
[0069] S34. Input the first noise and the constraint conditions into the first generator network to obtain the first voltage sag data.
[0070] In the embodiments of the present application, the preset noise generation method can be preset or default in advance.
[0071] In a specific embodiment, a high-dimensional input space can be constructed according to the m feature information of each of the n training samples. Specifically, relevant feature values can be extracted from the n training samples according to the m feature information to obtain k feature values, k = n * m. Then, these m feature information can be used as the dimensions of the high-dimensional space, and each feature corresponds to an axis, that is, there are m axes.
[0072] Further, each of the above k eigenvalues can be mapped into a high-dimensional space to form a point in the high-dimensional space. All these points together constitute a high-dimensional input space, which covers various characteristic information of voltage sag data and their mutual relationships, providing a basis for subsequent model training and analysis.
[0073] It should be explained that the high-dimensional input space refers to a complex data space constituted by multiple key characteristics (such as type of electrical equipment, operating power, voltage sag amplitude, etc.) of samples in the voltage sag historical dataset. For example, taking multiple characteristics such as the start time of the voltage sag event, equipment operation cycle, voltage sag amplitude, etc. as coordinate axes, the position of each sample in this multi-axis space forms a point in the high-dimensional input space, and numerous such points form a high-dimensional input space.
[0074] For example, assume the first training dataset is defined as: {S1, S2, ……, S i , ……, S n} = {{U i , d i , V i , F i , t i , Δt i , ……, t j , Δ j , ……}|D|, i = 1, 2, ……, n};
[0075] Among them, S i represents the i-th training sample in the first training dataset, and each training sample S i can include the following characteristic information:
[0076] U i : Represents the type of electrical equipment of this training sample, which is one of the core characteristics of the classification problem and is used to distinguish the affected equipment of the voltage sag;
[0077] d i : Represents the classification label, indicating the sag category to which the i-th sample belongs;
[0078] V i : Represents the voltage sag amplitude of the i-th training sample and is used to represent the voltage performance of the equipment during the sag event;
[0079] F i : Represents the operating power of the electrical equipment and reflects the load condition of the equipment;
[0080] t i : Represents the start time of the voltage sag event;
[0081] Δt i: Represents the device operation cycle, Δt i The magnitude of which is directly related to the time range during which the electrical equipment may be affected by voltage sags;
[0082] The data at the remaining time points (t j and Δ j ) describe the dynamic characteristics of the voltage sag, thus providing sufficient time series information for the samples. Specifically, t j represents the j-th time point, and Δ j represents the time interval between the j-th time point and the j - 1-th time point;
[0083] |D|: Represents the overall distribution or context constraints (such as the device operating environment) of the first training dataset.
[0084] Based on these multi-dimensional feature information contained in the first training dataset, a high-dimensional input space reflecting complex voltage sag patterns can be constructed, providing reliable training samples for the subsequent generator network and discriminator network; the integrity and diversity of the training samples are crucial for enhancing the generalization ability of the data generator network and the classification ability of the discriminator network.
[0085] Next, the first noise can be randomly generated through a preset noise generation method. For example, the preset noise generation method can be the uniform noise generation method. Using the probability density function of the uniform distribution, numerical values are randomly generated within a specified interval (such as [-1, 1]) to obtain the first noise. The uniform distribution can ensure the diversity and randomness of the noise, enabling the first generator network to explore all potential data spaces and thus generate various different voltage sag data.
[0086] It should be noted that the dimension of the generated first noise needs to be consistent with the input requirements of the first generator network and be able to capture the feature dimensions required for generating data. Simply put, the dimension of the first noise should be equal to the dimension of each training sample in the n training samples. For example, assuming the dimension of a certain training sample is (1, 1, 3), then the dimension of the first noise is also (1, 1, 3).
[0087] Next, the constraint conditions can be determined based on the n training samples and the high-dimensional input space. Specifically, statistical analysis can be performed on the data of each feature in the n training samples to obtain p statistical features. For example, statistical quantities such as minimum value, maximum value, mean value, and standard deviation. Another example is that for the feature of the voltage sag amplitude, by calculation, its minimum value in the training samples is 0.5 times the rated voltage, and the maximum value is 0.9 times the rated voltage. Then, the value range of each dimension in the high-dimensional input space can be determined according to the p statistical features to obtain m value ranges, and these m value ranges are the constraint conditions. Finally, the first noise and the constraint conditions can be input into the first generator network, and the first voltage sag data is generated by the first generator network. Specifically, the generation process of the first generator network can be expressed by the following formula:
[0088] V generated = G(z) = clip(V min , V max , G raw (z))
[0089] where V generated represents the first voltage sag data; G(z) represents the output of the first generator network; V min and V max are the lower and upper limits of the voltage respectively; G raw (z) is the original voltage value generated by the first generator network according to the first noise z; clip is a truncation operation function used to ensure that the generated voltage value falls within the range of [V min , V max ; the purpose of this formula is to ensure that the generated voltage data does not exceed the reasonable voltage range, so that the output data G(z) conforms to the physical limitations of the actual voltage sag.
[0090] In this way, by generating noise through the preset noise generation method and inputting it into the first generator network, new first voltage sag data can be generated based on the original n training samples, increasing the diversity and quantity of the data, which helps to improve the effect of subsequent model training and reduce the risk of overfitting;
[0091] In addition, by determining the constraint conditions based on the n training samples and the high-dimensional input space, the generated data can be restricted from multiple aspects such as feature range and feature correlation, ensuring that the generated first voltage sag data is reasonable in terms of physical meaning, business requirements, and statistical laws, and avoiding generating invalid data that does not conform to the actual situation.
[0092] S204. Perform adversarial training on the first improved generative adversarial network using the first training dataset and the first voltage sag data until the first improved generative adversarial network meets the preset training termination condition, obtaining a second improved generative adversarial network; the second improved generative adversarial network includes a second generator network and a second discriminator network.
[0093] In the embodiments of the present application, the preset training termination condition can be preset in advance or by default. For example, the preset training termination condition can be: the discriminator network and the generator network reach a balanced state, or the number of training iteration steps reaches the preset maximum number of training iteration steps.
[0094] It should be explained that the balanced state means that the discriminator network cannot distinguish whether the input is real data or generated data. That is, for both real data and generated data, the probability output by the discriminator network is almost the same, close to 50%, indicating that the discriminator network's judgment of the input data tends to be random.
[0095] When the first improved generative adversarial network reaches a balanced state, the first preset loss function can be expressed as:
[0096]
[0097] where n represents the size of the training batch, that is, the number of samples input to the first generator network each time during training; D(G(z i )) represents the output of the first discriminator network for the data G(z i ) generated by the first generator network, indicating the probability that the generated data G(z i ) belongs to real data.
[0098] In a specific embodiment, the first improved generative adversarial network can be trained adversarially using the first training dataset and the first voltage sag data until the trained first improved generative adversarial network meets the preset training termination condition, and the trained first improved generative adversarial network is used as the second improved generative adversarial network.
[0099] In one embodiment, please refer to Figure 6 , Figure 6 which is a training flow chart of an improved generative adversarial network provided by the embodiments of the present application, specifically as follows:
[0100] The first step, "Start", starts the process.
[0101] In the second step, define the feature information of the first training dataset to obtain m pieces of feature information. Specifically, it is possible to determine the features possessed by the data in the training dataset used for training, and it is clear that there are m such features. In actual training, these features are the basis for subsequent operations. For example, in the first round of training (iterations 1 to 100 steps), the generator network needs to process the input based on the information related to these features.
[0102] In the third step, construct a high-dimensional input space according to the m pieces of feature information; the first generator network generates training samples based on the high-dimensional input space. Specifically, it is possible to use the m pieces of feature information determined previously to construct a high-dimensional input space. Based on this space, the generator network starts to generate training samples. In the first round of training, the generator network can receive noise from a standard Gaussian distribution, process the noise through convolutional layers and fully connected layers, and generate voltage data as training samples under the constraints of the relevant rules of this high-dimensional input space.
[0103] In the fourth step, define the loss function of the generator network and the optimization objective of the generator network; the optimization objective of the generator network is: to minimize the probability that the generated samples are judged to be fake. Specifically, it is possible to determine the loss function of the generator network, which is used to measure the difference between the generated data and the real data. Its optimization objective is to make it difficult for the discriminator network to distinguish that the generated data is fake. In the first round and each subsequent round of training, the generator network adjusts its own weights according to the output of the discriminator network based on the loss function, so that the generated data is closer to the real data. Just like in the first round, the generator network needs to make the voltage data it generates not be recognized as fake data by the discriminator network.
[0104] In the fifth step, define the loss function of the discriminator network and the optimization objective of the discriminator network; the optimization objective of the discriminator network is: to minimize the error for real samples and maximize the rejection probability for generated samples. Specifically, it is possible to determine the loss function of the discriminator network, which is used to measure the accuracy of the discriminator network's judgment of real samples and generated samples. The discriminator network should strive to reduce the possibility of misjudging real samples, and at the same time increase the probability of recognizing that the generated samples are fake data. In each round of training, the discriminator network evaluates the training samples generated by the generator network and optimizes its own parameters according to the loss function.
[0105] Step 6: Conduct adversarial training on the first improved generative adversarial network using the training samples, and alternately optimize the model parameters of the generator network and the discriminator network according to their optimization objectives. Specifically, the training samples generated by the generator network can be input into the entire generative adversarial network, and the generator network and the discriminator network update their model parameters alternately according to their respective optimization objectives and loss functions. For example, in the first round (iterations 1 to 100 steps), the generator network first adjusts its weights according to the output of the discriminator network, and then the discriminator network adjusts itself according to the new generated data. In subsequent rounds (iterations 101 to 200 steps), this adversarial training and parameter alternation optimization process is continuously repeated.
[0106] Step 7: Determine whether the trained first improved generative adversarial network meets the preset training termination condition. Specifically, it can be checked whether the currently trained generative adversarial network meets the pre-set conditions for stopping training, such as whether the loss functions of the generator network and the discriminator network reach a balanced state, or whether the maximum number of training steps is reached. This judgment is made after each round of training.
[0107] If the judgment result is "N (No)": Return to the step of "Construct a high-dimensional input space based on m feature information; the first generator network generates training samples according to the high-dimensional input space" to continue training. For example, if the first round of training does not meet the termination condition, enter the second round (iterations 101 to 200 steps) to continue training. The generator network continues to use the noise of the standard Gaussian distribution and trains based on the weights of the previous round of the generator network.
[0108] If the judgment result is "Y (Yes)": Enter the step of "Training completed, obtaining the second improved generative adversarial network", the training ends, and the trained and optimized generative adversarial network, that is, the second improved generative adversarial network, is obtained.
[0109] Step 8: "End", the entire training process ends.
[0110] Optionally, in step S204, the step of performing adversarial training on the first improved generative adversarial network using the first training data set and the first voltage sag data until the first improved generative adversarial network meets the preset training termination condition to obtain the second improved generative adversarial network may include the following steps:
[0111] A1: Input the first training data set and the first voltage sag data into the first discriminator network to obtain a first discrimination result; the first discrimination result includes: the probability that the first voltage sag data is judged as real data;
[0112] A2: Determine the first loss value of the first generator network and the second loss value of the first discriminator network according to the first discrimination result;
[0113] A3. Update the parameters of the first generator network by using a first preset update algorithm based on the first loss value;
[0114] A4. Update the parameters of the first discriminator network by using a second preset update algorithm based on the second loss value;
[0115] A5. Determine whether the updated first improved generative adversarial network meets the preset training termination condition;
[0116] A6. If so, determine the second improved generative adversarial network according to the updated first improved generative adversarial network;
[0117] A7. If not, generate second voltage sag data through the updated first generator network; continue to perform adversarial training on the updated first improved generative adversarial network by using the first training data set and the second voltage sag data until the updated first improved generative adversarial network meets the preset training termination condition, so as to obtain the second improved generative adversarial network.
[0118] In the embodiments of the present application, both the first preset update algorithm and the second preset update algorithm can be preset in advance or by default.
[0119] In a specific embodiment, the first training data set and the first voltage sag data can be input into the first discriminator network first, and the first discriminator network outputs the probability of whether the first voltage sag data is real data, so as to obtain a first discrimination result; then, the first loss value of the first generator network and the second loss value of the first discriminator network can be determined according to the first discrimination result.
[0120] Then, the parameters of the first generator network can be updated by using a first preset update algorithm based on the first loss value. For example, the first preset update algorithm can be the gradient descent method; further, the parameters of the first discriminator network can be updated by using a second preset update algorithm based on the second loss value.
[0121] It should be noted that the first preset update algorithm and the second preset update algorithm can be the same update algorithm or different update algorithms.
[0122] Next, it can be determined whether the updated first improved generative adversarial network meets the preset training termination condition; if so, the second improved generative adversarial network is determined according to the updated first improved generative adversarial network.
[0123] If not, the second voltage sag data is generated by the updated first generator network. Specifically, the steps of generating the second voltage sag data can be the same as those of generating the first voltage sag data above. Then, the updated first improved generative adversarial network can be continuously trained adversarially using the first training dataset and the second voltage sag data until the updated first improved generative adversarial network meets the preset training termination condition, and the second improved generative adversarial network is obtained.
[0124] In this way, by inputting the first training dataset and the first voltage sag data into the first discriminator network, the first generator network can determine the first loss value according to the discrimination result, and update the parameters using the first preset update algorithm based on the first loss value, which can enable the first generator network to learn the characteristics of the real data distribution, optimize the quality of the generated data, and generate more realistic voltage sag data. For example, in the initial stage of training, the data generated by the first generator network is quite different from the real data. Through the guidance of the loss value to update the parameters, the generation mode is gradually adjusted to make the subsequent generated data more in line with the actual situation.
[0125] Optionally, the first discriminator network includes: a convolution module, an attention module, and a target fully connected module; step A1, inputting the first training dataset and the first voltage sag data into the first discriminator network to obtain a first discrimination result may include the following steps:
[0126] B1. Feature extraction is performed on the first training dataset and the first voltage sag data through the convolution module to obtain a first feature map;
[0127] B2. Calculate the attention weights of each feature position in the first feature map through the attention module to obtain an attention weight matrix; determine a second feature map according to the attention weight matrix and the first feature map;
[0128] B3. Map the second feature map to two preset output nodes through the target fully connected module to obtain two output probabilities; each preset output node corresponds to a data category; the data category includes true or false;
[0129] B4. Determine the probability corresponding to the data category being true among the two output probabilities to obtain the first discrimination result.
[0130] In the embodiment of the present application, the two preset output nodes can be preset in advance or by default.
[0131] In a specific embodiment, the first training dataset and the first voltage sag data can be subjected to feature extraction through a convolution module to obtain a first feature map. Specifically, the first training dataset and the first voltage sag data can be preprocessed first (for example, data normalization operation) to ensure that the data format is suitable for convolution operations. Then, the convolution kernel of the convolution module can be slid on the input data (i.e., the first training dataset and the first voltage sag data) to perform convolution operations, extract the local features of the data, and obtain the first feature map.
[0132] Next, the attention weights of each feature position in the first feature map can be calculated through an attention module to obtain an attention weight matrix. Specifically, the first feature map can be respectively passed through three different linear transformations (which can be implemented by means of the fully connected layers in the target fully connected module) to obtain three new feature matrices, which are respectively called the query matrix (Query, denoted as Q), the key matrix (Key, denoted as K), and the value matrix (Value, denoted as V). These three matrices are the key intermediate quantities for calculating the attention weights, and different aspects of information are extracted from the first feature map through different linear mappings. Then, the product of the query matrix Q and the transpose of the key matrix K can be calculated to obtain an attention score matrix. To prevent the element values in the score matrix from being too large, resulting in numerical instability problems when calculating the gradient, a scaling operation can be performed on the score matrix, dividing it by a scaling factor (generally √d k , d k is the dimension of the vectors in the key matrix K). Further, the Softmax function can be applied to the scaled attention score matrix to convert the scores into a probability distribution form to obtain the attention weight matrix.
[0133] It should be explained that the role of the Softmax function is to normalize the scores at each position so that the sum of the weights at all positions is 1. In this way, each weight represents the relative importance of the corresponding feature position in the overall feature map.
[0134] Then, the second feature map can be determined based on the attention weight matrix and the first feature map. Specifically, the attention weight matrix can be directly multiplied by the first feature map to obtain the second feature map. For example, assume that the first feature map is a multi-dimensional tensor with a shape of (B1, C1, H1, W1), where B is the batch size (representing the number of samples processed at one time), C is the number of channels, H is the height of the feature map, and W is the width of the feature map; the attention weight matrix is also a multi-dimensional tensor with a shape of (B2, C2, H2, W2), that is, each sample has a corresponding attention weight value at each spatial position. The two are multiplied to obtain the second feature map. Further, the second feature map can be mapped to two preset output nodes through the target fully connected module to obtain two output probabilities. Finally, the probability corresponding to the true data category among the two output probabilities can be determined to obtain the probability that the first voltage sag data is judged to be real data, that is, the first discrimination result.
[0135] It should be noted that the target fully connected module can include one or more fully connected layers, which can be determined according to actual needs. For example, for tasks with extremely high discrimination accuracy requirements, such as accurately distinguishing subtle differences in voltage sags, multiple fully connected layers are required to improve the discrimination ability of the model; if the task has relatively loose accuracy requirements, a single fully connected layer with a simple structure is sufficient.
[0136] In this way, by introducing the attention module, the attention weights of each feature position in the first feature map can be calculated. This enables the model to focus on the features that are more important for the discrimination task and suppress the influence of irrelevant or noisy features. For example, when judging the authenticity of voltage sag data, the feature positions that reflect the unique patterns of real sag events can be highlighted to improve the discrimination accuracy.
[0137] Optionally, in step A2, the determining the first loss value of the first generator network and the second loss value of the first discriminator network according to the first discrimination result may include the following steps:
[0138] C1. Calculate the first loss value according to the first discrimination result and the first preset loss function; the first preset loss function is specifically as follows:
[0139]
[0140] where L G represents the first loss value; z represents the first noise; p z (z) is the probability distribution of the noise z; z ∼ p z (z) means that the noise z follows the probability distribution p z (z); E z~pz(z) represents taking the expectation over the distribution p zTake the expectation of the noise z of (z); G(z) represents the first voltage sag data; D(G(z)) represents the first discrimination result;
[0141] C2. Determine the second loss value according to the second preset loss function; the second preset loss function is specifically as follows:
[0142]
[0143] where L D represents the second loss value; n represents the size of the training batch, that is, the number of samples input into the first discriminator network each time during training; k represents the number of data categories into which the voltage sag data is divided; y i,k represents the true label of sample i, and p i,k is the predicted probability that the first discriminator network assigns sample i to the k-th data category; sample i is a data in the first training dataset.
[0144] In the embodiments of the present application, both the first preset loss function and the second preset loss function can be preset in advance or by default.
[0145] In a specific embodiment, the first discrimination result can be substituted into the first preset loss function for calculation. The first preset loss function is specifically as follows:
[0146]
[0147] According to the above formula, the first loss value can be obtained. Then, the number of samples n input into the first discriminator network each time during training can be obtained. n can be preset in advance or by default. Of course, n can also be set manually. Assuming that the first training dataset contains n sample data, then the number of data categories k into which the voltage sag data is divided can be obtained, which can be determined according to the classification requirements of the voltage sag data and the actual business scenario. For example, if only real voltage sag data and generated fake data need to be distinguished, then k = 2; if the different degrees of voltage sag (such as mild, moderate, severe, etc.) are further subdivided, the value of k will increase accordingly, which needs to be determined in combination with the professional definition and research purpose of voltage sag in the power system.
[0148] Furthermore, the true label corresponding to each sample in the first training dataset can be obtained, resulting in n true labels. For example, y i,k represents the true belonging of sample i to the k-th data category, which is a definite value. If sample i belongs to the k-th category, y i,k is equal to 1, and if not, y i,kEqual to 0; then, the first training data set can be input into the first discriminator network to obtain n predicted probabilities, and these data are brought into the second preset loss function. The second preset loss function is specifically as follows:
[0149]
[0150] According to the above formula, the second loss value can be obtained.
[0151] In this way, the second preset loss function takes into account multiple data categories (reflected by k) of the voltage sag data division and can handle complex classification tasks. Whether the data is simply divided into two categories of true and false or further subdivided into multiple sag situations, the discriminator network can learn and distinguish different categories according to this loss function, enhancing the discrimination accuracy of the model for different types of voltage sag data.
[0152] Optionally, the second preset update algorithm includes an Adam optimizer; step A4, updating the parameters of the first discriminator network based on the second loss value using the second preset update algorithm may include the following steps:
[0153] D1. Obtain the current network parameters of the first discriminator network;
[0154] D2. Calculate the initial gradient of the second preset loss function with respect to the current network parameters through the backpropagation algorithm based on the second loss value;
[0155] D3. Obtain the target optimization parameter set corresponding to the Adam optimizer; the target optimization parameter set includes: the first decay rate, the second decay rate, the target constant, and the target learning rate;
[0156] D4. Iteratively update the current network parameters through the Adam optimizer according to the target optimization parameter set and the preset update rule.
[0157] In the embodiments of the present application, the network parameters of the first discriminator network may include at least one of the following: convolution kernel weights, convolution kernel biases, weight matrices of fully connected layers, bias vectors of fully connected layers, etc., which are not limited herein.
[0158] In a specific embodiment, the current network parameters of the first discriminator network can be obtained first. Specifically, different deep learning frameworks have corresponding mechanisms and methods for obtaining network parameters. Generally, the parameters of each layer in the first discriminator network can be accessed through the interfaces or functions provided by the framework to obtain the current network parameters. For example, if the first improved generative adversarial network is a model based on the PyTorch framework, the parameters of all trainable parameters in the model can be accessed through the parameters method provided by the PyTorch framework, thereby obtaining the current network parameters.
[0159] Next, the initial gradient of the second preset loss function with respect to the current network parameters can be calculated based on the second loss value through the backpropagation algorithm. Specifically, starting from the second loss value, the second loss value can be propagated along the reverse path of the network to calculate the gradient of the second preset loss function with respect to the current network parameters, obtaining the initial gradient. Since the backpropagation algorithm is a conventional technique, it is not limited here.
[0160] Next, the target optimization parameter set corresponding to the Adam optimizer can be obtained. Specifically, the target optimization parameter set can be preset in advance or by default, or it can also be set manually. For example, the first decay rate can be 0.9; the second decay rate can be 0.999; the target constant can be 10^-8; the target learning rate can be 0.001; finally, the current network parameters can be iteratively updated by the Adam optimizer according to the target optimization parameter set and the preset update rule.
[0161] Among them, the preset update rule is as follows:
[0162]
[0163] Among them, m t represents the first moment estimate of the t-th iteration, v t represents the second moment estimate of the t-th iteration, represents the corrected first moment estimate, represents the corrected second moment estimate; θ t represents the network parameters of the t-th iteration, that is, the updated network parameters; θ t-1 represents the network parameters of the (t - 1)-th iteration, that is, the current network parameters; t represents the current iteration number; represents the initial gradient, β1 represents the first decay rate, β2 represents the second decay rate, ∈ represents the target constant, and α represents the target learning rate.
[0164] In this way, the current network parameters are iteratively updated by the Adam optimizer. The Adam optimizer combines momentum and adaptive learning rate, comprehensively considering historical gradient information and current gradient, and can update parameters quickly and stably; in large-scale data and complex model training, the Adam optimizer converges faster than the traditional gradient descent method, can save training time and computing resources, and moreover, the Adam optimizer can also adaptively adjust the learning rate according to the gradient situation of different parameters, using a smaller learning rate for frequently updated parameters and a larger learning rate for sparse parameters, enabling the model to be effectively optimized in various parameter scenarios and improving the training effect and generalization ability of the discriminator network.
[0165] Optionally, the method may further include the following steps:
[0166] E1. Obtain the preset learning rate corresponding to the Adam optimizer;
[0167] E2. Determine the model structure information corresponding to the first improved generative adversarial network;
[0168] E3. Determine the first adjustment factor corresponding to the model structure information;
[0169] E4. Adjust the preset learning rate according to the first adjustment factor to obtain the reference learning rate;
[0170] E5. Obtain the data scale information corresponding to the first training dataset;
[0171] E6. Determine the target learning rate range corresponding to the data scale information;
[0172] E7. If the reference learning rate is within the target learning rate range, determine the target learning rate according to the reference learning rate;
[0173] E8. If the reference learning rate is not within the target learning rate range, determine the intermediate value of the target learning rate range; determine the target deviation between the reference learning rate and the intermediate value; determine the second adjustment factor corresponding to the target deviation; adjust the reference learning rate according to the second adjustment factor to obtain the target learning rate.
[0174] In the embodiments of the present application, the preset learning rate can be preset in advance or by default; the model structure information can include at least one of the following: network composition modules, module connection methods, input and output specifications, etc., which are not limited herein.
[0175] In a specific embodiment, the preset learning rate corresponding to the Adam optimizer can be obtained first. Then, the model structure information corresponding to the first improved generative adversarial network can be determined. Specifically, the design document of the first improved generative adversarial network can be obtained, which will describe in detail the overall architectures of the generator network and the discriminator network, such as the composition of each module, the connection method, the type of layer, etc. The model structure information can be obtained from this design document. Then, the first adjustment factor corresponding to the model structure information can be determined. Specifically, the mapping relationship between the preset structure information and the adjustment factor can be stored in advance, and the first adjustment factor corresponding to the model structure information can be determined based on this mapping relationship. Further, the preset learning rate can be adjusted according to the first adjustment factor, and the specific calculation formula is as follows:
[0176] Reference learning rate = preset learning rate * (1 + first adjustment factor);
[0177] According to the above formula, a reference learning rate can be obtained; further, the data scale information corresponding to the first training data set can be obtained. Specifically, the data scale information can include at least one of the following: the number of samples, the feature dimension, the data storage size, etc., which is not limited here. For example, the data scale information can be the number of samples, and the number of samples in the first training data set can be counted, that is, the data scale information; then, the target learning rate range corresponding to the data scale information can be determined. Specifically, a mapping relationship between the preset scale information and the learning rate range can be stored in advance, and the target learning rate range corresponding to the data scale information can be determined based on this mapping relationship; if the reference learning rate is within the target learning rate range, the reference learning rate can be directly used as the target learning rate;
[0178] If the reference learning rate is not within the target learning rate range, the intermediate value corresponding to the target learning rate range can be determined first; then, the target deviation degree between the reference learning rate and the intermediate value can be calculated. The specific calculation formula is as follows:
[0179] Target deviation degree = (reference learning rate - intermediate value) / intermediate value;
[0180] According to the above formula, the target deviation degree can be obtained; then, the second adjustment factor corresponding to the target deviation degree can be determined. For example, a mapping relationship between the preset deviation degree and the adjustment factor can be stored in advance, and the second adjustment factor corresponding to the target deviation degree can be determined based on this mapping relationship. Among them, the value ranges of the first adjustment factor and the second adjustment factor can both be -0.3 to 0.3; finally, the reference learning rate can be adjusted according to the second adjustment factor. The specific calculation formula is as follows:
[0181] Target learning rate = reference learning rate * (1 + second adjustment factor);
[0182] According to the above formula, the target learning rate can be obtained.
[0183] In this way, by obtaining the data scale information of the first training data set and determining the corresponding target learning rate range, the learning rate can be matched with the data volume. Generally speaking, when the data scale is large, the model has more data to learn features, and a relatively small learning rate can be adopted to update the parameters more stably and capture the subtle patterns in the data; if the data scale is small, to prevent the model from overfitting and be able to learn from the limited data faster, a relatively large learning rate can be selected.
[0184] S205. Input the first test data set into the second generator network to obtain second voltage sag data; add the second voltage sag data to the voltage sag historical data set.
[0185] In the embodiment of the present application, the data in the first test data set can be sequentially input into the second generator network, and the second voltage sag data close to the real data can be generated through the second generator network. Then, the second voltage sag data can be added to the voltage sag historical data set, expanding the voltage sag historical data set and enhancing its diversity. Thus, the enhancement of voltage sag data is achieved.
[0186] In summary, for the voltage sag data enhancement method based on the improved generative adversarial network described in the present application, by obtaining the voltage sag historical data set and the first improved generative adversarial network; selecting training data and test data from the voltage sag historical data set to obtain the first training data set and the first test data set; randomly generating voltage sag data according to the first training data set through the first generator network to obtain the first voltage sag data; performing adversarial training on the first improved generative adversarial network with the first training data set and the first voltage sag data until the first improved generative adversarial network meets the preset training termination condition to obtain the second improved generative adversarial network; inputting the first test data set into the second generator network to obtain the second voltage sag data; adding the second voltage sag data to the voltage sag historical data set; by training the improved generative adversarial network to generate voltage sag data close to the real data, a large amount of voltage sag data can be obtained, and adding these voltage sag data to the voltage sag historical data set solves the problem of limited voltage sag data.
[0187] Please refer to Figure 7 , Figure 7 which is a functional unit composition block diagram of a voltage sag data enhancement system 700 based on an improved generative adversarial network provided by an embodiment of the present application; the voltage sag data enhancement system 700 based on the improved generative adversarial network includes: an acquisition unit 701, a data enhancement unit 702, where:
[0188] The acquisition unit 701 is configured to obtain a voltage sag historical data set and a first improved generative adversarial network; the first improved generative adversarial network includes a first generator network and a first discriminator network; select training data and test data from the voltage sag historical data set to obtain a first training data set and a first test data set;
[0189] The data augmentation unit 702 is configured to randomly generate voltage sag data according to the first training data set by the first generator network to obtain first voltage sag data; perform adversarial training on the first improved generative adversarial network with the first training data set and the first voltage sag data until the first improved generative adversarial network meets a preset training termination condition to obtain a second improved generative adversarial network; the second improved generative adversarial network includes a second generator network and a second discriminator network; input the first test data set into the second generator network to obtain second voltage sag data; add the second voltage sag data to the voltage sag historical data set.
[0190] In specific implementation, the voltage sag data augmentation system 700 based on the improved generative adversarial network described in the embodiments of the present invention may also execute other implementation manners described in the voltage sag data augmentation method based on the improved generative adversarial network provided in the embodiments of the present invention, which will not be elaborated here.
[0191] Please refer to Figure 8 , Figure 8 FIG. is a schematic structural diagram of another electronic device provided in an embodiment of the present application. The electronic device may include a processor, a memory, a communication interface, and one or more programs. The processor, the memory, and the communication interface may be interconnected through a bus; the above one or more programs are stored in the above memory and are configured to be executed by the above processor; in the embodiments of the present application, the above programs include instructions for performing the following steps:
[0192] Obtain a voltage sag historical data set and a first improved generative adversarial network; the first improved generative adversarial network includes a first generator network and a first discriminator network;
[0193] Select training data and test data from the voltage sag historical data set to obtain a first training data set and a first test data set;
[0194] Randomly generate voltage sag data according to the first training data set by the first generator network to obtain first voltage sag data;
[0195] Perform adversarial training on the first improved generative adversarial network with the first training data set and the first voltage sag data until the first improved generative adversarial network meets a preset training termination condition to obtain a second improved generative adversarial network; the second improved generative adversarial network includes a second generator network and a second discriminator network;
[0196] Input the first test data set into the second generator network to obtain second voltage sag data; add the second voltage sag data to the voltage sag historical data set.
[0197] In a specific implementation, the electronic device described in the embodiments of the present invention may also execute other implementation manners described in the voltage sag data enhancement method based on an improved generative adversarial network provided in the embodiments of the present invention, which will not be elaborated herein.
[0198] The embodiments of the present application also provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, and the computer program enables a computer to execute some or all of the steps of any of the methods described in the above method embodiments, and the above computer includes an electronic device.
[0199] The embodiments of the present application also provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to enable a computer to execute some or all of the steps of any of the methods described in the above method embodiments. The computer program product may be a software installation package, and the above computer includes an electronic device.
[0200] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, some steps may be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.
[0201] In the above embodiments, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0202] In several embodiments provided by the present application, it should be understood that the disclosed device may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the above division of units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, and the indirect coupling or communication connection of the device or unit may be in an electrical or other form.
[0203] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by hardware instructed by a computer program. This program can be stored in a computer-readable storage medium. When this program is executed, it can include the processes of the above method embodiments. The aforementioned storage medium includes various media that can store program codes, such as ROM or random access memory RAM, magnetic disks, or optical discs.
[0204] The steps of the methods or algorithms described in the embodiments of this application can be implemented in a hardware manner or by a processor executing software instructions. The software instructions can be composed of corresponding software modules. The software modules can be stored in RAM, flash memory, ROM, EPROM, electrically erasable programmable read-only memory (EEPROM), registers, hard disks, removable hard disks, compact disc read-only memory (CD-ROM), or any other form of storage medium well-known in the art.
[0205] An exemplary storage medium is coupled to the processor, enabling the processor to read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. Additionally, the ASIC can be located in a terminal device or a management device. Of course, the processor and the storage medium can also exist as discrete components in the terminal device or the management device.
[0206] Those skilled in the art should be able to realize that in one or more of the above examples, the functions described in the embodiments of this application can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of this application are generated in whole or in part.
[0207] The above computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server, data center, etc. that contains one or more integrated available media.
[0208] Among them, the available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a digital video disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0209] For each device and product described in the above embodiments, each module / unit included therein can be a software module / unit, a hardware module / unit, or can also be partially a software module / unit and partially a hardware module / unit. For example, for each device and product applied to or integrated into a chip, each module / unit included therein can be implemented in a hardware manner such as a circuit. Or, at least some of the modules / units can be implemented in the form of a software program that runs on a processor integrated inside the chip, and the remaining (if any) part of the modules / units can be implemented in a hardware manner such as a circuit. For each device and product applied to or integrated into a chip module, each module / unit included therein can be implemented in a hardware manner such as a circuit. Different modules / units can be located in the same component (such as a chip, circuit module, etc.) or different components of the chip module. Or, at least some of the modules / units can be implemented in the form of a software program that runs on a processor integrated inside the chip module, and the remaining (if any) part of the modules / units can be implemented in a hardware manner such as a circuit. For each device and product applied to or integrated into a terminal device, each module / unit included therein can be implemented in a hardware manner such as a circuit. Different modules / units can be located in the same component (such as a chip, circuit module, etc.) or different components inside the terminal device. Or, at least some of the modules / units can be implemented in the form of a software program that runs on a processor integrated inside the terminal device, and the remaining (if any) part of the modules / units can be implemented in a hardware manner such as a circuit.
[0210] The specific embodiments described above further elaborate on the objectives, technical solutions, and beneficial effects of the embodiments of the present application. It should be understood that the above description is only the specific embodiments of the embodiments of the present application and is not intended to limit the protection scope of the embodiments of the present application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the embodiments of the present application shall be included within the protection scope of the embodiments of the present application.
Claims
1. A voltage sag data enhancement method based on an improved generative adversarial network, characterized in that Including: Obtaining a voltage sag historical dataset and a first improved generative adversarial network; The first improved generative adversarial network includes a first generator network and a first discriminator network; Selecting training data and test data from the voltage sag historical dataset to obtain a first training dataset and a first test dataset; Randomly generating voltage sag data according to the first training dataset through the first generator network to obtain first voltage sag data; Performing adversarial training on the first improved generative adversarial network with the first training dataset and the first voltage sag data until the first improved generative adversarial network meets a preset training termination condition to obtain a second improved generative adversarial network; The second improved generative adversarial network includes a second generator network and a second discriminator network; Inputting the first test dataset into the second generator network to obtain second voltage sag data; adding the second voltage sag data to the voltage sag historical dataset.
2. The method according to claim 1, wherein The first training dataset includes n training samples, and each training sample includes m feature information; Both m and n are integers greater than 1; The step of randomly generating voltage sag data according to the first training dataset through the first generator network to obtain first voltage sag data includes: Constructing a high-dimensional input space according to the m feature information of each of the n training samples; Randomly generating first noise through a preset noise generation method; Determining a constraint condition according to the n training samples and the high-dimensional input space; Inputting the first noise and the constraint condition into the first generator network to obtain the first voltage sag data.
3. The method according to claim 2, wherein The step of performing adversarial training on the first improved generative adversarial network with the first training dataset and the first voltage sag data until the first improved generative adversarial network meets a preset training termination condition to obtain a second improved generative adversarial network includes: Inputting the first training dataset and the first voltage sag data into the first discriminator network to obtain a first discrimination result; the first discrimination result includes: the probability that the first voltage sag data is judged as real data; Determining a first loss value of the first generator network and a second loss value of the first discriminator network according to the first discrimination result; Updating the parameters of the first generator network based on the first loss value using a first preset update algorithm; Updating the parameters of the first discriminator network based on the second loss value using a second preset update algorithm; Judging whether the updated first improved generative adversarial network meets the preset training termination condition; If so, determining the second improved generative adversarial network according to the updated first improved generative adversarial network; If not, generating second voltage sag data through the updated first generator network; continuing to perform adversarial training on the updated first improved generative adversarial network with the first training dataset and the second voltage sag data until the updated first improved generative adversarial network meets the preset training termination condition to obtain the second improved generative adversarial network.
4. The method according to claim 3, wherein The first discriminator network includes: a convolutional module, an attention module, and a target fully-connected module; Inputting the first training dataset and the first voltage sag data into the first discriminator network to obtain a first discrimination result, including: Performing feature extraction on the first training dataset and the first voltage sag data through the convolutional module to obtain a first feature map; Calculating the attention weights of each feature position in the first feature map through the attention module to obtain an attention weight matrix; determining a second feature map according to the attention weight matrix and the first feature map; Mapping the second feature map to two preset output nodes through the target fully-connected module to obtain two output probabilities; each preset output node corresponds to a data category; the data category includes true or false; Determining the probability corresponding to the data category being true among the two output probabilities to obtain the first discrimination result.
5. The method according to claim 3 or 4, characterized in that Determining a first loss value of the first generator network and a second loss value of the first discriminator network according to the first discrimination result, including: Calculating the first loss value according to the first discrimination result and a first preset loss function; the specific form of the first preset loss function is as follows: Among them, L G represents the first loss value; z represents the first noise; p z (z) is the probability distribution of the noise z; z ~ p z (z) indicates that the noise z follows the probability distribution p z (z); E z~pz(z) represents taking the expectation of the noise z that follows the distribution p z (z); G(z) represents the first voltage sag data; D(G(z)) represents the first discrimination result; Determining the second loss value according to a second preset loss function; the specific form of the second preset loss function is as follows: Among them, L D represents the second loss value; n represents the size of the training batch, that is, the number of samples input into the first discriminator network each time during training; k represents the number of data categories into which the voltage sag data is divided; y i,k represents the true label of sample i, and p i,k is the predicted probability that the first discriminator network assigns sample i to the k-th data category; sample i is a data in the first training dataset.
6. The method according to claim 5, wherein The second preset update algorithm includes an Adam optimizer; Updating the parameters of the first discriminator network by using the second preset update algorithm based on the second loss value, including: Obtaining the current network parameters of the first discriminator network; Calculating the initial gradient of the second preset loss function with respect to the current network parameters through the backpropagation algorithm based on the second loss value; Obtaining a target optimization parameter set corresponding to the Adam optimizer; the target optimization parameter set includes: a first decay rate, a second decay rate, a target constant, and a target learning rate; Iteratively updating the current network parameters through the Adam optimizer according to the target optimization parameter set and a preset update rule.
7. The method according to claim 6, wherein The method further includes: Obtaining a preset learning rate corresponding to the Adam optimizer; Determining the model structure information corresponding to the first improved generative adversarial network; Determining a first adjustment factor corresponding to the model structure information; Adjusting the preset learning rate according to the first adjustment factor to obtain a reference learning rate; Obtaining the data scale information corresponding to the first training dataset; Determining a target learning rate range corresponding to the data scale information; If the reference learning rate is within the target learning rate range, determining the target learning rate according to the reference learning rate; If the reference learning rate is not within the target learning rate range, determining the intermediate value of the target learning rate range; determining the target deviation degree between the reference learning rate and the intermediate value; determining a second adjustment factor corresponding to the target deviation degree; adjusting the reference learning rate according to the second adjustment factor to obtain the target learning rate.
8. A voltage sag data enhancement system based on an improved generative adversarial network, characterized in that Including: An acquisition unit and a data augmentation unit, where: The obtaining unit is configured to obtain a voltage sag historical data set and a first improved generative adversarial network; the first improved generative adversarial network includes a first generator network and a first discriminator network; select training data and test data from the voltage sag historical data set to obtain a first training data set and a first test data set; The data augmentation unit is configured to randomly generate voltage sag data according to the first training data set through the first generator network to obtain first voltage sag data; perform adversarial training on the first improved generative adversarial network with the first training data set and the first voltage sag data until the first improved generative adversarial network meets a preset training termination condition to obtain a second improved generative adversarial network; the second improved generative adversarial network includes a second generator network and a second discriminator network; input the first test data set into the second generator network to obtain second voltage sag data; add the second voltage sag data to the voltage sag historical data set.
9. An electronic device, characterized in that, Comprising: A processor, a memory, a communication interface, and one or more programs; The one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for performing the steps in the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, A computer program stored for electronic data exchange, wherein the computer program causes a computer to execute the method according to any one of claims 1-7.