A confrontation training method and system
Through a multi-round iterative adversarial training method based on information gain, training samples with high threat intensity of adversarial samples are selected for adversarial training, and the adversarial samples are used to update the information gain, which solves the problem of low adversarial training efficiency in the existing technology and achieves faster model convergence and more efficient robust training.
Patent Information
- Application Number
- CN202210383948.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-13
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-04-13
AI Technical Summary
Existing adversarial training methods have low efficiency in improving the robustness of machine learning models. Especially when the threat intensity of adversarial samples is uneven, it is difficult to effectively accelerate the convergence of adversarial training of the model.
Through multiple rounds of iterative adversarial training based on the information gain of training samples, select training samples whose information gain is positively related to the threat intensity of adversarial samples for adversarial training. Use the adversarial samples generated from the current round of training samples to update the information gain and optimize the adversarial training strategy. Introduce Repeat sample detection and class balancing mechanisms to improve training efficiency.
It accelerates the convergence speed of the adversarial training of the model, saves training costs, improves the efficiency of adversarial training and the robustness of the model, and ensures the diversity and category balance of training samples.
Smart Images

Figure CN114707661B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to an adversarial training method and system. Background Art
[0002] Adversarial Training (AT) is an effective method to enhance the robustness of machine learning models (such as neural networks). During adversarial training, small perturbations / noises are added to the original samples (small changes, but likely to cause model prediction errors), and then the model is made to adapt to such changes (maintaining correct predictions as much as possible), that is, the model is made robust to adversarial examples (AE) obtained after scrambling / noising, which improves the model's ability to resist adversarial attacks.
[0003] Currently, it is hoped to provide an efficient adversarial training scheme. Summary of the invention
[0004] One of the embodiments of this specification provides an adversarial training method, including: performing multiple rounds of iterative adversarial training on a target model based on multiple training samples. One round of iteration includes: selecting a current round of training samples participating in the current round of adversarial training from the multiple training samples based on the information gain of the training samples, wherein the information gain of the training samples is positively correlated with the threat intensity of the adversarial samples generated based on the training samples to the target model; and performing adversarial training on the target model based on the current round of training samples to improve the target model's ability to resist adversarial attacks.
[0005] One of the embodiments of this specification provides an adversarial training system, including a current round training sample selection module and an adversarial training module. The system is used to perform multiple rounds of iterative adversarial training on a target model based on multiple training samples. For one round of iterations: the current round training sample selection module is used to select current round training samples participating in the current round adversarial training from the multiple training samples based on the information gain of the training samples, wherein the information gain of the training samples is positively correlated with the threat intensity of the adversarial samples generated based on the training samples to the target model; the adversarial training module is used to perform adversarial training on the target model based on the current round training samples to improve the target model's ability to resist adversarial attacks.
[0006] One of the embodiments of this specification provides an adversarial training device, including a processor and a storage device, wherein the storage device is used to store instructions. When the processor executes the instructions, the adversarial training method described in any embodiment of this specification is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] This specification will be further described in the form of exemplary embodiments, which will be described in detail by the accompanying drawings. These embodiments are not restrictive, and in these embodiments, the same number represents the same structure, wherein:
[0008] Figure 1 is a schematic diagram of the principle of adversarial training according to some embodiments of this specification;
[0009] Figure 2 is an exemplary flow chart of performing adversarial training on a target model based on the current round of training samples according to some embodiments of this specification;
[0010] Figure 3 is an exemplary calculation method of information gain according to some embodiments of this specification;
[0011] Figure 4 is an exemplary module diagram of an adversarial training system according to some embodiments of this specification. DETAILED DESCRIPTION
[0012] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following is a brief introduction to the drawings required for the description of the embodiments. Obviously, the drawings described below are only some examples or embodiments of this specification. For ordinary technicians in this field, this specification can also be applied to other similar scenarios based on these drawings without creative work. Unless it is obvious from the language environment or otherwise explained, the same reference numerals in the figures represent the same structure or operation.
[0013] It should be understood that the "system", "device", "unit" and / or "module" used herein are a method for distinguishing different components, elements, parts, portions or assemblies at different levels. However, if other words can achieve the same purpose, the words can be replaced by other expressions.
[0014] As shown in this specification, unless the context clearly indicates an exception, the words "a", "an", "a kind" and / or "the" do not refer to the singular, but also include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of the steps and elements that have been clearly identified, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements.
[0015] Flowcharts are used in this specification to illustrate the operations performed by the system according to the embodiments of this specification. It should be understood that the preceding or following operations are not necessarily performed precisely in order. Instead, the steps may be processed in reverse order or simultaneously. At the same time, other operations may also be added to these processes, or one or more operations may be removed from these processes.
[0016] Adversarial attacks can cause models to produce unexpected outputs. Adversarial attacks can be achieved by adding imperceptible disturbances / noise to the model input data (such as prediction samples or feature values of prediction samples). Taking the classification model as an example, inputting the scrambled / noised identification object into the classification model may cause the model to output incorrect classification results. For example, in a face recognition scenario, an attacker (such as Zhang San) may cause the face recognition system to misclassify him as someone with another identity (such as Li Si) by wearing glasses, which may cause adverse effects (such as Zhang San illegally breaking into the room by impersonating Li Si). It should be understood that wearing glasses is a specific way to add tiny disturbances / noise to the recognized face image. For another example, in a speech recognition scenario, adding noise to an audio, although the human ear cannot hear the difference between the two audios before and after the noise is added, the speech recognition system may give completely different recognition results.
[0017] Adversarial training is considered to be one of the effective means to enhance the robustness of machine learning models, that is, to improve the model's ability to resist adversarial attacks. Figure 1 Schematic diagram of the principle of adversarial training according to some embodiments of this specification. Figure 1 As shown, in the process of adversarial training, based on the model input x (i.e., original input x) corresponding to the original training sample and the perturbation data z, the model input x' (i.e., mixed input x') corresponding to the adversarial sample is obtained. In some scenarios, the model input corresponding to the sample is also referred to as the feature of the sample. In some embodiments, scrambling can be achieved by means of a mask, that is, replacing a specific part of the model input x with the perturbation data z to obtain the scrambled model input. Continuing with the example in the previous article, when the model input is a face image, the eye area of the face can be covered with a frame to obtain a scrambled face image. The goal of adversarial training is to adapt the target model to the perturbation (maintaining the correct classification as much as possible). Specifically, it is to make the target model correctly classify the adversarial sample as the label k of the original training sample. It should be understood that the label k reflects the true category of the original training sample.
[0018] Adversarial training is usually carried out in a multi-round iteration. Specifically, in each round of iteration, a small batch of training samples can be extracted from a large number of training samples (such as a training set) to participate in the current round of adversarial training, so that the computational load of a single training can be avoided. In some specific embodiments of the adversarial training method, a large number of training samples can be pre-divided into multiple small batches of training samples, and the model can be trained in turn, or a random sampling strategy can be used to extract training samples participating in each round of adversarial training. It can be considered that in these adversarial training embodiments, the probability or frequency of each training sample participating in adversarial training is basically equal. The embodiment of this specification provides a sampling strategy based on the information gain of training samples. The information gain of training samples can indicate the importance of the training sample to the adversarial training of the target model. In fact, the importance of different training samples to the adversarial training of the target model may vary. Specifically, a training sample can bring more information gain to the adversarial training (or learning) of the target model under the setting of adversarial training goals, which means that the training sample is more important to the adversarial training of the target model. To help understand, here is an intuitive example. Assume: the label of training sample A is k1, and the label of training sample B is k2; the current target model predicts the category of adversarial sample A' corresponding to training sample A as k1, and predicts the category of adversarial sample B' corresponding to training sample B as k3. Obviously, the current target model already has good robustness to training sample A, while the robustness to training sample B needs to be strengthened. This can be further understood as the current target model is more "familiar" with training sample A, while training sample B can bring more useful information to the training of the target model. Therefore, compared with training sample A, training sample B is more important for the adversarial training of the current target model. From another perspective, the importance of adversarial training of training samples to the target model can also be understood as the threat intensity of adversarial samples generated based on the training samples to the target model. This is because the stronger the robustness of the target model to the training samples, the lower the threat intensity of the training samples to the target model.
[0019] It can be understood that, under the set adversarial training goal, the more training samples with larger information gain in the training samples used to train the target model, the faster the convergence speed of the target model will be, that is, the faster the target model that meets the set adversarial training goal will be obtained. In view of this, in the sampling strategy based on the information gain of training samples, in a single round of iteration, high-importance training samples can be selected from multiple training samples according to the information gain of the training samples to participate in the current round of adversarial training, which can accelerate the convergence of the target model and complete the adversarial training faster. Referring to the previous text, the information gain of the training sample can be positively correlated with the threat intensity of the adversarial sample generated based on the training sample to the target model.
[0020] The following are some specific sampling strategies based on the information gain of training samples.
[0021] In some embodiments, the information gain of the training sample can be used as a sampling weight, and multiple training samples can be sampled once or multiple times to obtain the current round of training samples. Specifically, the larger the sampling weight, the greater the probability that the corresponding training sample is drawn. For example, the information gain of training sample A is g1, and the information gain of training sample B is g2. If g1 is greater than g2, training sample A is more likely to be selected to participate in the current round of adversarial training than training sample B. If g1 is less than g2, training sample B is more likely to be selected to participate in the current round of adversarial training than training sample A. If g1=g2, the probability of training sample A and training sample B being selected to participate in the current round of adversarial training is equal.
[0022] In some embodiments, the sampling mentioned in this specification may be sampling with replacement or sampling without replacement. When sampling with replacement is used, the same training sample (especially a training sample with high information gain) may be repeatedly drawn. It can be understood that the diversity of training samples also helps to efficiently complete model training, because repeated training samples not only occupy training costs but also cannot provide new value / information for model training. In order to improve the diversity of training samples, a repeated sample detection mechanism can be introduced. Specifically, in the process of performing the one or more samplings on the multiple training samples, if the training sample currently extracted is repeated with the training sample that has been extracted, the training sample currently extracted is discarded so that there are no repeated training samples in the current round of training samples. For example, the training samples that have been extracted include training sample A, training sample B, etc., and the training sample currently extracted is training sample A, then the repeated training sample A can be discarded and resampled until the number of training samples required for the current round of training is extracted, while ensuring that the training samples of the same small batch are different. By introducing a repeated sample detection mechanism, the model convergence speed can be further improved and the training cost can be saved.
[0023] Similarly, the class balance of training samples also helps to complete model training efficiently. In order to promote the class balance of training samples, a class balance mechanism can be introduced. Taking the classification model as an example, when selecting the current round of training samples according to the information gain of the training samples, a preset number of training samples can be selected from the training samples under each classification category as the current round of training samples, so that the number of training samples under each classification category in the current round of training samples is balanced. It can be understood that the classification category here refers to the sample label known before training, that is, the true category of the sample. As an example only, the classification categories include k1, k2, and k3. It can be set to select 100 training samples under each classification category as the target of the current round of training samples, that is, it is hoped that the current round of training samples includes 100 training samples of the k1 category, 100 training samples of the k2 category, and 100 training samples of the k3 category. More specifically, for replacement sampling, when the number of training samples of any category (which may be recorded as k1) drawn has reached the preset number, if the subsequent training sample drawn is still k1, the training sample can be discarded. Of course, 100 training samples with the highest information gain can also be selected from the training samples under each classification category as the current round of training samples.
[0024] In some embodiments, the information gain of each training sample may be updated as the target model is trained. In each round of iterative adversarial training, sampling is first performed based on the information gain of each training sample (the latest one at the moment) to obtain training samples participating in the current round of adversarial training, in order to distinguish, or become the current round of training samples.
[0025] Figure 2 is an exemplary flow chart of performing adversarial training on a target model based on the current round of training samples according to some embodiments of this specification. Figure 2 As shown, process 200 may include the following steps.
[0026] Step 210, obtaining the current round adversarial samples based on the current round training samples.
[0027] As mentioned above, the features of the adversarial sample can be generated based on the features of its corresponding training sample and the perturbation data. The label of the adversarial sample is still equal to the label of its corresponding training sample.
[0028] It can be understood that the size of the perturbation data can be controlled within a certain range to ensure that the perturbation is not easily detected. In some embodiments, perturbation data can be generated based on the prediction error of the target model for the training sample, and the perturbation data can be added to the training sample to obtain the adversarial sample corresponding to the training sample. In some embodiments, the target model can be used to process the training sample or the characteristic value of the training sample to obtain a prediction result. Then determine the gradient information of the difference between the prediction result and the training sample label relative to the characteristic value of the training sample, and use the gradient information as the perturbation data. This specification does not specifically limit the adversarial sample generation algorithm used. As an example only, known adversarial sample generation algorithms such as Box-constrained L-BFGS and FGSM can be used. New adversarial sample generation algorithms proposed in the future are also applicable to the adversarial training method provided in this article. In some embodiments, adversarial samples can also be regenerated based on the adversarial samples corresponding to the training samples through the target model iteration, and the regenerated adversarial samples are used as adversarial samples corresponding to the training samples. It can be understood that a current round of training samples can generate multiple adversarial samples.
[0029] Step 220: Perform adversarial training on the target model based on the current round of adversarial samples.
[0030] The goal of adversarial training is to enhance the robustness of the target model, which can include two aspects: one is to maintain the prediction accuracy of the target model for the original training samples, that is, to control the difference between the prediction results of the training samples and the labels; the other is to improve the prediction accuracy of the target model for the scrambled adversarial samples, that is, to control the difference between the prediction results of the adversarial samples and the labels. In some embodiments, the goal of adversarial training may only include controlling the difference between the prediction results of the adversarial samples and the labels.
[0031] In some embodiments, in any round of iteration, corresponding multiple adversarial samples can be generated based on the multiple training samples, that is, a full amount of adversarial samples can be produced. Furthermore, based on the multiple adversarial samples and the target model (to be subjected to the current round of adversarial training), the information gain of the multiple training samples can be obtained. According to the information gain of the multiple training samples, the current round training samples participating in the current round of adversarial training can be selected from the multiple training samples. Furthermore, the current round adversarial samples corresponding to the current round training samples can be determined from the multiple adversarial samples.
[0032] In the above implementation, a full amount of adversarial samples need to be produced before adversarial training based on adversarial samples, which has a high computational cost. In view of this, the present specification also provides another implementation, which can initialize the information gain of the multiple training samples in advance, and the initialized information gain of each training sample is used to select the current round of training samples in the first round of iteration. In the first round of adversarial training, the information gain of the current round of training samples in the first round of iteration can be updated, such as based on the initialized information gain of the current round of training samples, the updated information gain of the training samples can be obtained, which is used to select the current round of training samples in the next round of iteration.
[0033] In some embodiments, the information gain of each training sample can be pre-set to the same preset value (for example, the information gain of the multiple training samples is initialized to 1). At this time, it can be considered that each training sample has the same importance to the adversarial training of the target model, so the current round of training samples participating in the first round of adversarial training can be randomly selected from the multiple training samples.
[0034] In some embodiments, a round of iterative adversarial training also includes determining the current round information gain of the corresponding training sample based on the current round adversarial sample and the target model after the current round adversarial training after adversarial training of the target model based on the current round adversarial sample, and updating the information gain of the training sample based on the current round information gain of the corresponding training sample, and specifically using the current round information gain of the corresponding training sample as the information gain of the training sample. Considering that the information gain of the training sample is positively correlated with the threat intensity of the adversarial sample generated based on the training sample to the target model, in some embodiments, the current round adversarial sample can be used to perform an adversarial attack test on the target model after the current round adversarial training to obtain the threat intensity of the adversarial sample generated by each current round training sample to the target model after the current round adversarial training. Exemplarily, multiple adversarial samples generated by a current round training sample are used to perform an attack test on the target model after the current round adversarial training, where the proportion of adversarial samples with successful attacks (model prediction results are different from corresponding labels) to the total number of adversarial samples generated by the training sample can be used as the current round information gain of the training sample.
[0035] In the study, we found that the prediction results (i.e., outputs) of adversarial samples generated based on the same training sample in different rounds (such as adjacent rounds) of iteration using the target model have a high degree of similarity. It can be considered that the information gain of the same training sample has a certain degree of stability in different rounds of iteration. Therefore, in the said round of iterative adversarial training, the information gain of the training sample can be jointly updated based on the information gain re-determined in the current round of the training sample and its existing information gain (such as determined in the historical iteration round), thereby ensuring the stability of the information gain of the training sample to a certain extent and improving the model training efficiency. In some alternative embodiments, the said round of iterative adversarial training also includes determining the initial information gain of the corresponding training sample based on the current round of adversarial samples and the target model after the current round of adversarial training; then obtaining the current round information gain of the corresponding training sample based on the information gain of the corresponding training sample (i.e., the existing information gain) and the initial information gain, and updating the information gain of the training sample based on the current round information gain of the corresponding training sample. In some embodiments, the method of determining the initial information gain of the corresponding training sample can be similar to the method of determining the current round information gain of the corresponding training sample in the previous embodiment. In this embodiment, the information gain of the corresponding training sample (i.e., the existing information gain) and its initial information gain can be weighted and summed to obtain the current round information gain of the corresponding training sample in this embodiment. The specific calculation method can be expressed as follows:
[0036]
[0037] in, represents the current round information gain of training sample i in the i-th iteration, represents the information gain of the training sample i, w i represents the initial information gain of training sample i, and α represents the balance coefficient between 0 and 1.
[0038] For a multi-classification model (three or more categories in total), the initial information gain can also be calculated as Figure 3 The specific process shown is calculated. It can be understood that Figure 3 The process shown can also be used as the calculation method of the information gain of the current round in the previous embodiment. Take one of the adversarial samples in the current round as an example. Figure 3 As shown, process 300 may include the following steps.
[0039] Step 310, using the target model after the current round of adversarial training to process the features of the adversarial sample to obtain a prediction result.
[0040] The prediction result can be in various forms. For example, the prediction result can indicate which category the predicted object belongs to (hereinafter referred to as the predicted category). In another example, the prediction result can indicate the probability that the predicted object belongs to each category (hereinafter referred to as the predicted probability, also referred to as the confidence). Specifically, the prediction result can be in the form of a vector (hereinafter referred to as a prediction vector), where each bit of the prediction vector corresponds to a category and reflects the probability that the predicted object belongs to the category.
[0041] Step 320: Obtain a first similarity between the prediction result and the label of the adversarial sample.
[0042] Referring to the description of the prediction results, the first similarity can directly describe whether the predicted category and label of the adversarial sample by the target model are the same (for example, "1" indicates the same and "0" indicates different), or it can also be represented by the predicted probability corresponding to the label category of the adversarial sample in the prediction result.
[0043] Step 330 , obtaining one or more second similarities between the prediction result and one or more other category labels except the label of the adversarial sample.
[0044] Similarly, the second similarity can directly describe whether the predicted category of the adversarial sample of the target model is the same as the other category label, or can also be represented by the predicted probability corresponding to the other category label in the prediction result.
[0045] Step 340: Obtain an initial information gain of a training sample corresponding to the adversarial sample based on a maximum value of differences between the one or more second similarities and the first similarity.
[0046] Specifically, for a binary classification model, the difference between the second similarity and the first similarity can be directly used as the initial information gain. For a multi-classification model, the maximum value of multiple differences can be used as the initial information gain.
[0047] It can be understood that the difference here can be a positive number or a negative number. When the second similarity is greater than the first similarity, the difference is positive, otherwise it is negative.
[0048] The maximum value reflects the certainty of the target model in correctly classifying the adversarial sample (or the possibility that the target model misclassifies the adversarial sample). The greater the certainty of the target model in correctly classifying the adversarial sample, the lower the threat intensity of the adversarial sample to the target model. The larger the maximum value, the greater the confidence of the current target model in classifying the adversarial sample into a category other than the label (i.e., misclassification), and the greater the threat intensity of the adversarial sample to the target model, so the initial information gain of the current round of training samples corresponding to the adversarial sample is greater; the smaller the maximum value, the smaller the confidence of the current target model in classifying the adversarial sample into a category other than the label, and the lower the threat intensity of the adversarial sample to the target model, that is, the smaller the initial information gain of the current round of training samples corresponding to the adversarial sample is.
[0049] In some embodiments, the specific calculation method of the initial information gain can be expressed as follows:
[0050]
[0051] Among them, w i represents the initial information gain of the training sample numbered i (referred to as training sample i), x i is the feature of training sample i, δ i represents the perturbation data added to training sample i, x i +δ i represents the characteristics of the adversarial sample obtained after scrambling the training sample i, y i represents the label of training sample i (also the label of its corresponding adversarial sample), k represents the number of samples in addition to y i Other category labels. θ represents the target model, which can be the target model after the current round of adversarial training, F θ ()[] represents the predicted probability (confidence) corresponding to the []th class label in the prediction vector of training sample i. max represents the maximum value, log represents the logarithm, and 1 to K are used to distinguish multiple (such as three or more) class labels. It can be seen that when predicting the adversarial sample generated by training sample i, if the target model outputs high confidence (such as probability close to 1) for other class labels k and outputs high confidence (such as probability close to 1) for label y i Output low confidence (such as probability close to 0), that is, the target model is likely to misclassify the adversarial sample, then w i The larger the value of , the higher the threat intensity of the adversarial sample of training sample i to the target model.
[0052] For the binary classification model, there is only one other category label k for the adversarial sample. Accordingly, the initial information gain of the current round of training samples corresponding to the adversarial sample can be obtained directly based on the difference between the two logarithmic values in formula (1) (i.e., no maximum value is required).
[0053] In some embodiments, in the iterative adversarial training, a current round training sample can generate multiple adversarial samples, and then according to Figure 3 The process shown can obtain multiple w i , which can be calculated for multiple adversarial samples i Perform fusion, such as calculating the mean, to obtain the initial information gain of the round of training samples.
[0054] It should be noted that the above description of the relevant process is only for example and explanation, and does not limit the scope of application of this specification. For those skilled in the art, various modifications and changes can be made to the process under the guidance of this specification. However, these modifications and changes are still within the scope of this specification.
[0055] Figure 4 It is a module diagram of an adversarial training system according to some embodiments of this specification.
[0056] like Figure 4 As shown, the system 400 may include a current round training sample selection module 410 and an adversarial training module 420 .
[0057] System 400 can be used to perform multiple rounds of iterative adversarial training on a target model based on multiple training samples.
[0058] For one round of iterations: the current round training sample selection module 410 can be used to select the current round training samples participating in the current round adversarial training from the multiple training samples based on the information gain of the training samples, wherein the information gain of the training samples is positively correlated with the threat intensity of the adversarial samples generated based on the training samples to the target model; the adversarial training module 420 can be used to perform adversarial training on the target model based on the current round training samples to improve the target model's ability to resist adversarial attacks.
[0059] For more details about the system 400 and its modules, reference may be made to the aforementioned embodiments.
[0060] It should be understood that Figure 4The system and its modules shown can be implemented in various ways. For example, in some embodiments, the system and its modules can be implemented by hardware, software or a combination of software and hardware. Among them, the hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or a dedicated design hardware. Those skilled in the art will understand that the above methods and systems can be implemented using computer executable instructions and / or included in a processor control code, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. Such code is provided on the system and its modules of this specification. Not only can the hardware circuits such as ultra-large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc. be implemented, it can also be implemented with software such as executed by various types of processors, and it can also be implemented by a combination of the above hardware circuits and software (for example, firmware).
[0061] It should be noted that the above description of the system and its modules is only for convenience of description and does not limit this specification to the scope of the embodiments. It is understandable that for those skilled in the art, after understanding the principle of the system, it is possible to arbitrarily combine the various modules or form a subsystem to connect with other modules without deviating from this principle. For example, in some embodiments, the current round training sample selection module 410 can be further divided into two submodules: an information gain determination module and a sampling module. Such variations are all within the scope of protection of this specification.
[0062] The beneficial effects that may be brought about by the embodiments of this specification include but are not limited to: (1) selecting training samples participating in adversarial training based on the information gain of training samples can accelerate model iteration and improve the efficiency of adversarial training; (2) using adversarial samples generated in historical iteration rounds to update the information gain of training samples, there is no need to generate adversarial samples for each training sample at the beginning of each iteration, saving training costs; (3) by introducing a duplicate sample detection mechanism, the diversity of samples participating in adversarial training is improved, which helps to efficiently complete model training; (4) by introducing a category balance mechanism, the category balance of training samples participating in adversarial training is promoted, which helps to efficiently complete model training. It should be noted that different embodiments may produce different beneficial effects. In different embodiments, the beneficial effects that may be produced may be any one or a combination of the above, or any other possible beneficial effects.
[0063] The basic concepts have been described above. Obviously, for those skilled in the art, the above detailed disclosure is only for example and does not constitute a limitation on the embodiments of this specification. Although not explicitly stated here, those skilled in the art may make various modifications, improvements and corrections to the embodiments of this specification. Such modifications, improvements and corrections are suggested in the embodiments of this specification, so such modifications, improvements and corrections still belong to the spirit and scope of the exemplary embodiments of this specification.
[0064] At the same time, this specification uses specific words to describe the embodiments of this specification. For example, "one embodiment", "an embodiment" and / or "some embodiments" refer to a certain feature, structure or characteristic related to at least one embodiment of this specification. Therefore, it should be emphasized and noted that "one embodiment" or "an embodiment" or "an alternative embodiment" mentioned twice or more in different locations in this specification does not necessarily refer to the same embodiment. In addition, certain features, structures or characteristics in one or more embodiments of this specification can be appropriately combined.
[0065] In addition, it will be appreciated by those skilled in the art that the various aspects of the embodiments of this specification may be illustrated and described by a number of patentable categories or situations, including any new and useful process, machine, product or combination of substances, or any new and useful improvements thereto. Accordingly, the various aspects of the embodiments of this specification may be performed entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software. The above hardware or software may all be referred to as "data blocks", "modules", "engines", "units", "components" or "systems". In addition, the various aspects of the embodiments of this specification may be represented as a computer product located in one or more computer-readable media, the product including computer-readable program code.
[0066] A computer storage medium may include a propagated data signal containing computer program code, for example, in baseband or as part of a carrier wave. The propagated signal may be in a variety of forms, including electromagnetic, optical, etc., or a suitable combination. A computer storage medium may be any computer-readable medium other than a computer-readable storage medium, which can be connected to an instruction execution system, device or apparatus to communicate, propagate or transmit the program for use. The program code on the computer storage medium may be transmitted via any suitable medium, including radio, cable, fiber optic cable, RF, or similar media, or any combination of the above media.
[0067] The computer program coding required for the operation of each part of the embodiment of this specification can be written in any one or more programming languages, including object-oriented programming languages such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB.NET, Python, etc., conventional procedural programming languages such as C language, VisualBasic, Fortran2003, Perl, COBOL2002, PHP, ABAP, dynamic programming languages such as Python, Ruby and Groovy, or other programming languages, etc. The program coding can be run completely on the user's computer, or run on the user's computer as an independent software package, or partly run on the user's computer and partly run on the remote computer, or run completely on the remote computer or processing equipment. In the latter case, the remote computer can be connected to the user's computer by any network form, such as a local area network (LAN) or a wide area network (WAN), or connected to an external computer (e.g., by the Internet), or in a cloud computing environment, or used as a service such as software as a service (SaaS).
[0068] In addition, unless explicitly stated in the claims, the order of the processing elements and sequences described in the embodiments of this specification, the use of alphanumeric characters, or the use of other names are not intended to limit the order of the processes and methods of the embodiments of this specification. Although the above disclosure discusses some invention embodiments that are currently considered useful through various examples, it should be understood that such details are only for illustrative purposes, and the attached claims are not limited to the disclosed embodiments. On the contrary, the claims are intended to cover all modifications and equivalent combinations that are consistent with the essence and scope of the embodiments of this specification. For example, although the system components described above can be implemented by hardware devices, they can also be implemented only by software solutions, such as installing the described system on an existing processing device or mobile device.
[0069] Similarly, it should be noted that in order to simplify the description of the embodiments disclosed in this specification, thereby helping to understand one or more embodiments of the invention, in the above description of the embodiments of this specification, multiple features are sometimes combined into one embodiment, figure or description thereof. However, this disclosure method does not mean that the features required by the objects of the embodiments of this specification are more than the features mentioned in the claims. In fact, the features of the embodiments are less than all the features of the single embodiment disclosed above.
[0070] Each patent, patent application, patent application publication, and other materials, such as articles, books, specifications, publications, documents, etc., cited in this specification is hereby incorporated by reference in its entirety. Except for application history documents that are inconsistent with or conflicting with the contents of this specification, documents that limit the broadest scope of the claims of this application (currently or later attached to this application) are also excluded. It should be noted that if the descriptions, definitions, and / or use of terms in the materials attached to this specification are inconsistent or conflicting with the contents described in this specification, the descriptions, definitions, and / or use of terms in this specification shall prevail.
[0071] Finally, it should be understood that the embodiments described in this specification are only used to illustrate the principles of the embodiments of this specification. Other variations may also fall within the scope of the embodiments of this specification. Therefore, as an example and not a limitation, alternative configurations of the embodiments of this specification may be considered consistent with the teachings of this specification. Accordingly, the embodiments of this specification are not limited to the embodiments explicitly introduced and described in this specification.
Claims
1. An adversarial training method, comprising: performing multiple rounds of iterative adversarial training on a target model based on multiple training samples, wherein the multiple training samples include image samples or speech samples, wherein one round of iteration includes: Determine the information gain of the training sample according to the target model after the last round of adversarial training; wherein the information gain of the training sample is positively correlated with the threat intensity of the adversarial sample generated based on the training sample to the target model; Selecting a current round of training samples participating in a current round of adversarial training from the multiple training samples according to the information gain of the training samples includes: Using the information gain of the training sample as a sampling weight, sampling the multiple training samples once or multiple times to obtain the current round of training samples, wherein the greater the sampling weight, the greater the probability that the corresponding training sample is drawn; The target model is subjected to adversarial training based on the current round of training samples to improve the ability of the target model to resist adversarial attacks.
2. The method according to claim 1, wherein the adversarial training of the target model based on the current round of training samples comprises: Generate adversarial samples based on the current round of training samples; The features of the adversarial sample are generated based on the features of its corresponding training sample and the perturbation data, and the label of the adversarial sample is equal to the label of its corresponding training sample; The target model is subjected to adversarial training based on the adversarial sample.
3. The method of claim 2, wherein one of the iterations further comprises: Based on the adversarial sample and the target model after the current round of adversarial training, the current round information gain of the corresponding training sample is determined, and the information gain of the training sample is updated based on the current round information gain of the corresponding training sample.
4. The method of claim 2, wherein one of the iterations further comprises: Determine the initial information gain of the corresponding training sample based on the adversarial sample and the target model after the current round of adversarial training; The current round information gain of the corresponding training sample is obtained based on the information gain of the corresponding training sample and the initial information gain, and the information gain of the training sample is updated based on the current round information gain of the corresponding training sample.
5. The method according to claim 4, wherein the target model is a classification model; and determining the initial information gain of the corresponding training sample based on the adversarial sample and the target model after the current round of adversarial training comprises: Use the target model after the current round of adversarial training to process the features of the adversarial sample and obtain the prediction result; Obtaining a first similarity between the prediction result and the label of the adversarial sample; Obtaining one or more second similarities between the prediction result and one or more other category labels other than the label of the adversarial sample; Based on the maximum value of the difference between the one or more second similarities and the first similarity, an initial information gain of the corresponding training sample is obtained.
6. The method of claim 1, wherein: In the process of sampling the multiple training samples one or more times, if the training sample currently extracted is repeated with the training sample already extracted, the training sample currently extracted is discarded so that there is no repeated training sample in the current round of training samples.
7. The method of claim 1, wherein: The target model is a classification model; the current round of training samples participating in the current round of adversarial training are selected from the multiple training samples based on the information gain of the training samples, including: based on the information gain of the training samples, a preset number of training samples are selected from the training samples under each classification category as the current round of training samples, so that the number of training samples under each classification category in the current round of training samples is balanced.
8. The method of claim 1, wherein: When one of the iterations is the first iteration, the information gain of the training sample is the same preset value; The selecting, according to the information gain of the training samples, the current round of training samples participating in the current round of adversarial training from the multiple training samples includes: randomly selecting the current round of training samples participating in the current round of adversarial training from the multiple training samples.
9. An adversarial training system, comprising a current round training sample selection module and an adversarial training module; The system is used to perform multiple rounds of iterative adversarial training on the target model based on multiple training samples, wherein the multiple training samples include image samples or speech samples; For one of the iterations: The current round training sample selection module is used to determine the information gain of the training sample according to the target model after the previous round of adversarial training; wherein, The information gain of the training sample is positively correlated with the threat intensity of the adversarial sample generated based on the training sample to the target model; as well as Selecting a current round of training samples participating in a current round of adversarial training from the multiple training samples according to the information gain of the training samples includes: Using the information gain of the training sample as a sampling weight, sampling the multiple training samples once or multiple times to obtain the current round of training samples, wherein the greater the sampling weight, the greater the probability that the corresponding training sample is drawn; The adversarial training module is used to perform adversarial training on the target model based on the current round of training samples to improve the ability of the target model to resist adversarial attacks.
10. An adversarial training apparatus, comprising a processor and a storage device, wherein the storage device is used to store instructions, wherein: When the processor executes the instructions, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Business risk prevention and control method, device and equipment
CN109598281A
Deep neural network attack method and device, medium and computing equipment
CN110084002A
