A method and device for generating adversarial samples based on dynamic scheduling
Through the dynamically scheduled adversarial sample generation method, the problem of low adversarial sample generation efficiency in the prior art is solved, efficient adversarial sample generation and task management are realized, and the adversarial sample generation process is simplified.
Patent Information
- Application Number
- CN202011544521.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-24
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2040-12-24
AI Technical Summary
In the prior art, the efficiency of adversarial sample generation is low, requiring a lot of time to select and schedule data and models, and the efficiency of integration of adversarial sample generation algorithms is low, and the task scheduling and management capabilities are poor.
Adopting the adversarial sample generation method based on dynamic scheduling, the corresponding generation tasks are determined by obtaining the original sample data and deep learning model, matching the corresponding algorithm, and scheduling according to the task priority and number of executions, dynamically update the algorithm library to realize the adversarial sample Efficient generation.
It improves the efficiency of adversarial sample generation, simplifies task management, and realizes the generation of a large number of adversarial samples in a short time, ensuring the generation efficiency of adversarial samples and the adaptation of system resources.
Smart Images

Figure CN114676811B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method and device for generating adversarial samples based on dynamic scheduling. Background Art
[0002] Deep learning is an important field of artificial intelligence and is widely used in fields such as computer vision. The security issues of deep learning systems are increasingly attracting the attention of researchers. Adversarial samples (i.e., samples with perturbed data) can not only be used to detect security issues in deep learning, but also to reinforce deep learning models. In the process of training the model, if perturbed samples are added to the data set, a more robust model can be constructed, which can effectively defend against attacks from adversarial samples.
[0003] At present, there are more and more algorithms for generating adversarial samples, which greatly facilitates the generation of adversarial samples. However, it takes a lot of time to select and use the original data and deep learning models from a large number of algorithms, and in the process of generating adversarial samples, it is also necessary to continuously select the appropriate deep learning architecture from a large number of deep learning architectures according to the performance parameters of the determined adversarial sample generation algorithm. In addition, the training process of neural networks requires the support of a large number of adversarial samples, so how to improve the efficiency of adversarial sample generation is an urgent problem to be solved. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides an adversarial sample generation method and device based on dynamic scheduling, which solves the problem of low efficiency of adversarial sample generation in the prior art.
[0005] According to a first aspect, an embodiment of the present invention provides a method for generating adversarial samples based on dynamic scheduling, comprising:
[0006] Obtain multiple original sample data and deep learning models to determine the corresponding adversarial sample generation tasks;
[0007] Based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm, matching at least one corresponding adversarial sample generation algorithm in a preset algorithm library;
[0008] Scheduling the adversarial sample generation tasks according to the preset execution quantity of the adversarial sample generation tasks and the priority of each adversarial sample generation task, and determining the current adversarial sample generation task to be executed;
[0009] Obtain the configuration parameters of the current adversarial sample generation task, schedule the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determine the scheduling algorithm;
[0010] The deep learning model is encapsulated, and based on the encapsulated model and the scheduling algorithm, the current adversarial sample generation task is executed in sequence to generate corresponding adversarial samples.
[0011] The adversarial sample generation method based on dynamic scheduling provided by the embodiment of the present invention determines the corresponding adversarial sample generation task through the original sample data and the deep learning model. After determining the corresponding adversarial sample generation algorithm, the encapsulated model is determined by using the corresponding implementation function of the adversarial sample generation algorithm and the original uploaded deep learning model; then all adversarial sample generation tasks are executed in sequence to generate adversarial samples corresponding to the adversarial sample generation algorithm; the technical problems of low integration efficiency of the current adversarial sample generation algorithm and poor task scheduling and management capabilities of adversarial sample generation are solved, which greatly facilitates the generation of adversarial samples, achieves the purpose of generating a large number of adversarial samples in a short time, and ensures the generation efficiency of adversarial samples.
[0012] In combination with the first aspect, in a first implementation of the first aspect, the adversarial sample generation method based on dynamic scheduling further includes:
[0013] According to the algorithm parameters of the adversarial sample generation algorithm, the algorithm information in the preset algorithm library is updated.
[0014] The adversarial sample generation method based on dynamic scheduling provided by an embodiment of the present invention updates the algorithm information in a preset algorithm library through the algorithm parameters of the adversarial sample generation algorithm, so that during the task execution process, the interface of the algorithm library is directly called to dynamically access the algorithm, thereby ensuring real-time update of the algorithm when the adversarial sample generation task is executed.
[0015] In combination with the first aspect, in a second implementation of the first aspect, scheduling the adversarial sample generation task according to a preset execution number of the adversarial sample generation task and a priority of each adversarial sample generation task, and determining a current adversarial sample generation task to be executed includes:
[0016] Determine whether the number of task executions is less than a preset threshold;
[0017] When the number of task executions is less than a preset threshold, executing the adversarial sample generation task, and updating the number of task executions until the number of task executions is not less than the preset threshold;
[0018] When the number of task executions is not less than a preset threshold, setting the task state of the adversarial sample generation task to a waiting state;
[0019] Obtain the adversarial sample generation task with the highest priority among the adversarial sample generation tasks whose task status is waiting;
[0020] The current adversarial sample generation task to be executed is determined as the adversarial sample generation task with the highest priority, and the priorities of the adversarial sample generation tasks in the waiting state are increased in sequence. When the adversarial sample generation task is monitored to be completed, the number of task executions is reduced, and the step of determining whether the number of task executions is less than a preset threshold is returned.
[0021] The adversarial sample generation method based on dynamic scheduling provided by the embodiment of the present invention realizes the adaptation of existing resources and ensures the maximum execution of the adversarial sample generation task without affecting the normal operation of other modules of the system, thereby improving the generation efficiency of adversarial samples.
[0022] In combination with the first aspect, in a third implementation of the first aspect, the encapsulation-based model and the scheduling algorithm sequentially execute the current adversarial sample generation task to generate the corresponding adversarial sample, including:
[0023] Utilizing the current scheduling algorithm and the encapsulated model, executing the current adversarial sample generation task, generating adversarial samples corresponding to the current original sample data, until the current adversarial sample generation algorithm completes the iterative solution of all the original sample data;
[0024] The current scheduling algorithm is determined as the next algorithm of the current scheduling algorithm, and the step of using the current scheduling algorithm and the encapsulated model to execute the current anti-sample generation task is returned until the current scheduling algorithm is the last scheduling algorithm.
[0025] The adversarial sample generation method based on dynamic scheduling provided by the embodiment of the present invention realizes the dynamic scheduling of the adversarial sample generation algorithm, and does not need to rematch the algorithm during each task execution, thereby ensuring work efficiency.
[0026] In combination with the first aspect, in a fourth implementation of the first aspect, the adversarial sample generation method based on dynamic scheduling further includes:
[0027] Get the original sample labels of the original sample data;
[0028] Input each adversarial sample into the encapsulated model to determine a predicted label of the adversarial sample;
[0029] An adversarial sample dataset is determined based on the original sample data, the original sample labels, the adversarial samples, and the predicted labels of the adversarial samples.
[0030] The adversarial sample generation method based on dynamic scheduling provided by the embodiment of the present invention realizes data management through the storage method of the adversarial sample data set to facilitate subsequent use, and can reproduce the generation process of the adversarial sample.
[0031] In combination with the fourth implementation of the first aspect, in the fifth implementation of the first aspect, the structure of the adversarial sample data set includes: data, models, labels, and prediction results.
[0032] The data includes: original sample data, an adversarial sample generation algorithm corresponding to an adversarial sample generation task, and a corresponding adversarial sample;
[0033] The model includes: a packaged model;
[0034] The labels include: original sample labels;
[0035] The prediction results include: the prediction results of the original sample and the prediction results of each adversarial sample.
[0036] According to a second aspect, an embodiment of the present invention provides an adversarial sample generation device based on dynamic scheduling, comprising:
[0037] A first processing module is used to obtain multiple original sample data and deep learning models to determine the corresponding adversarial sample generation task;
[0038] A second processing module, configured to match at least one corresponding adversarial sample generation algorithm in a preset algorithm library based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm;
[0039] A third processing module, configured to schedule the adversarial sample generation tasks according to a preset execution quantity of the adversarial sample generation tasks and a priority of each adversarial sample generation task, and determine a current adversarial sample generation task to be executed;
[0040] A fourth processing module is used to obtain the configuration parameters of the current adversarial sample generation task, schedule the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determine the scheduling algorithm;
[0041] The fifth processing module is used to encapsulate the deep learning model, and based on the encapsulated model and the scheduling algorithm, execute the current adversarial sample generation task in sequence to generate corresponding adversarial samples.
[0042] According to the third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the dynamic scheduling-based adversarial sample generation method described in the first aspect or any one of the embodiments of the first aspect by executing the computer instructions.
[0043] According to the fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the adversarial sample generation method based on dynamic scheduling described in the first aspect or any one embodiment of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 is a flowchart of a method for generating adversarial samples based on dynamic scheduling according to an embodiment of the present invention;
[0046] Figure 2 is a flowchart of a task of generating adversarial samples according to an embodiment of the present invention;
[0047] Figure 3 is a flowchart of performing adversarial sample generation tasks in batches according to an embodiment of the present invention;
[0048] Figure 4 is a schematic diagram of an adversarial sample dataset structure according to an embodiment of the present invention;
[0049] Figure 5 is a schematic diagram of an adversarial sample generation device based on dynamic scheduling according to an embodiment of the present invention;
[0050] Figure 6 is a schematic diagram of an adversarial sample generation system based on dynamic scheduling according to an embodiment of the present invention;
[0051] Figure 7 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0053] Deep learning is an important field of artificial intelligence and is widely used in computer vision and other fields, such as image recognition and face recognition. Its safety issues are increasingly attracting the attention of researchers. During a test of an autonomous driving car based on deep learning, a cyclist was hit while driving. The car was in autonomous driving mode at the time, and the system did not send any deceleration signal after encountering the pedestrian. Part of the cause of the accident was that the deep learning model was not robust enough. Therefore, the safety issues of deep learning systems are increasingly attracting the attention of researchers.
[0054] Adversarial samples can not only be used to detect security issues in deep learning, but also to reinforce deep learning models. In the process of training a model, if perturbed samples are added to the data set, a more robust model can be constructed, which can effectively defend against attacks from adversarial samples.
[0055] According to an embodiment of the present invention, an embodiment of an adversarial sample generation method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0056] In this embodiment, a method for generating adversarial samples is provided, which can be used in electronic devices such as computers, mobile phones, tablet computers, etc. Figure 1 is a flowchart of a method for generating adversarial samples according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0057] S11, obtain multiple original sample data and deep learning models to determine the corresponding adversarial sample generation task.
[0058] Among them, multiple original sample data and deep learning models uploaded by users are obtained, wherein the original sample data is the data used to generate adversarial samples, which can be data with known sample labels, such as samples for determining whether a given picture is a dog, the original sample data can be a series of pictures, the pictures can be dogs or other animals, the deep learning model is a network model composed of a deep learning architecture and network parameters, and is a deep learning model suitable for the task; according to the original sample data and the deep learning model, the corresponding adversarial sample generation task can be determined, wherein the number of adversarial sample generation tasks can be determined according to the number of corresponding adversarial samples that need to be generated. It should be noted that this embodiment is described by taking the sample data for determining whether the given data is a dog as an example. In actual applications, it can also be applied to other categories of judgments, such as obstacle recognition, face tracking, etc., and this embodiment is not limited to this. Among them, the original sample data can be generated by the original sample generator, or it can be determined by the user based on the sample data in the sample library.
[0059] S12, based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm, matching at least one corresponding adversarial sample generation algorithm in a preset algorithm library.
[0060] After the electronic device generates the adversarial sample generation task corresponding to the original sample data and the deep learning model in the above S11, it can determine the correspondence between each adversarial sample generation task and the adversarial sample generation algorithm, that is, after the adversarial sample generation task is determined (that is, after the original sample data and the deep learning architecture of the deep learning model are determined), at least one adversarial sample generation algorithm corresponding to each adversarial sample generation task can be obtained. For example, given the current original sample data, the deep learning model formed by the deep learning framework 1 and the current original sample data 1 determine that the current adversarial sample generation task is to identify the image of a dog as the target, and the adversarial sample generation algorithm can be used as two adversarial sample generation algorithms, fgsm and deepfool, to form a correspondence between the current adversarial sample generation task and the adversarial sample generation algorithm; then, based on the current adversarial sample generation task and the correspondence between the current adversarial sample generation task and the adversarial sample generation algorithm, at least one corresponding adversarial sample generation algorithm is matched in the preset algorithm library.
[0061] It should be noted that this embodiment uses the correspondence between the above-mentioned adversarial sample generation task and the adversarial sample generation algorithm as an example for explanation. In actual applications, one task may correspond to multiple algorithms, or one task value may correspond to one algorithm. This embodiment is not limited to this.
[0062] S13, scheduling the adversarial sample generation tasks according to the preset execution number of the adversarial sample generation tasks and the priority of each adversarial sample generation task, and determining the current adversarial sample generation task to be executed.
[0063] Based on system resources, the preset execution number of adversarial sample generation tasks is determined, and then the adversarial sample generation tasks are scheduled according to the preset execution number and the priority of each adversarial sample generation task, so as to realize dynamic scheduling of each adversarial sample generation task and determine the current adversarial sample generation task to be executed.
[0064] S14, obtaining the configuration parameters of the current adversarial sample generation task, scheduling the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determining the scheduling algorithm.
[0065] After the corresponding current adversarial sample generation task is determined, its corresponding configuration parameters can be obtained, where the configuration parameters include: the specific adversarial sample generation task identifier, the corresponding original sample data information called by the task, the number of algorithms required by the user, etc.; according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, the adversarial sample generation algorithm in the preset algorithm library is scheduled, and the scheduling algorithm is determined, where the scheduling algorithm is the relevant scheduling order and algorithm of the algorithms in the preset algorithm library that need to be used in the end.
[0066] S15, encapsulate the deep learning model, and based on the encapsulated model and the scheduling algorithm, execute the current adversarial sample generation task in sequence to generate the corresponding adversarial sample.
[0067] Generally speaking, the encapsulation of deep learning models can be done by obtaining the parameters of the algorithm's implementation functions after determining each adversarial sample generation algorithm, and determining the algorithm function using the parameters of the implementation function. The function to be implemented is determined based on the parameters. Since deep learning models may be trained based on different frameworks, the trained models have different structures. If the deep learning architecture of the deep learning model cannot implement the functions of the above algorithm, the corresponding target deep learning architecture is determined to ensure the versatility of the adversarial sample generation method. Any model uploaded by the user can be connected to generate adversarial samples through model encapsulation.
[0068] For example, the target deep learning architecture includes the tensorflow deep learning framework, and the deep learning architecture corresponding to the deep learning model is the keras deep learning framework. To encapsulate the above framework, you need to rewrite the function calls, obtain logical values, and obtain probability values before you can encapsulate the model into the access tool and determine the encapsulated model.
[0069] The general generation process of adversarial samples is to first obtain the calculation graph of the original deep learning model, then initialize the calculation graph, execute the calculation graph for the original sample data, and perform iterative solution. The algorithm initialization is used to parse the parameters of the adversarial sample generation algorithm; the calculation graph is used to generate the calculation graph, obtain the model label, and build the adversarial network. The encapsulated model and each scheduling algorithm are used to execute the current adversarial sample generation task in sequence to generate the corresponding adversarial sample until the current adversarial sample generation task to be executed determined by all scheduled adversarial sample generation tasks is completed. When an adversarial sample generation task starts to execute, the dynamic algorithm is loaded and the adversarial sample generation task is executed. The adversarial sample generation task also includes the task call parameter configuration and the algorithm parameters desired by the user.
[0070] The adversarial sample generation method based on dynamic scheduling provided by the embodiment of the present invention determines the corresponding adversarial sample generation task through the original sample data and the deep learning model. After determining the corresponding adversarial sample generation algorithm, the encapsulated model is determined by using the corresponding implementation function of the adversarial sample generation algorithm and the original uploaded deep learning model; then all adversarial sample generation tasks are executed in sequence to generate adversarial samples corresponding to the adversarial sample generation algorithm; the technical problems of low integration efficiency of the current adversarial sample generation algorithm and poor task scheduling and management capabilities of adversarial sample generation are solved, which greatly facilitates the generation of adversarial samples, achieves the purpose of generating a large number of adversarial samples in a short time, and ensures the generation efficiency of adversarial samples.
[0071] In this embodiment, a method for generating adversarial samples based on dynamic scheduling is provided. Figure 2 is a flowchart of a method for generating adversarial samples based on dynamic scheduling according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0072] S21, obtain multiple original sample data and deep learning models to determine the corresponding adversarial sample generation task.
[0073] For details, please see Figure 1 S11 of the illustrated embodiment will not be described in detail here.
[0074] S22, based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm, matching at least one corresponding adversarial sample generation algorithm in a preset algorithm library.
[0075] For details, please see Figure 1 S12 of the illustrated embodiment will not be described in detail here.
[0076] S23, scheduling the adversarial sample generation tasks according to the preset execution number of the adversarial sample generation tasks and the priority of each adversarial sample generation task, and determining the current adversarial sample generation task to be executed.
[0077] Specifically, as an optional implementation of this embodiment, the above S23 may include the following steps:
[0078] S231, determining whether the number of executed tasks is less than a preset threshold.
[0079] Determine whether the current system resources can support the execution of the new task, set a preset threshold according to actual needs, and determine whether the number of task executions is less than the preset threshold.
[0080] S232, when the number of task executions is less than a preset threshold, execute the adversarial sample generation task and update the number of task executions until the number of task executions is not less than the preset threshold.
[0081] When the number of task executions is less than the preset threshold, the adversarial sample generation task is executed, the task execution number is updated, and the task execution number is increased by 1 until the task execution number is not less than the preset threshold, and no new adversarial sample generation task is executed.
[0082] S233, when the number of task executions is not less than a preset threshold, setting the task state of the adversarial sample generation task to a waiting state.
[0083] When the number of task executions is not less than the preset threshold, it means that no new tasks can be executed at this time, and the task status of all adversarial sample generation tasks currently generated is set to the waiting state.
[0084] S234, obtaining the adversarial sample generation task with the highest priority among the adversarial sample generation tasks whose task status is the waiting state.
[0085] Among them, the priority of each adversarial sample generation task is set according to the actual task requirements, and the adversarial sample generation task with the highest priority is determined.
[0086] S235, determine the current adversarial sample generation task to be executed as the adversarial sample generation task with the highest priority, increase the priority of the adversarial sample generation tasks in the waiting state in turn, and when monitoring that the adversarial sample generation task is completed, reduce the number of task executions, and return to the step of obtaining the adversarial sample generation task with the highest priority among the adversarial sample generation tasks in the waiting state.
[0087] The task with the highest priority is determined as the current adversarial sample generation task to be executed, and the priorities of other waiting tasks are increased one level at a time. Once an adversarial sample generation task is completed, the number of tasks to be executed is reduced, and the current adversarial sample generation task is selected for execution until all waiting adversarial sample generation tasks are completed.
[0088] Since deep neural networks consume a lot of computing resources, there is an upper limit on the number of tasks that can be executed at the same time. Whenever there is a new task, the system will schedule the task. If there is no task running at this time, it will be executed directly, otherwise the task will be placed in the task queue and set to wait. When a task is completed, the task with the highest priority is taken out for execution; until the priority of the current adversarial sample generation task is the highest, it enters the task execution state, and the current adversarial sample generation algorithm completes the analysis of all adversarial sample generation tasks.
[0089] S24, obtaining the configuration parameters of the current adversarial sample generation task, scheduling the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determining the scheduling algorithm.
[0090] For details, please see Figure 1 S14 of the illustrated embodiment will not be described in detail here.
[0091] S25, encapsulate the deep learning model, and based on the encapsulated model and the scheduling algorithm, execute the current adversarial sample generation task in sequence to generate the corresponding adversarial sample.
[0092] For details, please see Figure 1 S15 of the illustrated embodiment will not be described in detail here.
[0093] In this embodiment, a method for generating adversarial samples based on dynamic scheduling is provided, and the process includes the following steps:
[0094] S31, obtaining multiple original sample data and deep learning models to determine the corresponding adversarial sample generation task.
[0095] For details, please see Figure 1 S11 of the illustrated embodiment will not be described in detail here.
[0096] S32, based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm, matching at least one corresponding adversarial sample generation algorithm in a preset algorithm library.
[0097] For details, please see Figure 1 S12 of the illustrated embodiment will not be described in detail here.
[0098] S33, scheduling the adversarial sample generation tasks according to the preset execution number of the adversarial sample generation tasks and the priority of each adversarial sample generation task, and determining the current adversarial sample generation task to be executed.
[0099] For details, please see Figure 1 S13 of the illustrated embodiment will not be described in detail here.
[0100] S34, obtaining the configuration parameters of the current adversarial sample generation task, scheduling the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determining the scheduling algorithm.
[0101] For details, please see Figure 1 S14 of the illustrated embodiment will not be described in detail here.
[0102] S35, encapsulate the deep learning model, and based on the encapsulated model and the scheduling algorithm, execute the current adversarial sample generation task in sequence to generate the corresponding adversarial sample.
[0103] Specifically, as an optional implementation of this embodiment, the above S35 may include the following steps:
[0104] S351, using the current scheduling algorithm and the encapsulated model, execute the current adversarial sample generation task to generate adversarial samples corresponding to the current original sample data until the current adversarial sample generation algorithm completes the iterative solution of all the original sample data.
[0105] S352, determining the current scheduling algorithm as the next algorithm of the current scheduling algorithm, and returning to the step of using the current scheduling algorithm and the encapsulated model to execute the current anti-sample generation task until the current scheduling algorithm is the last scheduling algorithm.
[0106] And because there are many algorithms for generating adversarial samples, new algorithms are constantly emerging. Therefore, the algorithms in the preset algorithm library can be dynamically configured through the relevant parameters of the new algorithm. The dynamic configuration of the algorithm library here includes algorithm updates, upgrades, additions, deletions, etc. It can be real-time dynamic configuration during the execution of the adversarial sample generation task, or it can be any time period before and after the task execution.
[0107] For different adversarial sample generation algorithms, adversarial samples are generated in batches according to the algorithms and the original sample data. Assume that there are I adversarial sample generation algorithms, and each algorithm has K batches of original sample data, such as Figure 3 As shown, it can be explained by the following steps:
[0108] (1) I adversarial sample generation algorithms are matched from the preset algorithm library of adversarial sample generation algorithms, let i=1;
[0109] (2) Select the i-th (1≤i≤I) adversarial sample generation algorithm, where I is the number of all adversarial samples determined by the user to be generated.
[0110] (3) Based on the obtained original deep learning model and K batches of original samples, initialize the computational graph of the original deep learning model (original model), and set k = 1.
[0111] (4) Input the kth batch (1≤k≤K) of original sample data and the encapsulated model uploaded by the user, execute the adversarial sample generation algorithm calculation graph, iteratively solve, and generate the kth batch of adversarial samples.
[0112] (5) Update k, set k = k + 1, if k ≤ K, return to input the kth batch of original sample data until the iterative solution of all K batches of original sample data is completed.
[0113] (6) After executing all K batches of original samples in this round, update i, set i=i+1. If i≤I, return to step (2) and continue to execute the next adversarial sample generation algorithm; otherwise, go to step (7);
[0114] (7) The task of batch generating adversarial samples is completed.
[0115] The above-mentioned adversarial sample generation method based on dynamic scheduling can also update the algorithm information in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm, wherein after the original sample data and the adversarial sample generation algorithm are determined, the algorithm parameters of the applicable adversarial sample generation algorithm have been determined.
[0116] In this embodiment, a method for generating adversarial samples based on dynamic scheduling is provided, and the process includes the following steps:
[0117] S41, obtaining multiple original sample data and deep learning models to determine the corresponding adversarial sample generation task.
[0118] For details, please see Figure 1 S11 of the illustrated embodiment will not be described in detail here.
[0119] S42, based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm, matching at least one corresponding adversarial sample generation algorithm in a preset algorithm library.
[0120] For details, please see Figure 1 S12 of the illustrated embodiment will not be described in detail here.
[0121] S43, scheduling the adversarial sample generation tasks according to the preset execution quantity of the adversarial sample generation tasks and the priority of each adversarial sample generation task, and determining the current adversarial sample generation task to be executed.
[0122] For details, please see Figure 1 S13 of the illustrated embodiment will not be described in detail here.
[0123] S44, obtaining the configuration parameters of the current adversarial sample generation task, scheduling the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determining the scheduling algorithm.
[0124] As an optional implementation of this embodiment, the above S44 may include the following steps:
[0125] S45, encapsulate the deep learning model, and based on the encapsulated model and the scheduling algorithm, execute the current adversarial sample generation task in sequence to generate the corresponding adversarial sample.
[0126] Specifically, the above S45 also includes:
[0127] (1) Obtain the original sample labels of the original sample data.
[0128] Obtain the original sample labels of the original sample data, where the original sample data may be input by the user or generated by the original sample generator, and the original sample labels may be known labels or labels obtained after prediction by the original network model.
[0129] (2) Input each adversarial sample into the encapsulated model and determine the predicted label of the adversarial sample.
[0130] (3) Determine the adversarial sample dataset based on the original sample data, original sample labels, adversarial samples, and predicted labels of adversarial samples.
[0131] The ultimate goal of generating adversarial samples is to generate data sets. In order to generate adversarial sample data sets, the generated adversarial sample data needs to be fed into the deep learning model as input data. The output model integrates the original sample data, adversarial sample data, original sample labels, and labels predicted for adversarial samples into adversarial sample data sets. Data management can be achieved, where data management is mainly used for data content, labels, organizational forms, etc. This facilitates the generation of adversarial samples and improves work efficiency.
[0132] The structure of the adversarial sample dataset includes: data, model, label and prediction results. The data includes: original sample data, adversarial sample generation algorithm corresponding to the adversarial sample generation task and corresponding adversarial sample; the model includes: encapsulated model; the label includes: original sample label; the prediction results include: prediction results of original samples and prediction results of each adversarial sample.
[0133] The adversarial sample dataset can be stored in Figure 4 The structure of the adversarial sample dataset shown is stored. Figure 4 The paper shows an adversarial sample dataset generated by two different algorithms for a given sample, which contains the original sample (original sample data) and the adversarial samples generated by the two algorithms, the original sample 1 label, the model's prediction results for the original sample and the adversarial sample, and the encapsulated model (encapsulated model). The generation process of adversarial samples can be reproduced through the data management mode.
[0134] In this embodiment, a device for generating adversarial samples based on dynamic scheduling is also provided to implement the above-mentioned embodiments and preferred implementation modes, which have been described and will not be repeated here. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0135] This embodiment provides an adversarial sample generation device, such as Figure 5 As shown, it includes: a first processing module 1, which is used to obtain multiple original sample data and deep learning models to determine the corresponding adversarial sample generation task; a second processing module 2, which is used to match at least one corresponding adversarial sample generation algorithm in a preset algorithm library based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm; a third processing module 3, which is used to schedule the adversarial sample generation task according to the preset execution number of the adversarial sample generation task and the priority of each adversarial sample generation task, and determine the current adversarial sample generation task to be executed; a fourth processing module 4, which is used to obtain the configuration parameters of the current adversarial sample generation task, and schedule the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determine the scheduling algorithm; a fifth processing module 5, which is used to encapsulate the deep learning model, and based on the encapsulated model and the scheduling algorithm, execute the current adversarial sample generation task in sequence to generate the corresponding adversarial sample.
[0136] The embodiment of the present invention also provides an adversarial sample generation system based on dynamic scheduling, such as Figure 6As shown in the figure, the whole system is implemented based on B / S architecture and is divided into three parts: front-end, back-end and adversarial sample database. The front-end part uses the front-end development framework to provide users with a visual interactive interface, and users can use the relevant functions of the system through the browser. The back-end is based on the Web application framework and implements a server that provides a network transmission interface for the front-end, mainly including data management, task management, algorithm management, dynamic scheduling and adversarial sample algorithm library (preset algorithm library). The data management module is mainly used for the management of data content, labels and organizational forms. The algorithm management module is used to configure different adversarial sample generation algorithms. The task management module is responsible for the priority management of each adversarial sample generation task. The dynamic scheduling module is used to realize the dynamic scheduling of adversarial sample generation tasks and the dynamic scheduling of the adversarial sample algorithm library. The adversarial sample algorithm library stores the execution scripts for implementing each adversarial sample algorithm. The adversarial sample database organizes, stores and manages the relevant data in the adversarial sample generation system according to a certain data structure.
[0137] The dynamic scheduling-based adversarial sample generation device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0138] The further functional description of each of the above modules is the same as that of the above corresponding embodiments and will not be repeated here.
[0139] The embodiment of the present invention also provides an electronic device having the above Figure 5 The adversarial sample generation device based on dynamic scheduling is shown.
[0140] See also Figure 7 , Figure 7 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present invention, such as Figure 7As shown, the electronic device may include: at least one processor 601, such as a CPU (Central Processing Unit), at least one communication interface 603, a memory 604, and at least one communication bus 602. The communication bus 602 is used to realize the connection and communication between these components. The communication interface 603 may include a display screen (Display), a keyboard (Keyboard), and the optional communication interface 603 may also include a standard wired interface and a wireless interface. The memory 604 may be a high-speed RAM memory (Random Access Memory, volatile random access memory) or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 604 may optionally be at least one storage device located away from the aforementioned processor 601. The processor 601 may be combined with Figure 5 In the described device, the memory 604 stores an application program, and the processor 601 calls the program code stored in the memory 604 to execute any of the above method steps.
[0141] The communication bus 602 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The communication bus 602 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0142] Among them, the memory 604 may include a volatile memory (English: volatile memory), such as a random access memory (English: random-access memory, abbreviated: RAM); the memory may also include a non-volatile memory (English: non-volatile memory), such as a flash memory (English: flash memory), a hard disk drive (English: hard disk drive, abbreviated: HDD) or a solid-state drive (English: solid-state drive, abbreviated: SSD); the memory 604 may also include a combination of the above types of memory.
[0143] The processor 601 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP.
[0144] The processor 601 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0145] Optionally, the memory 604 is also used to store program instructions. The processor 601 can call the program instructions to implement the present application Figure 1 and 2 The adversarial sample generation method based on dynamic scheduling shown in the embodiment.
[0146] The embodiment of the present invention also provides a non-transitory computer storage medium, which stores computer executable instructions, which can execute the adversarial sample generation method in any of the above method embodiments, or execute the model training method in any of the above method embodiments. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memory.
[0147] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for generating adversarial samples based on dynamic scheduling, characterized in that: include: Obtain multiple original sample data and deep learning models to determine the corresponding adversarial sample generation tasks; Based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm, matching at least one corresponding adversarial sample generation algorithm in a preset algorithm library; Scheduling the adversarial sample generation tasks according to the preset execution quantity of the adversarial sample generation tasks and the priority of each adversarial sample generation task, and determining the current adversarial sample generation task to be executed; Obtain the configuration parameters of the current adversarial sample generation task, schedule the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determine the scheduling algorithm; Encapsulating the deep learning model, and based on the encapsulated model and the scheduling algorithm, sequentially executing the current adversarial sample generation task to generate corresponding adversarial samples; The step of scheduling the adversarial sample generation tasks according to the preset execution quantity of the adversarial sample generation tasks and the priority of each adversarial sample generation task to determine the current adversarial sample generation task to be executed includes: Determine whether the number of task executions is less than a preset threshold; When the number of task executions is less than a preset threshold, executing the adversarial sample generation task, and updating the number of task executions until the number of task executions is not less than the preset threshold; When the number of task executions is not less than a preset threshold, setting the task state of the adversarial sample generation task to a waiting state; Obtain the adversarial sample generation task with the highest priority among the adversarial sample generation tasks whose task status is waiting; The current adversarial sample generation task to be executed is determined as the adversarial sample generation task with the highest priority, and the priorities of the adversarial sample generation tasks in the waiting state are increased in sequence. When the adversarial sample generation task is monitored to be completed, the number of task executions is reduced, and the step of determining whether the number of task executions is less than a preset threshold is returned.
2. The method according to claim 1, characterized in that Also includes: According to the algorithm parameters of the adversarial sample generation algorithm, the algorithm information in the preset algorithm library is updated.
3. The method according to claim 1, characterized in that The encapsulated model and the scheduling algorithm sequentially execute the current adversarial sample generation task to generate corresponding adversarial samples, including: Utilizing the current scheduling algorithm and the encapsulated model, executing the current adversarial sample generation task, generating adversarial samples corresponding to the current original sample data, until the current adversarial sample generation algorithm completes the iterative solution of all the original sample data; The current scheduling algorithm is determined as the next algorithm of the current scheduling algorithm, and the step of using the current scheduling algorithm and the encapsulated model to execute the current anti-sample generation task is returned until the current scheduling algorithm is the last scheduling algorithm.
4. The method according to claim 1, characterized in that: Also includes: Get the original sample labels of the original sample data; Input each adversarial sample into the encapsulated model to determine a predicted label of the adversarial sample; An adversarial sample dataset is determined based on the original sample data, the original sample labels, the adversarial samples, and the predicted labels of the adversarial samples.
5. The method according to claim 4, characterized in that The structure of the adversarial sample dataset includes: data, models, labels, and prediction results. The data includes: original sample data, an adversarial sample generation algorithm corresponding to an adversarial sample generation task, and a corresponding adversarial sample; The model includes: a packaged model; The labels include: original sample labels; The prediction results include: the prediction results of the original sample and the prediction results of each adversarial sample.
6. A device for generating adversarial samples based on dynamic scheduling, characterized in that: include: A first processing module is used to obtain multiple original sample data and deep learning models to determine the corresponding adversarial sample generation task; A second processing module, configured to match at least one corresponding adversarial sample generation algorithm in a preset algorithm library based on the adversarial sample generation task and the correspondence between the adversarial sample generation task and the adversarial sample generation algorithm; A third processing module, configured to schedule the adversarial sample generation tasks according to a preset execution quantity of the adversarial sample generation tasks and a priority of each adversarial sample generation task, and determine a current adversarial sample generation task to be executed; A fourth processing module is used to obtain the configuration parameters of the current adversarial sample generation task, schedule the adversarial sample generation algorithm in the preset algorithm library according to the algorithm parameters of the adversarial sample generation algorithm and the configuration parameters of the current adversarial sample generation task, and determine the scheduling algorithm; A fifth processing module, used to encapsulate the deep learning model, and based on the encapsulated model and the scheduling algorithm, sequentially execute the current adversarial sample generation task to generate corresponding adversarial samples; The step of scheduling the adversarial sample generation tasks according to the preset execution quantity of the adversarial sample generation tasks and the priority of each adversarial sample generation task to determine the current adversarial sample generation task to be executed includes: Determine whether the number of task executions is less than a preset threshold; When the number of task executions is less than a preset threshold, executing the adversarial sample generation task, and updating the number of task executions until the number of task executions is not less than the preset threshold; When the number of task executions is not less than a preset threshold, setting the task state of the adversarial sample generation task to a waiting state; Obtain the adversarial sample generation task with the highest priority among the adversarial sample generation tasks whose task status is waiting; The current adversarial sample generation task to be executed is determined as the adversarial sample generation task with the highest priority, and the priorities of the adversarial sample generation tasks in the waiting state are increased in sequence. When the adversarial sample generation task is monitored to be completed, the number of task executions is reduced, and the step of determining whether the number of task executions is less than a preset threshold is returned.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 5 is implemented.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method according to any one of claims 1 to 5 by executing the computer instructions.
Citation Information
Patent Citations
Method and device for generating adversarial sample
CN109036389A
Large-batch adversarial sample generation method and system
CN111275123A
