Training method, device, equipment and storage medium for power adversarial sample image recognition model
By adding noise to the power image dataset to generate noisy seed images and iteratively updating the generative adversarial network, the accuracy problem of adversarial sample image recognition in the power system is solved, and the recognition accuracy of the power image recognition model is improved.
Patent Information
- Application Number
- CN202411762777.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-12-03
AI Technical Summary
Existing AI model security assessment methods lack a unified system, making it difficult to effectively identify adversarial sample images in power systems, resulting in insufficient recognition accuracy.
By adding multiple noises to the power image dataset to generate noisy seed images, a generative adversarial network is used to generate adversarial sample images, and the generative adversarial network is iteratively updated based on the evaluation index value until the preset conditions are met. The discriminator of the last iteration is used as the power image recognition model.
The accuracy of the power image recognition model for adversarial sample images is improved, the discriminator performance of the generative adversarial network is enhanced, and the accuracy of power image recognition is ensured.
Smart Images

Figure CN119600368B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a training method, apparatus, device and storage medium for an electric power adversarial sample image recognition model. Background Art
[0002] The application of artificial intelligence (AI) technology in the energy industry, particularly in power systems, has reached a mature stage. However, the black-box nature and weak interpretability of AI algorithms used in emerging power systems make adversarial image attacks, among other threats, a persistent threat to the security of AI algorithm models in power systems, potentially causing system failures or even paralysis. Adversarial image attacks involve attackers adding subtle, imperceptible perturbations to normal samples, thereby misleading AI models into making incorrect decisions. Therefore, identifying power images in power systems to determine whether they are adversarial images is crucial.
[0003] Existing AI model security assessment methods typically focus on specific dimensions and lack a unified system for model security assessment. Furthermore, most existing AI security testing methods focus on single tests, resulting in poor scalability and repeatability. Therefore, improving the accuracy of power image recognition has become a pressing issue. Summary of the Invention
[0004] The embodiments of the present application provide a training method, apparatus, device, and storage medium for an electric power adversarial sample image recognition model, which is conducive to improving the accuracy of target electric power image recognition.
[0005] In a first aspect, an embodiment of the present application provides a method for training a power adversarial sample image recognition model, the method comprising:
[0006] Add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images;
[0007] Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain the predicted category of each adversarial sample image;
[0008] Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0009] Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; where i is a positive integer greater than or equal to 1.
[0010] In one embodiment, at least two different noises are added to each original image in the power image dataset to obtain multiple noisy seed images, including: adding Gaussian noise and salt and pepper noise to each original image in the power image dataset to obtain multiple noisy seed images.
[0011] In one embodiment, based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping the generation of adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image, including: updating the network parameters of the generative adversarial network of the i+1-th iteration based on the evaluation index value determined in the i-th iteration to obtain the i+1-th generative adversarial network; inputting the multiple adversarial sample images generated in the i-th iteration into the i+1-th generative adversarial network. In the generator, multiple new adversarial sample images generated by the i+1th iteration are obtained, and the multiple new adversarial sample images are input into the discriminator of the i+1th generative adversarial network to obtain the predicted category of each new adversarial sample image; based on the predicted category of each new adversarial sample image and the actual category of the original image corresponding to each new adversarial sample image, the evaluation index value corresponding to the i+1th iteration is determined, until the evaluation index value corresponding to N consecutive iterations is greater than or equal to the preset evaluation index threshold, the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image.
[0012] In one embodiment, the evaluation index value includes accuracy and / or total loss value; the total loss value is composed of a first loss value, a second loss value, and a third loss value; the first loss value is used to characterize the ability of the discriminator to recognize the original image, and the second loss value is used to characterize the ability of the discriminator to recognize the adversarial sample image corresponding to the original image; the third loss value is used to characterize the difference between the adversarial sample image and the original image corresponding to the adversarial sample image.
[0013] In one embodiment, the first loss value, the second loss value, and the third loss value are determined by: inputting the original image into the discriminator of the generative adversarial network to obtain the probability of the predicted category of the original image, and determining the first loss value based on the probability of the predicted category of the original image; determining the second loss value based on the probability corresponding to the predicted category of the adversarial sample image; and determining the third loss value based on the probability corresponding to the predicted category of the adversarial sample image and the probability of the predicted category of the original image corresponding to the adversarial sample image.
[0014] In one embodiment, each noisy seed image is input into the generator of a generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and each adversarial sample image is input into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image, including: inputting each original image and each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each original image and an adversarial sample image corresponding to each noisy seed image; and inputting the generated multiple adversarial sample images into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image.
[0015] In a second aspect, the present application provides a training device for a power adversarial sample image recognition model, the device comprising:
[0016] a processing module, configured to add at least two different noises to each original image in the power image dataset to obtain a plurality of noisy seed images;
[0017] The processing module is further configured to input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image;
[0018] A determination module is used to determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0019] An update module is configured to iteratively update the generative adversarial network of the (i+1)th iteration based on the evaluation index value determined in the (i)th iteration and the multiple adversarial sample images generated, until a preset condition for stopping the generation of adversarial sample images is met, and use the discriminator of the generative adversarial network of the last iteration as the power image recognition model for identifying the target power image; wherein i is a positive integer greater than or equal to 1.
[0020] In a third aspect, the present application provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are performed:
[0021] Add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images;
[0022] Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain the predicted category of each adversarial sample image;
[0023] Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0024] Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; where i is a positive integer greater than or equal to 1.
[0025] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the following steps:
[0026] Add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images;
[0027] Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain the predicted category of each adversarial sample image;
[0028] Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0029] Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; where i is a positive integer greater than or equal to 1.
[0030] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the following steps:
[0031] Add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images;
[0032] Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain the predicted category of each adversarial sample image;
[0033] Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0034] Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; where i is a positive integer greater than or equal to 1.
[0035] The training method, apparatus, device and storage medium of the above-mentioned power adversarial sample image recognition model, the computer device can add at least two different noises to each original image in the power image data set to obtain multiple noisy seed images; each noisy seed image is input into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and each adversarial sample image is input into the discriminator of the generative adversarial network to obtain a predicted category of each adversarial sample image; based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image, the evaluation index value corresponding to the generative adversarial network is determined; based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; wherein i is a positive integer greater than or equal to 1. By adopting this method, a computer device adds at least two different noises to each original image in a power image dataset to obtain multiple noisy seed images, and inputs the multiple noisy seed images into a generator, thereby improving the diversity of the generated adversarial samples. Thus, based on the diversified adversarial samples and the evaluation index values corresponding to the determined generative adversarial network, the generative adversarial network is iteratively updated, which can improve the performance of the discriminator of the generative adversarial network. Furthermore, when the preset condition for stopping the generation of adversarial sample images is met, the discriminator of the generative adversarial network of the last iteration is used as a power image recognition model for identifying the target power image, which is conducive to using the power image recognition model to accurately identify whether the target power image is an adversarial sample image, that is, it is conducive to improving the accuracy of identifying the target power image. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.
[0037] Figure 1 This is an architecture diagram of a training system for a power adversarial sample image recognition model provided by an embodiment of the present application;
[0038] Figure 2 This is a schematic diagram of the training process of a power adversarial sample image recognition model provided in an embodiment of the present application;
[0039] Figure 3This is a flowchart of a method for training a power adversarial sample image recognition model provided by an embodiment of the present application;
[0040] Figure 4 This is a flowchart of another method for training a power adversarial sample image recognition model provided by an embodiment of the present application;
[0041] Figure 5 Schematic diagram of a training device for a power adversarial sample image recognition model provided by an embodiment of the present application;
[0042] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0044] The following combination Figure 1 and Figure 2 The application scenarios of the training method of the power adversarial sample image recognition model provided in the embodiment of the present application are introduced. Figure 1 This is an architecture diagram of a training system for a power adversarial sample image recognition model provided by an embodiment of the present application. Figure 2 This is a schematic diagram of the training process of an electric power adversarial sample image recognition model provided in an embodiment of the present application.
[0045] like Figure 1 As shown, the computer device 101 ( Figure 1 In the figure, the computer device 101 is used as a terminal device for example) and the database server 102. The computer device 101 and the database server 102 can transmit data via a network. The computer device 101 can obtain the power image dataset from the database server 102.
[0046] like Figure 2 As shown, after acquiring the power image dataset, the computer device 101 can add at least two different noises (corresponding to Figure 2), obtain multiple noisy seed images; then, input the multiple noisy seed images into the generator of the generative adversarial network to generate diversified noisy adversarial sample images; thereafter, input the diversified noisy adversarial sample images into the discriminator of the generative adversarial network to classify each noisy adversarial sample image to obtain a predicted category of each adversarial sample image; further, determine an evaluation index value (for example, accuracy) corresponding to the generative adversarial network based on the predicted category of the adversarial sample image, and based on the accuracy determined in the i-th iteration and the generated diversified adversarial samples, iteratively update the generative adversarial network of the i+1-th iteration until a preset condition for stopping generating adversarial sample images is met, and use the discriminator of the last iteration as a power image recognition model, which is used to identify whether the power image is an adversarial sample image; wherein i is a positive integer greater than or equal to 1. In this way, the computer device 101 iteratively updates the generative adversarial network based on the diversified adversarial samples and the evaluation index values corresponding to the determined generative adversarial network, which can improve the performance of the discriminator of the generative adversarial network. Therefore, when the preset condition for stopping the generation of adversarial sample images is met, the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image, which is conducive to using the power image recognition model to accurately identify whether the target power image is an adversarial sample image, that is, it is conducive to improving the accuracy of identifying the target power image.
[0047] Optionally, the computer device 101 may be a terminal device or a server. The terminal devices mentioned herein may include, but are not limited to, smartphones, tablet computers, laptop computers, desktop computers, smart watches, smart TVs, and smart car terminals. The server mentioned herein may be an independent physical server, or a server cluster or distributed system consisting of multiple physical servers.
[0048] See Figure 3 , Figure 3 1 is a flow chart of a method for training a power adversarial sample image recognition model provided by an embodiment of the present application. The method can be executed by a computer device (for example, the computer device 101 described above). Figure 3 As shown, the training method of the power adversarial sample image recognition model may include but is not limited to the following steps:
[0049] S301 : Add at least two different noises to each original image in the electric power image dataset to obtain a plurality of noisy seed images.
[0050] The noisy seed image refers to the original image after adding at least two different noises, which can be used to train the generative adversarial network.
[0051] Generative Adversarial Networks (GANs) are deep learning models that generate new data similar to the training data through adversarial training of two neural networks. GANs consist of a generator and a discriminator. The generator's goal is to produce realistic-looking samples, while the discriminator's goal is to distinguish between real and generated samples.
[0052] S302: Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image.
[0053] Since each adversarial sample image is generated based on each noisy seed image, each adversarial sample image is an adversarial sample image with noise.
[0054] S303: Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image.
[0055] S304. Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the (i+1)-th iteration is iteratively updated until the preset condition for stopping the generation of adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; wherein i is a positive integer greater than or equal to 1.
[0056] In an optional embodiment, the evaluation index value corresponding to the generative adversarial network may include the accuracy and / or total loss value corresponding to the generative adversarial network.
[0057] In this embodiment, if the evaluation index value is accuracy, the preset condition for stopping generating adversarial sample images can be that the accuracy of the generated adversarial network obtained from N consecutive iterations is greater than a preset accuracy threshold. If the evaluation index value is total loss value, the preset condition for stopping generating adversarial sample images can be that the total loss value of the generated adversarial network obtained from N consecutive iterations is greater than a preset total loss threshold. If the evaluation index value is accuracy and total loss value, the preset condition for stopping generating adversarial sample images can be that the accuracy of the generated adversarial network obtained from N consecutive iterations is greater than a preset accuracy threshold, and the total loss value is greater than a preset total loss threshold.
[0058] In an embodiment of the present application, a computer device may add at least two different noises to each original image in a power image data set to obtain a plurality of noisy seed images; input each noisy seed image into a generator of a generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into a discriminator of the generative adversarial network to obtain a predicted category of each adversarial sample image; determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image; iteratively update the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration and the plurality of adversarial sample images generated until a preset condition for stopping generating adversarial sample images is met, and use the discriminator of the generative adversarial network of the last iteration as a power image recognition model for identifying the target power image; wherein, i is a positive integer greater than or equal to 1. By adopting this method, a computer device adds at least two different noises to each original image in a power image dataset to obtain multiple noisy seed images, and inputs the multiple noisy seed images into a generator, thereby improving the diversity of the generated adversarial samples. Thus, based on the diversified adversarial samples and the evaluation index values corresponding to the determined generative adversarial network, the generative adversarial network is iteratively updated, which can improve the performance of the discriminator of the generative adversarial network. Furthermore, when the preset condition for stopping the generation of adversarial sample images is met, the discriminator of the generative adversarial network of the last iteration is used as a power image recognition model for identifying the target power image, which is conducive to using the power image recognition model to accurately identify whether the target power image is an adversarial sample image, that is, it is conducive to improving the accuracy of identifying the target power image.
[0059] See Figure 4 , Figure 4 This is a flow chart of another method for training a power adversarial sample image recognition model provided by an embodiment of the present application. Figure 3 Compared with the training method of the power adversarial sample image recognition model shown, Figure 4 The method shown specifically describes how a computer device iteratively updates the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, until a preset condition for stopping the generation of adversarial sample images is met, and uses the discriminator of the generative adversarial network of the last iteration as the power image recognition model for recognizing the target power image. Figure 4 As shown, the training method of the power adversarial sample image recognition model may include but is not limited to the following steps:
[0060] S401 : Add Gaussian noise and salt and pepper noise to each original image in the electric power image dataset to obtain a plurality of noisy seed images.
[0061] Gaussian noise is a type of statistical noise whose amplitude follows a normal (Gaussian) distribution. Gaussian noise is a Gaussian distributed random variable with mean 0 and variance σ2. Salt and pepper noise is a type of random noise that is simulated by shifting certain pixels of an image to their maximum value (salt, usually 255) or minimum value (pepper, usually 0).
[0062] In an optional embodiment, the computer device adds Gaussian noise and salt and pepper noise to each original image in the power image dataset to obtain multiple noisy seed images. The method may be to first add Gaussian noise to each original image to obtain multiple noisy images, and then add salt and pepper noise to each noisy image to obtain multiple noisy seed images; or to first add salt and pepper noise to each original image to obtain multiple noisy images, and then add Gaussian noise to each noisy image to obtain multiple noisy seed images; or to add Gaussian noise and salt and pepper noise to each original image at the same time to obtain multiple noisy seed images, which is not limited here.
[0063] In an optional embodiment, the computer device adds Gaussian noise and salt and pepper noise to each original image in the power image dataset, and each of the obtained multiple noisy seed images can be expressed using the following formula (1).
[0064] (1)
[0065] In formula (1), I noisy represents the noisy seed image; I represents the original image; N g represents Gaussian noise; I s represents salt and pepper noise; (x, y) represents each pixel in the image.
[0066] It can be understood that the image after adding Gaussian noise can be expressed as the following formula (2).
[0067] (2)
[0068] In formula (2), I g It represents the image after adding Gaussian noise; I represents the original image; N g represents Gaussian noise.
[0069] Among them, for each pixel in the image, the Gaussian noise N g It can be expressed as the following formula (3).
[0070] (3)
[0071] In formula (3), It means that the mean is 0 and the variance is Gaussian distribution.
[0072] For each pixel in the image, the salt and pepper noise I s It can be expressed as the following formula (4).
[0073] (4)
[0074] In formula (4), p represents the noise density, that is, the probability that each pixel in the image is changed to salt and pepper; I represents the original image.
[0075] In this implementation, a computer device adds Gaussian noise to each original image in the power image dataset. For example, adding a random value with a mean of zero and an adjustable standard deviation can simulate the electronic noise encountered during natural image capture. Adding salt and pepper noise to each original image simulates random errors that may occur during image transmission or processing by randomly changing some pixels to white (salt) or black (pepper) with a certain probability. By adding Gaussian noise and salt and pepper noise with adjusted parameters to each original image, the generated noisy seed images can effectively test and enhance the robustness of the generative adversarial network. In other words, by adding Gaussian noise and salt and pepper noise with adjusted parameters to each original image, the diversity and intensity of the noise are balanced to ensure that the generated samples are both realistic and challenging to the generalization ability of the generative adversarial network using sufficiently complex noisy seed images.
[0076] S402: Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image.
[0077] The generator, as part of a generative adversarial network, can learn to extract features from the input image and generate new images similar to the input image (i.e., adversarial sample images). The goal of the generator is to minimize the discriminator's ability to correctly identify the generated data.
[0078] When a computer device inputs each noisy seed image into the generator of a generative adversarial network and generates adversarial sample images corresponding to each noisy seed image, the generator attempts to maintain the key features of the seed image while introducing changes to create new data samples (i.e., new images similar to the input image). These introduced changes may include, but are not limited to, further added noise, distortion, or other visual perturbations. Ultimately, the computer device, through the generator of the generative adversarial network, generates a set of new adversarial sample images that are visually similar to the original images but contain sufficient changes. These adversarial sample images can be used to further test and enhance the robustness of the generative adversarial network, particularly in terms of its ability to defend against adversarial sample attacks.
[0079] It is understandable that a computer device can generate a diverse set of adversarial sample images through the generator of the generative adversarial network, which is conducive to evaluating and improving the performance of the generative adversarial network in the face of malicious attacks in practical applications.
[0080] In step S402, the computer device inputs each adversarial image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial image. This is primarily to evaluate the performance of the discriminator, specifically its ability to distinguish between original images and adversarial images. The computer device outputs a predicted category probability value corresponding to each input image through the discriminator, which indicates the likelihood that the input image belongs to the real dataset (or, in other words, the power image dataset).
[0081] S403: Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image.
[0082] In one optional embodiment, the evaluation metric includes accuracy and / or a total loss value; the total loss value is composed of a first loss value, a second loss value, and a third loss value. The first loss value is used to characterize the discriminator's ability to recognize the original image, the second loss value is used to characterize the discriminator's ability to recognize the adversarial sample image corresponding to the original image, and the third loss value is used to characterize the difference between the adversarial sample image and the original image corresponding to the adversarial sample image. Thus, by introducing the third loss value into the process of determining the total loss value of the generative adversarial network, the computer device can further enhance the discriminator's ability to recognize subtle differences, thereby facilitating subsequent improvements in the performance of the generative adversarial network.
[0083] The accuracy rate refers to the proportion of correct classifications (correctly identifying the input image as the original image or the adversarial sample image) by the discriminator. The accuracy rate can be determined by a computer device using the following formula (5).
[0084] (5)
[0085] In formula (5), ACC represents the accuracy; TP refers to true positive examples, which indicates the number of images correctly identified as original images; TN refers to true negative examples, which indicates the number of images correctly identified as adversarial samples; FP refers to false positive examples, which indicates the number of adversarial samples that are mistakenly judged as original images; and FN refers to false negative examples, which indicates the number of original images that are mistakenly judged as adversarial samples.
[0086] Optionally, the third loss value may be a Euclidean distance loss value between the adversarial sample image and the original image corresponding to the adversarial sample image. The total loss value may be determined by the computer device using the following formula (6).
[0087] (6)
[0088] In formula (6), LD represents the total loss value; the first term on the right side of the equal sign represents the first loss value, the second term represents the second loss value, and the third term represents the third loss value; λ is a hyperparameter that is used to balance the adversarial loss value (i.e., the first loss value and the second loss value) with the Euclidean distance loss value (the third loss value). In this way, by introducing the Euclidean distance loss when determining the total loss value of the generative adversarial network, it is not only beneficial to subsequently improve the discriminator's ability to recognize the generated adversarial sample images, but also to promote the generator to generate higher-quality adversarial sample images, thereby improving the performance and security of the entire generative adversarial network.
[0089] The first loss value, the second loss value, and the third loss value can be determined by the computer device in the following manner: inputting the original image into the discriminator of the generative adversarial network to obtain the probability of the predicted category of the original image, and determining the first loss value based on the probability of the predicted category of the original image (such as the first term on the right side of the equal sign in formula (6)); determining the second loss value based on the probability corresponding to the predicted category of the adversarial sample image (such as the second term on the right side of the equal sign in formula (6)); and determining the third loss value based on the probability corresponding to the predicted category of the adversarial sample image and the probability of the predicted category of the original image corresponding to the adversarial sample image (such as the third term on the right side of the equal sign in formula (6)).
[0090] S404: Update the network parameters of the generative adversarial network of the (i+1)th iteration based on the evaluation index value determined in the (i)th iteration to obtain the (i+1)th generative adversarial network.
[0091] Wherein, i is a positive integer greater than or equal to 1.
[0092] S405. Input the multiple adversarial sample images generated by the i-th iteration into the generator of the i+1-th generative adversarial network to obtain multiple new adversarial sample images generated by the i+1-th iteration, and input the multiple new adversarial sample images into the discriminator of the i+1-th generative adversarial network to obtain the predicted category of each new adversarial sample image.
[0093] S406. Based on the predicted category of each new adversarial sample image and the actual category of the original image corresponding to each new adversarial sample image, determine the evaluation index value corresponding to the i+1th iteration, until the evaluation index value corresponding to N consecutive iterations is greater than or equal to the preset evaluation index threshold, and use the discriminator of the generative adversarial network of the last iteration as the power image recognition model for identifying the target power image.
[0094] The following is an illustration of steps S404 to S406.
[0095] For example, assuming the evaluation indicator value is accuracy, the preset evaluation indicator threshold is 85% (i.e., the accuracy threshold is 85%), and assuming the accuracy determined in the first iteration is 89%, the computer device may determine that the accuracy of 89% determined in the first iteration is greater than the accuracy threshold of 85%. In this case, the computer device may first update the network parameters of the generative adversarial network of the second iteration based on the accuracy of 89% determined in the first iteration to obtain a second generative adversarial network. Secondly, the adversarial sample image generated in the first iteration is input into the generator of the second generative adversarial network to obtain multiple new adversarial sample images generated in the second iteration, and the multiple new adversarial sample images are input into the discriminator of the second generative adversarial network to obtain the predicted category of each new adversarial sample image. The computer device may then determine the accuracy corresponding to the second iteration based on the predicted category of each new adversarial sample image and the actual category of the original image corresponding to each new adversarial sample image. If the accuracy corresponding to the second iteration is greater than 85% (e.g., the accuracy corresponding to the second iteration is 90%), the computer device may update the network parameters of the second iteration's generative adversarial network based on the 90% accuracy determined for the two iterations, thereby obtaining a third generative adversarial network. Thereafter, the computer device may input the new adversarial sample images generated in the second iteration into the generator of the third generative adversarial network to obtain multiple new adversarial sample images generated in the third iteration, and input the multiple new adversarial sample images generated in the third iteration into the discriminator of the third generative adversarial network to obtain the predicted category of each new adversarial sample image generated in the third iteration. Subsequently, the computer device may determine the accuracy corresponding to the third iteration based on the predicted category of each new adversarial sample image generated by the third iteration and the actual category of the original image corresponding to each new adversarial sample image. If the accuracy corresponding to the third iteration is still greater than 85% (for example, the accuracy corresponding to the third iteration is 91%), the computer device may determine that the accuracy corresponding to three consecutive iterations is greater than the preset accuracy threshold of 85%. In this case, the computer device may use the discriminator of the generative adversarial network of the last iteration (i.e., the discriminator in the third generative adversarial network) as the power image recognition model for identifying the target power image.
[0096] In an optional embodiment, after step S406, the computer device may further use the power image recognition model to identify the target power image to determine whether the target power image is an adversarial sample image. In this way, the accuracy of the target power image recognition can be improved.
[0097] In an embodiment of the present application, a computer device can add Gaussian noise and salt and pepper noise to each original image in the power image data set to obtain multiple noisy seed images. In this way, the diversity and complexity of the seed image can be improved by artificial noise addition; thereafter, by inputting the diverse and complex noisy seed images into the generator of the generative adversarial network, not only the diversity of the generated adversarial sample images can be improved, but also the robustness of the generative adversarial network can be effectively tested and enhanced. Thus, based on the diverse adversarial samples and the evaluation index values corresponding to the determined generative adversarial network, the generative adversarial network is iteratively updated to improve the performance of the discriminator of the generative adversarial network. Furthermore, when the preset condition for stopping the generation of adversarial sample images is met, the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image, which is conducive to using the power image recognition model to accurately identify whether the target power image is an adversarial sample image, that is, it is conducive to improving the accuracy of identifying the target power image.
[0098] In addition, in an embodiment of the present application, by setting an early stopping strategy, when the evaluation index value corresponding to N consecutive iterations is greater than or equal to the preset evaluation index threshold, the next iteration is stopped, that is, the generation of new adversarial sample images is stopped, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image. In this way, the generative adversarial network can be effectively prevented from overfitting, computing resources can be saved, and the training process can be accelerated.
[0099] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0100] Based on the same inventive concept, embodiments of the present application also provide a training device for a power adversarial image recognition model for implementing the aforementioned training method for a power adversarial image recognition model. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of one or more embodiments of the training device for a power adversarial image recognition model provided below can be found in the aforementioned limitations of the training method for a power adversarial image recognition model, and will not be further elaborated here.
[0101] See Figure 5 , Figure 5 This is a structural diagram of a training device for a power adversarial sample image recognition model provided by an embodiment of the present application. Figure 5 As shown, the training device of the power adversarial sample image recognition model may include but is not limited to:
[0102] The processing module 501 is configured to add at least two different noises to each original image in the power image dataset to obtain a plurality of noisy seed images;
[0103] The processing module 501 is further configured to input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image;
[0104] A determination module 502 is configured to determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0105] An updating module 503 is configured to iteratively update the generative adversarial network of the (i+1)th iteration based on the evaluation index value determined in the (i)th iteration and the multiple adversarial sample images generated, until a preset condition for stopping generating adversarial sample images is met, and use the discriminator of the generative adversarial network of the last iteration as the power image recognition model for identifying the target power image; wherein, i is a positive integer greater than or equal to 1.
[0106] In one embodiment, when the processing module 501 is used to add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images, it is specifically used to: add Gaussian noise and salt and pepper noise to each original image in the power image dataset to obtain multiple noisy seed images.
[0107] In one embodiment, the update module 503 is used to iteratively update the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image. Specifically, it is used to: update the network parameters of the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration to obtain the i+1th generative adversarial network; input the multiple adversarial sample images generated in the i-th iteration into the i+1th generative adversarial network; In the generator of the generative adversarial network, multiple new adversarial sample images generated by the i+1th iteration are obtained, and the multiple new adversarial sample images are input into the discriminator of the i+1th generative adversarial network to obtain the predicted category of each new adversarial sample image; based on the predicted category of each new adversarial sample image and the actual category of the original image corresponding to each new adversarial sample image, the evaluation index value corresponding to the i+1th iteration is determined, until the evaluation index value corresponding to N consecutive iterations is greater than or equal to the preset evaluation index threshold, the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image.
[0108] In one embodiment, the evaluation index value includes accuracy and / or total loss value; the total loss value is composed of a first loss value, a second loss value, and a third loss value; the first loss value is used to characterize the ability of the discriminator to recognize the original image, and the second loss value is used to characterize the ability of the discriminator to recognize the adversarial sample image corresponding to the original image; the third loss value is used to characterize the difference between the adversarial sample image and the original image corresponding to the adversarial sample image.
[0109] In one embodiment, the determination module 502 is further used to: input the original image into the discriminator of the generative adversarial network to obtain the probability of the predicted category of the original image, and determine a first loss value based on the probability of the predicted category of the original image; determine a second loss value based on the probability corresponding to the predicted category of the adversarial sample image; and determine a third loss value based on the probability corresponding to the predicted category of the adversarial sample image and the probability of the predicted category of the original image corresponding to the adversarial sample image.
[0110] In one embodiment, when the processing module 501 is used to input each noisy seed image into the generator of the generative adversarial network, generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image, it is specifically used to: input each original image and each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each original image and an adversarial sample image corresponding to each noisy seed image; and input the generated multiple adversarial sample images into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image.
[0111] Each module in the aforementioned training device for the power adversarial sample image recognition model can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a terminal device in hardware form, or stored in a memory in the terminal device in software form, allowing the processor to call and execute the corresponding operations of each module.
[0112] In an exemplary embodiment, the present application provides a computer device, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner. The wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, it implements a training method for an electric power adversarial sample image recognition model.
[0113] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0114] In an exemplary embodiment, the present application provides a computer device including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0115] Add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images;
[0116] Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain the predicted category of each adversarial sample image;
[0117] Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0118] Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; where i is a positive integer greater than or equal to 1.
[0119] In one embodiment, when a processor executes a computer program to add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images, the following steps are specifically implemented: Gaussian noise and salt and pepper noise are added to each original image in the power image dataset to obtain multiple noisy seed images.
[0120] In one embodiment, a processor executes a computer program to iteratively update the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, until a preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image, specifically implementing the following steps: updating the network parameters of the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration to obtain the i+1th generative adversarial network; inputting the multiple adversarial sample images generated in the i-th iteration into the i+1th generation adversarial network; In the generator of a generative adversarial network, multiple new adversarial sample images generated by the i+1th iteration are obtained, and the multiple new adversarial sample images are input into the discriminator of the i+1th generative adversarial network to obtain the predicted category of each new adversarial sample image; based on the predicted category of each new adversarial sample image and the actual category of the original image corresponding to each new adversarial sample image, the evaluation index value corresponding to the i+1th iteration is determined, until the evaluation index value corresponding to N consecutive iterations is greater than or equal to the preset evaluation index threshold, the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image.
[0121] In one embodiment, the evaluation index value includes accuracy and / or total loss value; the total loss value is composed of a first loss value, a second loss value, and a third loss value; the first loss value is used to characterize the ability of the discriminator to recognize the original image, and the second loss value is used to characterize the ability of the discriminator to recognize the adversarial sample image corresponding to the original image; the third loss value is used to characterize the difference between the adversarial sample image and the original image corresponding to the adversarial sample image.
[0122] In one embodiment, when the processor executes the computer program, it further implements the following steps: inputting the original image into the discriminator of the generative adversarial network to obtain the probability of the predicted category of the original image, and determining a first loss value based on the probability of the predicted category of the original image; determining a second loss value based on the probability corresponding to the predicted category of the adversarial sample image; and determining a third loss value based on the probability corresponding to the predicted category of the adversarial sample image and the probability of the predicted category of the original image corresponding to the adversarial sample image.
[0123] In one embodiment, when a processor executes a computer program to input each noisy seed image into a generator of a generative adversarial network, generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into a discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image, the following steps are specifically implemented: input each original image and each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each original image and an adversarial sample image corresponding to each noisy seed image; and input the generated multiple adversarial sample images into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image.
[0124] In an exemplary embodiment, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the following steps are implemented:
[0125] Add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images;
[0126] Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain the predicted category of each adversarial sample image;
[0127] Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0128] Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; where i is a positive integer greater than or equal to 1.
[0129] In one embodiment, when a computer program is executed by a processor to add at least two different noises to each original image in a power image dataset to obtain multiple noisy seed images, the following steps are specifically implemented: Gaussian noise and salt and pepper noise are added to each original image in the power image dataset to obtain multiple noisy seed images.
[0130] In one embodiment, a computer program is executed by a processor to iteratively update the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated until a preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image, specifically implementing the following steps: updating the network parameters of the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration to obtain the i+1th generative adversarial network; inputting the multiple adversarial sample images generated in the i-th iteration into the i+1th generation adversarial network; In the generator of a generative adversarial network, multiple new adversarial sample images generated by the i+1th iteration are obtained, and the multiple new adversarial sample images are input into the discriminator of the i+1th generative adversarial network to obtain the predicted category of each new adversarial sample image; based on the predicted category of each new adversarial sample image and the actual category of the original image corresponding to each new adversarial sample image, the evaluation index value corresponding to the i+1th iteration is determined, until the evaluation index value corresponding to N consecutive iterations is greater than or equal to the preset evaluation index threshold, the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image.
[0131] In one embodiment, the evaluation index value includes accuracy and / or total loss value; the total loss value is composed of a first loss value, a second loss value, and a third loss value; the first loss value is used to characterize the ability of the discriminator to recognize the original image, and the second loss value is used to characterize the ability of the discriminator to recognize the adversarial sample image corresponding to the original image; the third loss value is used to characterize the difference between the adversarial sample image and the original image corresponding to the adversarial sample image.
[0132] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: inputting the original image into the discriminator of the generative adversarial network to obtain the probability of the predicted category of the original image, and determining a first loss value based on the probability of the predicted category of the original image; determining a second loss value based on the probability corresponding to the predicted category of the adversarial sample image; and determining a third loss value based on the probability corresponding to the predicted category of the adversarial sample image and the probability of the predicted category of the original image corresponding to the adversarial sample image.
[0133] In one embodiment, when a computer program is executed by a processor to input each noisy seed image into the generator of a generative adversarial network, generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image, the following steps are specifically implemented: input each noisy seed image into the generator of the generative adversarial network, generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image.
[0134] In an exemplary embodiment, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the following steps:
[0135] Add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images;
[0136] Input each noisy seed image into the generator of the generative adversarial network to generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain the predicted category of each adversarial sample image;
[0137] Determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image;
[0138] Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, the generative adversarial network of the i+1-th iteration is iteratively updated until the preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image; where i is a positive integer greater than or equal to 1.
[0139] In one embodiment, when a computer program is executed by a processor to add at least two different noises to each original image in a power image dataset to obtain multiple noisy seed images, the following steps are specifically implemented: Gaussian noise and salt and pepper noise are added to each original image in the power image dataset to obtain multiple noisy seed images.
[0140] In one embodiment, a computer program is executed by a processor to iteratively update the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated until a preset condition for stopping generating adversarial sample images is met, and the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image, specifically implementing the following steps: updating the network parameters of the generative adversarial network of the i+1th iteration based on the evaluation index value determined in the i-th iteration to obtain the i+1th generative adversarial network; inputting the multiple adversarial sample images generated in the i-th iteration into the i+1th generation adversarial network; In the generator of a generative adversarial network, multiple new adversarial sample images generated by the i+1th iteration are obtained, and the multiple new adversarial sample images are input into the discriminator of the i+1th generative adversarial network to obtain the predicted category of each new adversarial sample image; based on the predicted category of each new adversarial sample image and the actual category of the original image corresponding to each new adversarial sample image, the evaluation index value corresponding to the i+1th iteration is determined, until the evaluation index value corresponding to N consecutive iterations is greater than or equal to the preset evaluation index threshold, the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image.
[0141] In one embodiment, the evaluation index value includes accuracy and / or total loss value; the total loss value is composed of a first loss value, a second loss value, and a third loss value; the first loss value is used to characterize the ability of the discriminator to recognize the original image, and the second loss value is used to characterize the ability of the discriminator to recognize the adversarial sample image corresponding to the original image; the third loss value is used to characterize the difference between the adversarial sample image and the original image corresponding to the adversarial sample image.
[0142] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: inputting the original image into the discriminator of the generative adversarial network to obtain the probability of the predicted category of the original image, and determining a first loss value based on the probability of the predicted category of the original image; determining a second loss value based on the probability corresponding to the predicted category of the adversarial sample image; and determining a third loss value based on the probability corresponding to the predicted category of the adversarial sample image and the probability of the predicted category of the original image corresponding to the adversarial sample image.
[0143] In one embodiment, when a computer program is executed by a processor to input each noisy seed image into the generator of a generative adversarial network, generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image, the following steps are specifically implemented: input each noisy seed image into the generator of the generative adversarial network, generate an adversarial sample image corresponding to each noisy seed image, and input each adversarial sample image into the discriminator of the generative adversarial network to obtain a predicted category for each adversarial sample image.
[0144] It should be noted that the data involved in this application (including but not limited to original images, adversarial sample images, target power images, etc.) are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0145] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), quantum computing-based data processing logic devices, artificial intelligence (AI) processors, and the like.
[0146] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0147] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A training method for an electric power adversarial sample image recognition model, characterized in that: The method comprises: Add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images; Inputting each of the noisy seed images into a generator of a generative adversarial network to generate an adversarial sample image corresponding to each of the noisy seed images, and inputting each of the adversarial sample images into a discriminator of the generative adversarial network to obtain a predicted category for each of the adversarial sample images; Determining an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image; the evaluation index value includes a total loss value; Based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated, iteratively updating the generative adversarial network of the i+1-th iteration until a preset condition for stopping generating adversarial sample images is met, and using the discriminator of the generative adversarial network of the last iteration as the power image recognition model for recognizing the target power image; wherein i is a positive integer greater than or equal to 1; The total loss value is composed of a first loss value, a second loss value, and a third loss value; the first loss value is used to characterize the ability of the discriminator to recognize the original image, the second loss value is used to characterize the ability of the discriminator to recognize the adversarial sample image corresponding to the original image; the third loss value is used to characterize the difference between the adversarial sample image and the original image corresponding to the adversarial sample image.
2. The method according to claim 1, characterized in that The method of adding at least two different noises to each original image in the power image dataset to obtain a plurality of noisy seed images includes: Gaussian noise and salt and pepper noise are added to each original image in the power image dataset to obtain multiple noisy seed images.
3. The method according to claim 1, characterized in that The method iteratively updates the generative adversarial network of the (i+1)th iteration based on the evaluation index value determined in the i-th iteration and the multiple adversarial sample images generated until a preset condition for stopping generating adversarial sample images is met, and uses the discriminator of the generative adversarial network of the last iteration as the power image recognition model for identifying the target power image, including: Based on the evaluation index value determined in the i-th iteration, the network parameters of the generative adversarial network of the i+1-th iteration are updated to obtain the i+1-th generative adversarial network; Inputting the multiple adversarial sample images generated in the i-th iteration into the generator of the i+1-th generative adversarial network to obtain multiple new adversarial sample images generated in the i+1-th iteration, and inputting the multiple new adversarial sample images into the discriminator of the i+1-th generative adversarial network to obtain a predicted category for each of the new adversarial sample images; Based on the predicted category of each of the new adversarial sample images and the actual category of the original image corresponding to each of the new adversarial sample images, the evaluation index value corresponding to the i+1th iteration is determined, until the evaluation index value corresponding to N consecutive iterations is greater than or equal to the preset evaluation index threshold, the discriminator of the generative adversarial network of the last iteration is used as the power image recognition model for identifying the target power image.
4. The method according to claim 1, wherein The first loss value, the second loss value, and the third loss value are determined in the following manner: Inputting the original image into the discriminator of the generative adversarial network to obtain a probability of a predicted category of the original image, and determining a first loss value based on the probability of the predicted category of the original image; Determining a second loss value based on a probability corresponding to the predicted category of the adversarial sample image; and A third loss value is determined based on a probability corresponding to the predicted category of the adversarial sample image and a probability corresponding to the predicted category of the original image corresponding to the adversarial sample image.
5. The method according to claim 1, wherein Inputting each of the noisy seed images into a generator of a generative adversarial network to generate an adversarial sample image corresponding to each of the noisy seed images, and inputting each of the adversarial sample images into a discriminator of the generative adversarial network to obtain a predicted category for each of the adversarial sample images, including: Inputting each of the original images and each of the noisy seed images into a generator of a generative adversarial network to generate an adversarial sample image corresponding to each of the original images and an adversarial sample image corresponding to each of the noisy seed images; The generated multiple adversarial sample images are input into the discriminator of the generative adversarial network to obtain a predicted category of each adversarial sample image.
6. A training device for an electric power adversarial sample image recognition model, characterized in that: The device comprises: a processing module, configured to add at least two different noises to each original image in the power image dataset to obtain a plurality of noisy seed images; The processing module is further configured to input each of the noisy seed images into a generator of a generative adversarial network to generate an adversarial sample image corresponding to each of the noisy seed images, and input each of the adversarial sample images into a discriminator of the generative adversarial network to obtain a predicted category for each of the adversarial sample images; A determination module, configured to determine an evaluation index value corresponding to the generative adversarial network based on the predicted category of each adversarial sample image and the actual category of the original image corresponding to each adversarial sample image; the evaluation index value includes a total loss value; an updating module, configured to iteratively update the generative adversarial network of the (i+1)th iteration based on the evaluation index value determined in the (i)th iteration and the multiple adversarial sample images generated, until a preset condition for stopping generating adversarial sample images is satisfied, and use the discriminator of the generative adversarial network of the last iteration as the power image recognition model for recognizing the target power image; wherein i is a positive integer greater than or equal to 1; The total loss value is composed of a first loss value, a second loss value, and a third loss value; the first loss value is used to characterize the ability of the discriminator to recognize the original image, the second loss value is used to characterize the ability of the discriminator to recognize the adversarial sample image corresponding to the original image; the third loss value is used to characterize the difference between the adversarial sample image and the original image corresponding to the adversarial sample image.
7. The device according to claim 6, characterized in that When the processing module is used to add at least two different noises to each original image in the power image dataset to obtain multiple noisy seed images, it is specifically used to: Gaussian noise and salt and pepper noise are added to each original image in the power image dataset to obtain multiple noisy seed images.
8. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 5 when executing the computer program.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Medical image classification-oriented adversarial sample generation method and system
CN110516695A