Confrontation data detection method and device, electronic equipment, storage medium and computer program product
Through multiple trainings and feature extraction of the adversarial sample detection model, and gradient updates of group category loss and family category loss, a preset detection model is generated, which solves the problem of low accuracy of adversarial sample detection by the neural network model in open set data, and achieves Efficient detection of open set data.
Patent Information
- Application Number
- CN202410233259.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-29
- Publication Date
- 2024-10-18
AI Technical Summary
In the existing technology, neural network models cannot effectively detect adversarial samples when facing open set data, resulting in low accuracy in adversarial sample detection.
By obtaining the data set to be detected, a preset detection model is used. The model trains the initial detection model based on training samples and sample labels, generates clean samples and adversarial sample groups, and performs operations through the initial feature extraction model, group classification model and family classification model. After multiple trainings, an intermediate detection model is generated, and the preset detection model is finally determined to improve the accuracy of adversarial sample detection.
It significantly improves the accuracy of adversarial sample detection in the face of open set data, can effectively detect adversarial data in open set data sets, and is more generalizable than a single distribution data set detection solution.
Smart Images

Figure CN118797337A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an adversarial data detection method, device, electronic device, storage medium and computer program product. Background Art
[0002] In the related art, neural network models are vulnerable to adversarial samples. An effective defense method is adversarial sample pre-check, that is, to determine whether the sample is an adversarial sample before it is input into the network. If it is an adversarial sample, the network rejects its input. Common adversarial sample detection methods include Bayesian uncertainty-based, feature compression-based, and input reconstruction-based. However, adversarial samples in the related art are all pre-checked for adversarial samples on a single distributed data set. In actual applications, the model faces open set data and cannot effectively detect adversarial samples generated by open set data, resulting in low accuracy in adversarial sample detection for open set data. Summary of the invention
[0003] The embodiments of the present application provide an adversarial data detection method, device, electronic device, storage medium, and computer program product, which can improve the accuracy of adversarial sample detection for open set data.
[0004] The technical solution of this application is implemented as follows:
[0005] The present application provides a method for detecting adversarial data, including:
[0006] Get the data set to be tested;
[0007] Inputting the to-be-detected data set into a preset detection model to determine adversarial data in the to-be-detected data set;
[0008] The preset detection model is obtained by training the initial detection model based on the training samples and the corresponding sample labels; the sample labels are used to characterize the family and group to which the training samples belong.
[0009] In the above scheme, the training samples include: clean samples and adversarial samples; before inputting the to-be-detected data set into a preset detection model and determining the adversarial data in the to-be-detected data set, the method further includes:
[0010] Generate an adversarial sample group based on the acquired clean sample group through at least one attack method; wherein the clean sample group includes multiple clean sample families, each of which includes multiple clean samples; the adversarial sample group includes multiple adversarial sample families, each of which includes multiple adversarial samples; each clean sample corresponds to at least one adversarial sample generated based on at least one attack method;
[0011] A corresponding clean sample label is formed for each of the clean samples, and a corresponding adversarial sample label is formed for each of the adversarial samples; wherein the clean sample label includes a corresponding clean sample identifier, and the clean sample family and the clean sample group to which the clean sample belongs; the adversarial sample label includes a corresponding adversarial sample identifier, and the adversarial sample family and the adversarial sample group to which the adversarial sample belongs;
[0012] The initial detection model is trained multiple times based on multiple sets of training data packets, and an intermediate detection model obtained after each training and an evaluation index corresponding to each intermediate detection model are determined; wherein the training data packet includes: the clean sample and the corresponding clean sample label, at least one adversarial sample corresponding to the clean sample, and the adversarial sample label corresponding to at least one adversarial sample;
[0013] The preset detection model is determined based on each of the evaluation indicators.
[0014] In the above scheme, the method of generating an adversarial sample group based on the acquired clean sample group by at least one attack method includes:
[0015] Using each of the attack methods to process each of the clean samples, to obtain the adversarial samples corresponding to each of the clean samples for at least one of the attack methods;
[0016] The adversarial samples corresponding to the same attack method are combined to obtain the adversarial sample family, and each adversarial sample family is combined to obtain the adversarial sample group.
[0017] In the above scheme, the initial detection model includes: an initial feature extraction model, an initial group classification model and an initial family classification model; the initial detection model is trained multiple times based on multiple sets of training data packets, and the intermediate detection model obtained after each training is determined, and the evaluation index corresponding to each intermediate detection model includes:
[0018] Extracting, using an initial feature extraction model, a first feature of the clean sample and a first feature corresponding to the clean sample label, and a second feature of at least one of the adversarial samples and a second feature corresponding to the adversarial sample label;
[0019] Processing the first feature and at least one of the second features based on the initial group classification model to determine a group classification loss;
[0020] Processing the first feature and at least one of the second features based on the initial family classification model to determine a family classification loss;
[0021] Performing gradient update on the initial detection model based on the group category loss and the family category loss to obtain a first intermediate detection model and the evaluation index corresponding to the first intermediate detection model;
[0022] The initial detection model is trained using the next set of the training data packets until a predetermined number of training times is reached, thereby obtaining N intermediate detection models and the evaluation index corresponding to each intermediate detection model; wherein N is an integer greater than 0.
[0023] In the above solution, the processing of the first feature and at least one of the second features based on the initial group classification model to determine the group classification loss includes:
[0024] Processing the first feature and at least one of the second features based on the initial group classification model to determine a contrast loss and a classification loss;
[0025] The group class loss is determined based on the contrastive loss and the classification loss.
[0026] In the above scheme, the gradient updating of the initial detection model based on the group category loss and the family category loss to obtain the first intermediate detection model and the evaluation index corresponding to the first intermediate detection model includes:
[0027] Performing gradient update on the initial detection model based on the sum of the group category loss and the family category loss to obtain the first intermediate detection model;
[0028] Using multiple test samples to input the first intermediate detection model, determining a prediction label corresponding to each of the test samples; wherein the multiple test samples belong to the clean sample group and the adversarial sample group;
[0029] Based on the true label and the predicted label of each of the test samples, the evaluation index corresponding to the first intermediate detection model is determined.
[0030] In the above scheme, the output of the family classification model in the preset detection model includes: a probability output corresponding to each of the clean sample families and a probability output of the first virtual other class; wherein the probability output of the first virtual other class is used to characterize the probability that the clean sample label does not belong to the clean sample group;
[0031] The output of the family classification model in the preset detection model also includes: a probability output corresponding to each of the adversarial sample families and a probability output of a second virtual other class; wherein the probability output of the second virtual other class is used to characterize the probability that the adversarial sample label does not belong to the adversarial sample group.
[0032] In the above solution, the step of inputting the to-be-detected data set into a preset detection model to determine adversarial data in the to-be-detected data set includes:
[0033] Input each to-be-detected data in the to-be-detected data set into the preset detection model, and obtain the group probability information output by the group classification model in the preset detection model, as well as the probability information of the first virtual other class and the probability information of the second virtual other class output by the family classification model in the preset detection model;
[0034] Determine the group detection result to which the data to be detected belongs based on the group probability information;
[0035] Determine the adversarial data detection result of the data to be detected based on the group detection result combined with the probability information of the first virtual other class or the probability information of the second virtual other class;
[0036] The adversarial data is determined in the to-be-detected data set based on each of the adversarial data detection results.
[0037] In the above scheme, determining the adversarial data detection result of the data to be detected based on the group detection result combined with the probability information of the first virtual other class or the probability information of the second virtual other class includes one of the following:
[0038] If the group detection result indicates that the data to be detected belongs to the clean sample group, and the probability information of the first virtual other class is less than a first threshold, determining that the data to be detected is the adversarial data detection result of clean data;
[0039] If the group detection result indicates that the data to be detected belongs to an adversarial sample group, and the probability information of the second virtual other class is less than a second threshold, then determining the adversarial data detection result that the data to be detected is adversarial data.
[0040] The present application also provides a countermeasure data detection device, including:
[0041] A data acquisition unit, used to acquire a data set to be detected;
[0042] A determination unit, configured to input the to-be-detected data set into a preset detection model, and determine adversarial data in the to-be-detected data set;
[0043] The preset detection model is obtained by training the initial detection model based on the training samples and the corresponding sample labels; the sample labels are used to characterize the family and group to which the training samples belong.
[0044] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the steps in the above method when executing the computer program.
[0045] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method are implemented.
[0046] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps in the above method when executed by a processor.
[0047] In an embodiment of the present application, a data set to be detected is obtained; the data set to be detected is input into a preset detection model to determine adversarial data in the data set to be detected; wherein the preset detection model is obtained by training an initial detection model based on training samples and corresponding sample labels; the sample labels are used to characterize the families and groups to which the training samples belong. Since the preset detection model in the embodiment of the present application has learned the characteristics of a large number of training samples and the families and groups to which the training samples belong, when facing an open set data set, effective detection can be performed on adversarial data formed by data of each class in each group of the open set data set. Compared with the scheme of detecting adversarial samples for a single distributed data set in the related art, the accuracy of adversarial sample detection facing open set data is greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 An optional flowchart of the adversarial data detection method provided in an embodiment of the present application;
[0049] Figure 2 An optional effect diagram of the adversarial data detection method provided in an embodiment of the present application;
[0050] Figure 3 An optional flowchart of the adversarial data detection method provided in an embodiment of the present application;
[0051] Figure 4 An optional effect diagram of the adversarial data detection method provided in an embodiment of the present application;
[0052] Figure 5 An optional effect diagram of the adversarial data detection method provided in an embodiment of the present application;
[0053] Figure 6 An optional flowchart of the adversarial data detection method provided in an embodiment of the present application;
[0054] Figure 7An optional flowchart of the adversarial data detection method provided in an embodiment of the present application;
[0055] Figure 8 An optional effect diagram of the adversarial data detection method provided in an embodiment of the present application;
[0056] Fig. 9 An optional flowchart of the adversarial data detection method provided in an embodiment of the present application;
[0057] Fig.10 An optional flowchart of the adversarial data detection method provided in an embodiment of the present application;
[0058] Fig.11 An optional flowchart of the adversarial data detection method provided in an embodiment of the present application;
[0059] Fig.12 A schematic diagram of the structure of the adversarial data detection device provided in the embodiment of the present application Figure 1 ;
[0060] Fig.13 A schematic diagram of the structure of the adversarial data detection device provided in the embodiment of the present application Figure 2 ;
[0061] Fig.14 A hardware entity schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0063] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0064] If similar descriptions of "first / second" appear in the application documents, the following instructions are added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0065] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0066] Neural networks are vulnerable to adversarial samples. An effective defense method is adversarial sample pre-detection, that is, judging whether the sample is an adversarial sample before it is input into the network. If it is an adversarial sample, the network rejects its input. Common adversarial sample detection methods include adversarial sample detection based on Bayesian uncertainty, adversarial sample detection based on feature compression, and adversarial sample detection based on input reconstruction.
[0067] 1. Adversarial sample detection based on Bayesian uncertainty.
[0068] Bayesian neural networks have the characteristics of describing sample uncertainty, and can use variational reasoning and Monte Carlo sampling methods to optimize network parameters. The uncertainty generated by the Bayesian network can effectively distinguish adversarial samples from clean samples. Specifically, firstly, a certain prior distribution of the Bayesian network parameters is given, and then the network parameters are continuously fitted to this distribution through variational reasoning. During forward reasoning, the network parameters are obtained by the Monte Carlo sampling method T random data and their mean is calculated. There is no unique way to generate uncertainty.
[0069] 2. Adversarial sample detection based on feature compression.
[0070] Feature compression refers to the preprocessing of input images through methods such as color bit depth and spatial smoothing. The image after feature compression is not much different from the original image and cannot be detected by the human eye. Based on this prior, the original image and the feature compressed image are respectively input into the Deep Neural Networks (DNN) to obtain two feature vectors. The adversarial samples are identified by comparing the difference between the two feature vectors. It is believed that the feature vector generated by the adversarial sample after feature compression will be very different from the feature vector generated by the adversarial sample. By setting a suitable threshold, the adversarial sample and the clean sample can be distinguished.
[0071] 3. Adversarial sample detection based on input reconstruction.
[0072] The main idea of the reconstruction is encoder-decoder, which uses encoder to encode the input data and then decodes the encoded data. Figure 1 After training the encoder and decoder, the reconstruction error is used to determine whether the input is an adversarial sample. The reconstruction error is as follows: the reconstruction error of the clean sample will be lower than a certain threshold, and vice versa, the reconstruction error of the adversarial sample will be higher than this threshold.
[0073] In related technologies, adversarial sample pre-checks are performed on a single distributed data set. In actual applications, the model faces open data sets and cannot effectively detect adversarial samples generated by these data sets. In addition, adversarial samples generated by a single attack method are used during training. This training method has a poor detection effect on adversarial samples generated by other attack methods.
[0074] This application embodiment provides a method for detecting adversarial data. Figure 2 , is an optional flow chart of the adversarial data detection method provided in the embodiment of the present application, which is combined with Figure 2 The steps shown are explained.
[0075] S101: Obtain a data set to be detected.
[0076] In the embodiment of the present application, the adversarial data detection device obtains a data set to be detected, wherein the data set to be detected may be an open data set, and the data set to be detected includes a plurality of data to be detected.
[0077] The data set to be detected may include image data of multiple objects of different types.
[0078] The adversarial data detection device may be a terminal or a server having a corresponding image processing function.
[0079] S102. Input the data set to be detected into a preset detection model to determine the adversarial data in the data set to be detected; wherein the preset detection model is obtained by training an initial detection model based on training samples and corresponding sample labels; and the sample labels are used to characterize the family and group to which the training samples belong.
[0080] In the embodiment of the present application, the adversarial data detection device inputs multiple data to be detected in the data set to be detected into a preset detection model to obtain group probability information and family probability information for each data to be detected. Based on the group probability information and family probability information corresponding to each data to be detected, it is determined whether it is adversarial data.
[0081] The preset detection model is obtained by training the initial detection model based on the training samples and the corresponding sample labels; the sample labels are used to characterize the families and groups to which the training samples belong. In the training process for the initial detection model, the training samples and the labels corresponding to the training samples can be input into the initial detection model to obtain an intermediate detection model and the evaluation indicators corresponding to the intermediate detection model. After multiple trainings, the preset detection model is determined based on the optimal evaluation indicators.
[0082] In an embodiment of the present application, a data set to be detected is obtained; the data set to be detected is input into a preset detection model to determine adversarial data in the data set to be detected; wherein the preset detection model is obtained by training an initial detection model based on training samples and corresponding sample labels; the sample labels are used to characterize the families and groups to which the training samples belong. Since the preset detection model in the embodiment of the present application has learned the characteristics of a large number of training samples and the families and groups to which the training samples belong, when facing an open set data set, effective detection can be performed on the adversarial data formed by the data of each family in each group of the open set data set. Compared with the scheme of detecting adversarial samples for a single distributed data set in the related art, the accuracy of adversarial sample detection facing open set data is greatly improved.
[0083] See also Figure 3 , is an optional flowchart of the adversarial data detection method provided in an embodiment of the present application, Figure 2 The process before S102 shown may also include S201 to S204, which will be explained in conjunction with the steps in the figure.
[0084] S201. Generate an adversarial sample group based on the acquired clean sample group through at least one attack method; wherein the clean sample group includes multiple clean sample families, and each of the clean sample families includes multiple clean samples; the adversarial sample group includes multiple adversarial sample families, and each of the adversarial sample families includes multiple adversarial samples.
[0085] In an embodiment of the present application, an anti-data detection device obtains a clean sample group. The clean sample group includes multiple clean sample families, and each of the clean sample families includes multiple clean samples. Clean sample data types include animals, faces, clothing, vehicles, invoices, etc. For each clean sample, at least one corresponding adversarial sample is formed by at least one attack method, and the formed adversarial samples are classified and combined according to the attack methods to which they belong to obtain an adversarial sample group. The adversarial sample group includes multiple adversarial sample families, and each of the adversarial sample families includes multiple adversarial samples. Each of the clean samples corresponds to at least one adversarial sample generated based on at least one of the attack methods.
[0086] Exemplary, combined Figure 4 The adversarial data detection device obtains a clean sample group, wherein the clean sample group includes clean sample family 1, clean sample family 2, and clean sample family 3. For each clean sample in clean sample family 1, clean sample family 2, and clean sample family 3, at least one corresponding adversarial sample is generated by at least one attack method. The adversarial samples corresponding to the same attack method are classified to form adversarial sample family 1, adversarial sample family 2, and adversarial sample family 3. The adversarial sample family 1, adversarial sample family 2, and adversarial sample family 3 are combined to obtain an adversarial sample group.
[0087] Among them, clean samples and adversarial samples are data with different distributions. The types of clean sample data include animals, faces, clothing, vehicles, invoices, etc. Here, it is mainly used to simulate the open set data that needs to be faced in reality. The adversarial samples are generated by clean samples. The categories in the clean sample group are types of various distributed data (faces, clothing, etc.), and the categories in the adversarial sample group are types of attacks. The organization form of data is different from the commonly used <data, category label> form. It adopts the hierarchical multi-label form of <data, [family, group]>, combined with Figure 5 , the family belongs to the corresponding group (family 1 and family 2 belong to the corresponding clean sample group), one type of data is a family, all clean sample families constitute the clean sample group, and all adversarial sample families constitute the adversarial sample group. In addition, the other family is set in the clean sample and adversarial sample groups respectively, indicating the probability that the sample belongs to this group, which is used to further determine the sample category.
[0088] S202: forming a corresponding clean sample label for each of the clean samples, and forming a corresponding adversarial sample label for each of the adversarial samples.
[0089] In the embodiment of the present application, a corresponding clean sample label is formed based on the clean sample identifier of each clean sample and the clean sample family and clean sample group to which it belongs. A corresponding adversarial sample label is formed based on the adversarial sample identifier of each adversarial sample and the adversarial sample family and adversarial sample group to which it belongs.
[0090] The clean sample label includes the corresponding clean sample identifier, and the clean sample family and the clean sample group to which the clean sample belongs; the adversarial sample label includes the corresponding adversarial sample identifier, and the adversarial sample family and the adversarial sample group to which the adversarial sample belongs.
[0091] S203, training the initial detection model multiple times based on multiple groups of training data packets, determining an intermediate detection model obtained after each training, and an evaluation index corresponding to each intermediate detection model.
[0092] In an embodiment of the present application, each of the training data packets includes: the clean sample and the corresponding clean sample label, at least one adversarial sample corresponding to the clean sample, and the adversarial sample label corresponding to at least one adversarial sample. Multiple training data packets can be input into the initial detection model to obtain the losses corresponding to the multiple training data packets, and the initial detection model can be updated by the loss gradient to determine the intermediate detection model obtained after each training. Then, the test data is input into the intermediate detection model, and the evaluation index corresponding to each intermediate detection model is determined based on the output of the intermediate detection model.
[0093] Exemplarily, in the training process for the initial detection model, all categories (families) in the training samples are divided into two groups, each of which has an other family. An input sample belongs to both a group and a family. First, the input data is a positive and negative sample pair, that is, a clean sample and an adversarial sample pair. The adversarial sample is generated by the attack method for the corresponding clean sample. The group to which the sample belongs is determined by the group loss function, and then the family of the sample is determined by the family loss function. At the same time, it is further determined whether the sample belongs to this family group based on the other family in the group.
[0094] S204: Determine the preset detection model based on each of the evaluation indicators.
[0095] In an embodiment of the present application, the adversarial data detection device can determine that the intermediate detection model corresponding to the optimal evaluation index is the preset detection model.
[0096] In an embodiment of the present application, the initial detection model is trained multiple times using clean samples and corresponding clean sample labels, at least one adversarial sample corresponding to the clean samples, and at least one adversarial sample label corresponding to the adversarial sample, to determine an intermediate detection model obtained after each training, and an evaluation index corresponding to each intermediate detection model. A preset detection model is determined based on each evaluation index. Since the adversarial sample label and the clean sample label respectively include the group and family to which the corresponding sample belongs, the preset detection model can learn a large number of training samples and the characteristics of the family and group to which the training sample belongs. When facing an open set of data, the adversarial data formed by the data of each family in each group of the open set of data can be effectively detected. Compared with the scheme of detecting adversarial samples for a single distribution data set in the related art, the accuracy of adversarial sample detection facing open set data is greatly improved.
[0097] See also Figure 6 , is an optional flowchart of the adversarial data detection method provided in an embodiment of the present application, Figure 3 The illustrated S201 may also be implemented through S301 to S302 , which will be described in conjunction with the steps in the figure.
[0098] S301. Use each of the attack methods to process each of the clean samples to obtain the adversarial samples corresponding to each of the clean samples for at least one of the attack methods.
[0099] In the embodiment of the present application, the adversarial data detection device uses each attack method to process each clean sample to obtain adversarial samples corresponding to the clean sample for at least one attack method.
[0100] Among them, at least one attack method may include: an algorithm based on gradient generation of adversarial samples (fast gradient sign method, FGSM), an iterative attack algorithm (Project Gradient Descent, PGD), a basic iterative method (Basic Iterative Method, BIM) and a translation-invariant attack method (Translation-Invariant Method, TIM).
[0101] S302 , combining the adversarial samples corresponding to the same attack method to obtain the adversarial sample family, and combining each adversarial sample family to obtain the adversarial sample group.
[0102] In an embodiment of the present application, the adversarial data detection device can group adversarial samples formed by the same attack method into an adversarial sample family, and combine multiple adversarial sample families to obtain an adversarial sample group.
[0103] Exemplarily, the adversarial data detection device can group the adversarial samples formed by the FGSM method into an adversarial sample family. Similarly, adversarial sample families corresponding to PGD, BIM and TIM can be formed respectively.
[0104] In an embodiment of the present application, corresponding adversarial samples are formed by at least one attack method. Compared with the method of forming adversarial samples by a single attack method in the related art, the present application can provide more types of adversarial samples for training, so that the preset detection model can learn a large number of adversarial samples of various types, thereby improving the generalization of the preset detection model, and thus enabling the preset detection model to have higher data detection accuracy when facing open set data.
[0105] See also Figure 7 , is an optional flowchart of the adversarial data detection method provided in an embodiment of the present application, Figure 3 The illustrated S203 may also be implemented through S401 to S405, which will be described in conjunction with the steps in the figure.
[0106] S401. Using an initial feature extraction model, extract a first feature of the clean sample and a first feature corresponding to the clean sample label, and a second feature of at least one adversarial sample and a second feature corresponding to the adversarial sample label.
[0107] In the embodiment of the present application, the initial detection model includes: an initial feature extraction model, an initial group classification model and an initial family classification model. The adversarial data detection device inputs the clean sample and the corresponding clean sample label in the first training data packet, at least one adversarial sample corresponding to the clean sample, and the adversarial sample label corresponding to the at least one adversarial sample into the initial feature extraction model, and uses the initial feature extraction model to extract the first feature of the clean sample and the corresponding clean sample label, and the second feature of the at least one adversarial sample and the corresponding adversarial sample label.
[0108] Exemplary, combined Figure 8 , the initial detection model is divided into the initial feature extraction model, the initial group classification model and the initial family classification model. Among them, the initial feature extraction model can select the network structure widely used in the field of image recognition, such as the deep convolutional neural network ResNet (Residual Network), the Inception model, the Visual Geometry Group (Vgg) model of the University of Oxford, etc. This paper uses the ResNet model by default. The initial group classification model and the initial family classification model use the category decoupling strategy. The initial group classification model is used for group category classification, and the number of categories is 2: corresponding to the clean sample group and the adversarial sample group. The initial family classification model is used for family category classification. The number of categories is the number of families of the group category plus 1, and 1 represents the others family. At the same time, the first two layers of the feature extraction module and the classification module (initial group classification model and initial family classification model) of the model adopt weight sharing. The last fully connected layer of the group classification model in the model adopts the sigmoid activation function, and the last layer of the family classification model uses softmax to calculate the probability of the family.
[0109] S402: Process the first feature and at least one of the second features based on the initial group classification model to determine a group classification loss.
[0110] In an embodiment of the present application, the adversarial data detection device processes the first feature and at least one second feature through an initial group classification model, and determines the group category loss based on the corresponding group category loss function.
[0111] In an embodiment of the present application, the adversarial data detection device processes the first feature and at least one of the second features based on the initial group classification model to determine the contrast loss and the classification loss; and determines the group category loss based on the contrast loss and the classification loss.
[0112] Exemplarily, the group category loss function is used to classify samples in a wide group, and it is expected that the distribution between the two group samples is as far as possible. It includes two loss functions, the contrast loss function L1 and the classification loss function L2. The contrast loss functions used include Contrastive Loss, N-pair Loss, InfoNce Loss, etc. For example, InfoNce Loss is as shown in formula (1), and the classification loss function L2 is a binary cross entropy function.
[0113]
[0114] Among them, q represents the encoding feature of the query sample, k i With k + represents the encoding feature of the comparison sample, where the encoding feature is taken from the output of the last convolutional layer of the model, T represents the temperature parameter, and L1 represents the group loss function. + When there is a high similarity, that is, when they belong to the same group, the value of will be lower, otherwise it will be higher.
[0115] S403: Process the first feature and at least one of the second features based on the initial family classification model to determine a family category loss.
[0116] In an embodiment of the present application, the adversarial data detection device processes the first feature and at least one second feature through an initial family classification model, and determines the category loss based on the corresponding family category loss function.
[0117] For example, the class loss function L3 is used to classify samples into small families within the group, which mainly involves multi-classification problems. Commonly used loss functions such as cross entropy, mean square error, and softmax can be used. In particular, the added other class also participates in the loss calculation. The model is optimized based on the sum of the group loss function and the family loss function. The total Lsum loss function is as shown in formula (2).
[0118] Lsum= L1+ L2 +L3 (2)
[0119] S404: performing gradient update on the initial detection model based on the group category loss and the family category loss to obtain the first intermediate detection model and the evaluation index corresponding to the first intermediate detection model.
[0120] In the embodiment of the present application, the adversarial data detection device determines the total loss based on the group category loss and the good category loss, and performs gradient update on the initial feature extraction model, the initial group classification model and the initial family classification model based on the total loss to obtain an intermediate detection model. Then, the test data is input into the intermediate detection model, and the evaluation index corresponding to each intermediate detection model is determined based on the result output by the intermediate detection model.
[0121] S405, using the next group of the training data packets to train the initial detection model until a predetermined number of training times is reached, thereby obtaining N intermediate detection models and the evaluation index corresponding to each intermediate detection model.
[0122] In an embodiment of the present application, the adversarial data detection device trains the initial detection model using the clean samples and the corresponding clean sample labels included in the next group of training data packets, at least one adversarial sample corresponding to the clean sample, and the adversarial sample label corresponding to at least one adversarial sample, until a predetermined number of training times is reached, to obtain N intermediate detection models and the evaluation indicators corresponding to each intermediate detection model.
[0123] In the embodiment of the present application, multiple sets of training data packets are used to train the initial detection model until the predetermined number of training times is reached, and N intermediate detection models and evaluation indicators corresponding to each intermediate detection model are obtained. In this way, the preset detection model corresponding to the optimal evaluation indicator can be selected, and then the preset detection model with the optimal evaluation indicator can be used to detect adversarial data, which can improve the detection accuracy of adversarial data.
[0124] See also Fig. 9 , is an optional flowchart of the adversarial data detection method provided in an embodiment of the present application, Figure 7 The illustrated S403 may also be implemented through S501 to S503, which will be explained in conjunction with the steps in the figure.
[0125] S501. Performing gradient update on the initial detection model based on the sum of the group category loss and the family category loss to obtain the first intermediate detection model.
[0126] In an embodiment of the present application, the adversarial data detection device performs a gradient update on the initial detection model based on the sum of the group category loss and the family category loss to obtain the first intermediate detection model.
[0127] S502. Using a plurality of test samples to input into the first intermediate detection model, determine a prediction label corresponding to each of the test samples; wherein the plurality of test samples belong to the clean sample group and the adversarial sample group.
[0128] In the embodiment of the present application, after determining the clean sample group and the adversarial sample group, a certain proportion of clean samples and adversarial samples in the clean sample group and the adversarial sample group can be determined as multiple test samples. Each test sample corresponds to a true label, and the true label is used to characterize whether the corresponding test sample belongs to the adversarial sample group. The test sample is input into the first intermediate detection model, and the predicted label corresponding to the test sample is output.
[0129] S503: Determine the evaluation index corresponding to the first intermediate detection model based on the true label and the predicted label of each test sample.
[0130] In an embodiment of the present application, the adversarial data detection device determines the absolute matching rate and accuracy rate corresponding to the intermediate model based on the true label and the corresponding predicted label of each test sample.
[0131] The evaluation indicators are absolute matching rate and accuracy rate. The absolute matching rate means that for a certain input sample, only when both the group category and the family category are correctly judged can the prediction be considered accurate. The absolute matching rate is expressed as formula (3):
[0132]
[0133] Among them, MR represents the absolute matching rate, n represents the number of test samples, and y and They represent the true label and predicted label of the sample respectively, and I(*) represents the indicator function.
[0134] The accuracy rate means that when one of the group category and family category is correct, the prediction is considered correct. Its expression method is as shown in formula (4):
[0135]
[0136] Among them, ACC represents the accuracy, n represents the number of test samples, y and They represent the true label and predicted label of the sample respectively.
[0137] In the embodiment of the present application, multiple test samples are input into the first intermediate detection model to determine the predicted label corresponding to each test sample. Based on the true label and predicted label of each test sample, the evaluation index corresponding to the first intermediate detection model is determined. In this way, the preset detection model corresponding to the optimal evaluation index can be selected, and then the preset detection model with the optimal evaluation index can be used to perform adversarial data detection, which can improve the detection accuracy of adversarial data.
[0138] See also Fig.10 , is an optional flowchart of the adversarial data detection method provided in an embodiment of the present application, Figure 2 The illustrated S102 may also be implemented through S601 to S604, which will be described in conjunction with the steps in the figure.
[0139] S601. Input each data to be detected in the data set to be detected into the preset detection model to obtain the group probability information output by the group classification model in the preset detection model, as well as the probability information of the first virtual other class and the probability information of the second virtual other class output by the family classification model in the preset detection model.
[0140] In an embodiment of the present application, the adversarial data detection device inputs the data to be detected into a preset detection model, obtains the group probability information output by the group classification model of the preset detection model, and the probability information of the first virtual other class and the probability information of the second virtual other class output by the family classification model in the preset detection model.
[0141] Among them, the output of the family classification model in the preset detection model includes: the probability output corresponding to each clean sample family and the probability output of the first virtual other class; wherein the probability output of the first virtual other class is used to characterize the probability that the clean sample label does not belong to the clean sample group; the output of the family classification model in the preset detection model also includes: the probability output corresponding to each adversarial sample family and the probability output of the second virtual other class; wherein the probability output of the second virtual other class is used to characterize the probability that the adversarial sample label does not belong to the adversarial sample group.
[0142] S602: Determine a group detection result to which the to-be-detected data belongs based on the group probability information.
[0143] In an embodiment of the present application, the group probability information includes probability information representing the adversarial sample group and probability information representing the clean sample group. Based on the probability size of each representation of the adversarial sample group probability information and the clean sample group probability information, the group detection result to which the data to be detected belongs is determined.
[0144] S603: Determine an adversarial data detection result of the data to be detected based on the group detection result combined with the probability information of the first virtual other class or the probability information of the second virtual other class.
[0145] In an embodiment of the present application, if the group detection result represents that the data to be detected belongs to the clean sample group, and the probability information of the first virtual other class is less than a first threshold, then the adversarial data detection result that the data to be detected is clean data is determined; if the group detection result represents that the data to be detected belongs to the adversarial sample group, and the probability information of the second virtual other class is less than a second threshold, then the adversarial data detection result that the data to be detected is adversarial data is determined.
[0146] The model's judgment of the input sample category relies on two bases: one is the probability prediction of the group category output by the first level of the classification module, and the other is based on the probability of the other group in each group. Specifically, the sample category is preliminarily determined based on the output result of the group category; then the other group in each group is judged, which can be divided into the following situations:
[0147] Adversarial sample: The group category is determined to be an adversarial sample group; the probability of the other family in the adversarial sample group (the probability information of the second virtual other class) is less than the second threshold.
[0148] Clean sample: The group category is determined to be a clean sample group; the probability of the other group in the clean sample group (the probability information of the first virtual other class) is less than the first threshold.
[0149] Note: The sum of all family probabilities is 1. By setting a suitable threshold, the situation where the other family is greater than or less than the threshold and the opposite of the group category judgment will not occur.
[0150] S604: Determine the adversarial data in the data set to be detected based on each adversarial data detection result.
[0151] In the embodiment of the present application, after the preset detection model detects each data to be detected, it can be determined whether it is adversarial data, and the adversarial data can be eliminated from the data set to be detected.
[0152] In an embodiment of the present application, each data to be detected in the data set to be detected is input into a preset detection model to obtain group probability information output by the group classification model in the preset detection model, as well as probability information of the first virtual other class and probability information of the second virtual other class output by the family classification model in the preset detection model. The group detection result is determined based on the group probability information, and then the adversarial data detection result of the data to be detected is determined based on the group detection result combined with the probability information of the first virtual other class or the probability information of the second virtual other class. Compared with the method of pre-testing adversarial samples for a single distribution data set, this method of determining the detection result by combining the group probability information and the probability information of the two virtual other classes increases the judgment basis for data detection and takes more comprehensive considerations, thereby achieving higher accuracy in data detection when facing an open set of data.
[0153] See also Fig.11 , which is an optional flow chart of the adversarial data detection method provided in an embodiment of the present application, will be explained in conjunction with the steps in the figure.
[0154] S701. Construct hierarchical multi-label data.
[0155] In the embodiment of the present application, an adversarial sample group is generated based on the acquired clean sample group through at least one attack method; wherein the clean sample group includes multiple clean sample families, each of which includes multiple clean samples; the adversarial sample group includes multiple adversarial sample families, each of which includes multiple adversarial samples. A corresponding clean sample label is formed for each clean sample, and a corresponding adversarial sample label is formed for each adversarial sample.
[0156] S702: Construct a hierarchical adversarial sample detection model.
[0157] In the embodiment of the present application, an initial physical sign extraction model, an initial group classification model and an initial family classification model are constructed, wherein the initial group classification model and the initial family classification model are decoupled using a category decoupling strategy.
[0158] S703, contrastive learning + classification training hierarchical model.
[0159] In an embodiment of the present application, a hierarchical adversarial sample detection model (initial detection model) is trained using the clean sample and the corresponding clean sample label, at least one adversarial sample corresponding to the clean sample, and the adversarial sample label corresponding to at least one adversarial sample to obtain a final detection model.
[0160] S704: Hierarchical detection model evaluation.
[0161] In an embodiment of the present application, an open data set is obtained, and the data to be detected in the open data set is evaluated using a trained model to determine adversarial data therein.
[0162] In the embodiment of the present application, the multi-distribution adversarial sample detection is carried out by using a group method, which can not only detect adversarial samples on different data sets, but also detect adversarial samples generated by different attack methods. The data organization method is hierarchical multi-label, the input is a sample pair, and the network structure also adopts a hierarchical structure to decouple the family category and the group category.
[0163] Combination Fig.12 The adversarial data detection device includes a hierarchical multivariate label data construction module 101, a hierarchical adversarial sample detection model module 102, a contrastive learning and classification training module 103, a model evaluation module 104, and a multi-distribution adversarial sample detection module 105. The hierarchical multivariate label data construction module 101 is used to construct hierarchical multivariate label data. The hierarchical adversarial sample detection model module 102 is used to construct a hierarchical model, wherein the feature extraction model includes but is not limited to that described in S702. The contrastive learning and classification training module 103 is used to train the model. The model evaluation module 104 is used to evaluate the performance of the trained model. The multi-distribution adversarial sample detection module 105 is used to detect adversarial samples input to the hierarchical detection network.
[0164] See also Fig.13 , which is a schematic diagram of the structure of the adversarial data detection device provided in an embodiment of the present application.
[0165] The embodiment of the present application further provides a countermeasure data detection device 800 , including: a data acquisition unit 801 and a determination unit 802 .
[0166] The data acquisition unit 801 is used to acquire a data set to be detected;
[0167] A determination unit 802 is used to input the data set to be detected into a preset detection model to determine adversarial data in the data set to be detected;
[0168] The preset detection model is obtained by training the initial detection model based on the training samples and the corresponding sample labels; the sample labels are used to characterize the family and group to which the training samples belong.
[0169] In the embodiment of the present application, the training samples include: clean samples and adversarial samples; the determination unit 802 in the adversarial data detection device 800 is used to generate an adversarial sample group based on the acquired clean sample group by at least one attack method; wherein the clean sample group includes a plurality of clean sample families, each of which includes a plurality of clean samples; the adversarial sample group includes a plurality of adversarial sample families, each of which includes a plurality of adversarial samples; each of the clean samples corresponds to at least one adversarial sample generated based on at least one of the attack methods;
[0170] A corresponding clean sample label is formed for each of the clean samples, and a corresponding adversarial sample label is formed for each of the adversarial samples; wherein the clean sample label includes a corresponding clean sample identifier, and the clean sample family and the clean sample group to which the clean sample belongs; the adversarial sample label includes a corresponding adversarial sample identifier, and the adversarial sample family and the adversarial sample group to which the adversarial sample belongs;
[0171] The initial detection model is trained multiple times based on multiple sets of training data packets, and an intermediate detection model obtained after each training and an evaluation index corresponding to each intermediate detection model are determined; wherein the training data packet includes: the clean sample and the corresponding clean sample label, at least one adversarial sample corresponding to the clean sample, and the adversarial sample label corresponding to at least one adversarial sample;
[0172] The preset detection model is determined based on each of the evaluation indicators.
[0173] In the embodiment of the present application, the determination unit 802 in the adversarial data detection device 800 is used to process each of the clean samples using each of the attack methods to obtain the adversarial samples corresponding to each of the clean samples for at least one of the attack methods;
[0174] The adversarial samples corresponding to the same attack method are combined to obtain the adversarial sample family, and each adversarial sample family is combined to obtain the adversarial sample group.
[0175] In the embodiment of the present application, the initial detection model includes: an initial feature extraction model, an initial group classification model and an initial family classification model; the determination unit 802 in the adversarial data detection device 800 is used to extract the first feature of the clean sample and the corresponding clean sample label, and the second feature of at least one adversarial sample and the corresponding adversarial sample label by using the initial feature extraction model;
[0176] Processing the first feature and at least one of the second features based on the initial group classification model to determine a group classification loss;
[0177] Processing the first feature and at least one of the second features based on the initial family classification model to determine a family classification loss;
[0178] Performing gradient update on the initial detection model based on the group category loss and the family category loss to obtain a first intermediate detection model and the evaluation index corresponding to the first intermediate detection model;
[0179] The initial detection model is trained using the next set of the training data packets until a predetermined number of training times is reached, thereby obtaining N intermediate detection models and the evaluation index corresponding to each intermediate detection model; wherein N is an integer greater than 0.
[0180] In the embodiment of the present application, the determination unit 802 in the adversarial data detection device 800 is used to process the first feature and at least one of the second features based on the initial group classification model to determine the contrast loss and the classification loss;
[0181] The group class loss is determined based on the contrastive loss and the classification loss.
[0182] In the embodiment of the present application, the determination unit 802 in the adversarial data detection device 800 is used to perform a gradient update on the initial detection model based on the sum of the group category loss and the family category loss to obtain the first intermediate detection model;
[0183] Using multiple test samples to input the first intermediate detection model, determining a prediction label corresponding to each of the test samples; wherein the multiple test samples belong to the clean sample group and the adversarial sample group;
[0184] Based on the true label and the predicted label of each of the test samples, the evaluation index corresponding to the first intermediate detection model is determined.
[0185] In the embodiment of the present application, the output of the family classification model in the preset detection model includes: a probability output corresponding to each of the clean sample families and a probability output of the first virtual other class; wherein the probability output of the first virtual other class is used to characterize the probability that the clean sample label does not belong to the clean sample group;
[0186] The output of the family classification model in the preset detection model also includes: a probability output corresponding to each of the adversarial sample families and a probability output of a second virtual other class; wherein the probability output of the second virtual other class is used to characterize the probability that the adversarial sample label does not belong to the adversarial sample group.
[0187] In the embodiment of the present application, the determination unit 802 in the adversarial data detection device 800 is used to input each to-be-detected data in the to-be-detected data set into the preset detection model, and obtain the group probability information output by the group classification model in the preset detection model, and the probability information of the first virtual other class and the probability information of the second virtual other class output by the family classification model in the preset detection model;
[0188] Determine the group detection result to which the data to be detected belongs based on the group probability information;
[0189] Determine the adversarial data detection result of the data to be detected based on the group detection result combined with the probability information of the first virtual other class or the probability information of the second virtual other class;
[0190] The adversarial data is determined in the to-be-detected data set based on each of the adversarial data detection results.
[0191] In the embodiment of the present application, the determination unit 802 in the adversarial data detection device 800 is used to determine the adversarial data detection result that the data to be detected is clean data if the group detection result indicates that the data to be detected belongs to the clean sample group, and the probability information of the first virtual other class is less than a first threshold;
[0192] If the group detection result indicates that the data to be detected belongs to an adversarial sample group, and the probability information of the second virtual other class is less than a second threshold, then determining the adversarial data detection result that the data to be detected is adversarial data.
[0193] It should be noted that in the embodiment of the present application, if the above-mentioned adversarial data detection method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable an adversarial data detection device (which can be a personal computer, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0194] Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the method on the side of the countermeasure data detection device are implemented.
[0195] Correspondingly, an embodiment of the present application further provides a computer program product, including a computer program, which can be executed by the processor 901 of the electronic device 900 to complete the steps in the method on the detection device side.
[0196] Correspondingly, an embodiment of the present application provides an electronic device 900, including a memory 902 and a processor 901, wherein the memory 902 stores a computer program that can be executed on the processor 901, and the processor 901 implements the steps in the above method when executing the program.
[0197] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0198] It should be noted that Fig.14 A hardware entity diagram of an electronic device provided in an embodiment of the present application, such as Fig.14 As shown, the hardware entity of the electronic device 900 includes: a processor 901 and a memory 902, wherein;
[0199] The processor 901 generally controls the overall operations of the electronic device 900 .
[0200] The memory 902 is configured to store instructions and applications executable by the processor 901, and can also cache data to be processed or processed by the processor 901 and various modules in the electronic device 900 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0201] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.
[0202] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0203] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0204] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0205] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0206] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: a mobile storage device, a read-only memory (ROM), a magnetic disk or an optical disk, and other media that can store program codes.
[0207] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a mobile storage device, a ROM, a magnetic disk, or an optical disk.
[0208] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for detecting adversarial data, It is characterized in that include: Get the data set to be tested; Inputting the to-be-detected data set into a preset detection model to determine adversarial data in the to-be-detected data set; The preset detection model is obtained by training the initial detection model based on the training samples and the corresponding sample labels; the sample labels are used to characterize the family and group to which the training samples belong.
2. The adversarial data detection method according to claim 1, It is characterized in that The training samples include: clean samples and adversarial samples; before inputting the to-be-detected data set into a preset detection model and determining adversarial data in the to-be-detected data set, the method further includes: Generate an adversarial sample group based on the acquired clean sample group through at least one attack method; wherein the clean sample group includes a plurality of clean sample clusters, each of the clean sample clusters includes a plurality of the clean samples; the adversarial sample group includes a plurality of adversarial sample clusters, each of the adversarial sample clusters includes a plurality of the adversarial samples; each of the clean samples corresponds to at least one adversarial sample generated based on at least one of the attack methods; A corresponding clean sample label is formed for each of the clean samples, and a corresponding adversarial sample label is formed for each of the adversarial samples; wherein the clean sample label includes a corresponding clean sample identifier, and the clean sample family and the clean sample group to which the clean sample belongs; the adversarial sample label includes a corresponding adversarial sample identifier, and the adversarial sample family and the adversarial sample group to which the adversarial sample belongs; The initial detection model is trained multiple times based on multiple sets of training data packets, and an intermediate detection model obtained after each training and an evaluation index corresponding to each intermediate detection model are determined; wherein the training data packet includes: the clean sample and the corresponding clean sample label, at least one adversarial sample corresponding to the clean sample, and the adversarial sample label corresponding to at least one adversarial sample; The preset detection model is determined based on each of the evaluation indicators.
3. The adversarial data detection method according to claim 2, It is characterized in that The method of generating an adversarial sample group based on the acquired clean sample group by at least one attack method includes: Using each of the attack methods to process each of the clean samples, to obtain the adversarial samples corresponding to each of the clean samples for at least one of the attack methods; The adversarial samples corresponding to the same attack method are combined to obtain the adversarial sample family, and each adversarial sample family is combined to obtain the adversarial sample group.
4. The adversarial data detection method according to claim 2, It is characterized in that The initial detection model includes: an initial feature extraction model, an initial group classification model and an initial family classification model; the initial detection model is trained multiple times based on multiple sets of training data packets, and an intermediate detection model obtained after each training is determined, as well as an evaluation index corresponding to each intermediate detection model, including: Extracting, using an initial feature extraction model, a first feature of the clean sample and a first feature corresponding to the clean sample label, and a second feature of at least one of the adversarial samples and a second feature corresponding to the adversarial sample label; Processing the first feature and at least one of the second features based on the initial group classification model to determine a group classification loss; Processing the first feature and at least one of the second features based on the initial family classification model to determine a family classification loss; Performing gradient update on the initial detection model based on the group category loss and the family category loss to obtain a first intermediate detection model and the evaluation index corresponding to the first intermediate detection model; The initial detection model is trained using the next set of the training data packets until a predetermined number of training times is reached, thereby obtaining N intermediate detection models and the evaluation index corresponding to each intermediate detection model; wherein N is an integer greater than 0.
5. The adversarial data detection method according to claim 4, It is characterized in that The determining the group classification loss by processing the first feature and at least one of the second features based on the initial group classification model includes: Processing the first feature and at least one of the second features based on the initial group classification model to determine a contrast loss and a classification loss; The group class loss is determined based on the contrastive loss and the classification loss.
6. The adversarial data detection method according to claim 4, It is characterized in that The step of performing gradient updating on the initial detection model based on the group category loss and the family category loss to obtain the first intermediate detection model and the evaluation index corresponding to the first intermediate detection model includes: Performing gradient update on the initial detection model based on the sum of the group category loss and the family category loss to obtain the first intermediate detection model; Using multiple test samples to input the first intermediate detection model, determining a prediction label corresponding to each of the test samples; wherein the multiple test samples belong to the clean sample group and the adversarial sample group; Based on the true label and the predicted label of each of the test samples, the evaluation index corresponding to the first intermediate detection model is determined.
7. The adversarial data detection method according to any one of claims 4 to 6, It is characterized in that The output of the family classification model in the preset detection model includes: a probability output corresponding to each of the clean sample families and a probability output of a first virtual other class; wherein the probability output of the first virtual other class is used to represent the probability that the clean sample label does not belong to the clean sample group; The output of the family classification model in the preset detection model also includes: a probability output corresponding to each of the adversarial sample families and a probability output of a second virtual other class; wherein the probability output of the second virtual other class is used to characterize the probability that the adversarial sample label does not belong to the adversarial sample group.
8. The adversarial data detection method according to claim 7, It is characterized in that The step of inputting the to-be-detected data set into a preset detection model to determine adversarial data in the to-be-detected data set includes: Input each to-be-detected data in the to-be-detected data set into the preset detection model, and obtain the group probability information output by the group classification model in the preset detection model, as well as the probability information of the first virtual other class and the probability information of the second virtual other class output by the family classification model in the preset detection model; Determine the group detection result to which the data to be detected belongs based on the group probability information; Determine the adversarial data detection result of the data to be detected based on the group detection result combined with the probability information of the first virtual other class or the probability information of the second virtual other class; The adversarial data is determined in the to-be-detected data set based on each of the adversarial data detection results.
9. The adversarial data detection method according to claim 8, It is characterized in that The determining, based on the group detection result combined with the probability information of the first virtual other class or the probability information of the second virtual other class, the adversarial data detection result of the to-be-detected data includes one of the following: If the group detection result indicates that the data to be detected belongs to the clean sample group, and the probability information of the first virtual other class is less than a first threshold, determining that the data to be detected is the adversarial data detection result of clean data; If the group detection result indicates that the data to be detected belongs to an adversarial sample group, and the probability information of the second virtual other class is less than a second threshold, then determining the adversarial data detection result that the data to be detected is adversarial data.
10. A device for detecting adversarial data, It is characterized in that include: A data acquisition unit, used to acquire a data set to be detected; A determination unit, configured to input the to-be-detected data set into a preset detection model, and determine adversarial data in the to-be-detected data set; The preset detection model is obtained by training the initial detection model based on the training samples and the corresponding sample labels; the sample labels are used to characterize the family and group to which the training samples belong.
11. An electronic device, It is characterized in that The method comprises a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 9 when executing the computer program.
12. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 9 are implemented.
13. A computer program product comprising a computer program, It is characterized in that The computer program implements the steps of the method according to any one of claims 1 to 9 when executed by a processor.
Citation Information
Cited By
Image confrontation sample detection method based on sample semantic difference
CN120976655A
