Method and processor for detecting adversarial samples in neural network models

By obtaining neuron output values ​​and model output values ​​​​in the neural network model, determining ineffective neurons and key neurons, and performing adversarial sample detection based on prediction discrimination, the problem of low efficiency in adversarial sample detection in the existing technology is solved and achieved. Real-time detection and low false negative rate.

CN117787352BActive Publication Date: 2024-09-03BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311640739.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-01
Publication Date
2024-09-03
Estimated Expiration
2043-12-01

AI Technical Summary

Technical Problem

The detection efficiency of adversarial samples in the existing technology is low, relying on the comprehensiveness of the types of generated adversarial samples, and cannot effectively detect neuron attacks that multiplex normal sample activations.

Method used

By obtaining the neuron output values ​​and model output values ​​​​of different sample categories in the preset neural network model, the invalid neurons and key neurons are determined. Combined with the prediction discrimination, the data to be detected is detected in real time to determine whether it is an adversarial sample. Using A method that combines neuron anomaly detection and model output anomaly detection.

Benefits of technology

It achieves real-time adversarial sample detection when the neural network model is running, without relying on complex prior knowledge of adversarial samples, improving detection efficiency and reducing the false negative rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117787352B
    Figure CN117787352B
Patent Text Reader

Abstract

The present application discloses a method and processor for detecting adversarial samples of a neural network model, and belongs to the field of artificial intelligence technology. The method includes: obtaining the neuron output values ​​and model output values ​​corresponding to sample data of different sample categories in a preset neural network model; determining the invalid neurons and key neurons corresponding to each sample category in the preset neural network model according to the neuron output values; determining the prediction discrimination of the preset neural network model for each sample category according to the model output values; performing adversarial sample detection on the data to be detected according to the invalid neurons, key neurons and model prediction discrimination to determine whether the data to be detected is adversarial sample data. The present application can improve the detection efficiency of adversarial samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and specifically to a method and processor for detecting adversarial samples of a neural network model. Background Art

[0002] At present, with the rapid development of artificial intelligence technology, the application of artificial intelligence technology is becoming more and more extensive. It has been applied to many fields such as image analysis, speech recognition, text processing, intelligent recommendation, security detection, etc. The security protection technology for artificial intelligence systems themselves has become a new frontier technology hotspot. Adversarial sample attack is a typical attack type against artificial intelligence algorithm models. Through carefully designed input data, the artificial intelligence algorithm model outputs abnormal results to achieve the purpose of attacking or interfering with the artificial intelligence system. In order to defend against adversarial sample attacks, the existing technology usually adopts a method of generating adversarial samples to train adversarial sample detection models, and then detecting adversarial samples through adversarial sample detection models. The detection effect depends on whether the generated adversarial sample types are comprehensive. It is very difficult to generate adversarial samples with comprehensive types, and adversarial samples cannot be fully enumerated. Therefore, there is a problem of low efficiency in adversarial sample detection. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a method and processor for adversarial sample detection in a neural network model, so as to solve the problem of low efficiency of adversarial sample detection in the prior art.

[0004] In order to achieve the above-mentioned object, the first aspect of the embodiment of the present application provides a method for detecting adversarial samples of a neural network model, comprising:

[0005] Obtaining the neuron output values ​​and model output values ​​corresponding to the sample data of different sample categories in the preset neural network model;

[0006] According to the neuron output value, determine the invalid neurons and key neurons corresponding to each sample category in the preset neural network model;

[0007] According to the model output value, determine the prediction discrimination of the preset neural network model for each sample category;

[0008] According to the invalid neurons, key neurons and model prediction discrimination, adversarial sample detection is performed on the data to be tested to determine whether the data to be tested is adversarial sample data.

[0009] In an embodiment of the present application, determining the invalid neurons and key neurons corresponding to each sample category in a preset neural network model according to the neuron output value includes: for a set of neuron output values ​​of any neuron in any sample category, judging whether the data in the set are all 0; when it is determined that the data in the set are all 0, determining that any neuron is an invalid neuron in the classification task of any sample category; obtaining a set of invalid neurons for any sample category based on all invalid neurons in the sample classification task of any sample category; when it is determined that the data in the set are not 0, determining that any neuron is a key neuron in the classification task of any sample category; obtaining a set of key neurons for any sample category based on all key neurons in the sample classification task of any sample category.

[0010] In an embodiment of the present application, determining the predictive discrimination of the preset neural network model for each sample category based on the model output value includes: obtaining multiple first model output values ​​of the preset neural network model for any sample in each sample category; determining the predictive discrimination of the preset neural network model for each sample category based on the maximum value and the second largest value among the multiple first model output values.

[0011] In the embodiment of the present application, the prediction discrimination of the neural network model for each sample category satisfies formula (1):

[0012]

[0013] Among them, D i is the predicted discrimination of the preset neural network model for the i-th type of sample; |T i | is the dataset T consisting of samples of the i-th category i The number of samples; The data set T composed of the i-th type of samples for the preset neural network model i The maximum value among the m+1 model output values ​​of the kth sample in ; The data set T composed of the i-th type of samples for the preset neural network model i The second largest value among the m+1 model output values ​​of the kth sample in .

[0014] In an embodiment of the present application, adversarial sample detection is performed on the data to be detected based on invalid neurons, key neurons and model prediction discrimination to determine whether the data to be detected is adversarial sample data, including: inputting the data to be detected into a preset neural network model to obtain the predicted category of the data to be detected, and the neurons activated in the preset neural network model; determining whether the predicted category of the data to be detected belongs to the sample category; when it is determined that the predicted category of the data to be detected belongs to the sample category, performing neuron anomaly detection on the data to be detected based on the invalid neurons, key neurons and activated neurons in the preset neural network model corresponding to the predicted category; and performing model output anomaly detection on the data to be detected based on the predicted discrimination of the predicted category.

[0015] In an embodiment of the present application, performing neuronal anomaly detection on the data to be detected according to the invalid neurons, key neurons corresponding to the prediction category and the activated neurons in the preset neural network model includes: judging whether in the classification task of the samples of the prediction category, invalid neurons of the invalid neuron set belonging to the prediction category are activated; judging whether in the classification task of the samples of the prediction category, key neurons of the key neuron set belonging to the prediction category are not activated; when it is determined that invalid neurons of the invalid neuron set belonging to the prediction category are activated and / or key neurons of the key neuron set belonging to the prediction category are not activated, determining that the data to be detected is adversarial sample data.

[0016] In an embodiment of the present application, performing model output anomaly detection on the data to be detected based on the prediction discrimination of the prediction category includes: obtaining multiple second model output values ​​of a preset neural network model for the data to be detected; calculating the difference between the maximum value and the second largest value among the multiple second model output values; judging whether the difference is less than the prediction discrimination of the preset neural network model for the prediction category; and determining that the data to be detected is adversarial sample data when it is judged that the difference is less than the prediction discrimination of the preset neural network model for the prediction category.

[0017] In an embodiment of the present application, the method further includes: when it is determined that the predicted category of the data to be detected does not belong to the sample category, terminating the detection of the data to be detected, and outputting that the security of the data to be detected is unknown.

[0018] A second aspect of an embodiment of the present application provides a processor configured to execute the above-mentioned method for detecting adversarial samples for a neural network model.

[0019] A third aspect of an embodiment of the present application provides a machine-readable storage medium having instructions stored thereon, the instructions being used to enable a machine to execute the above-mentioned method for detecting adversarial samples for a neural network model.

[0020] The above technical scheme obtains the neuron output values ​​and model output values ​​corresponding to the sample data of different sample categories in the preset neural network model, and determines the invalid neurons and key neurons corresponding to each sample category in the preset neural network model according to the neuron output values, and then determines the prediction discrimination of the preset neural network model for each sample category according to the model output value, so as to perform adversarial sample detection on the data to be detected according to the invalid neurons, key neurons and model prediction discrimination, so as to determine whether the data to be detected is adversarial sample data. The present application can detect adversarial samples in real time when the neural network model is running, does not rely on complex prior knowledge of adversarial samples, and the implementation process is simple and easy, which improves the detection efficiency of adversarial samples. In addition, by simultaneously using neuron output analysis and model output analysis for adversarial sample detection, the false negative rate of adversarial sample detection is effectively reduced.

[0021] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:

[0023] Figure 1 A flowchart of a method for detecting adversarial samples of a neural network model according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0025] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0026] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0027] Figure 1 The flowchart of a method for detecting adversarial samples of a neural network model according to an embodiment of the present application is schematically shown. Figure 1 As shown, the embodiment of the present application provides a method for detecting adversarial samples of a neural network model. The method is described by taking the application of the method to a processor as an example. The method may include the following steps:

[0028] Step S101, obtaining neuron output values ​​and model output values ​​corresponding to sample data of different sample categories in a preset neural network model.

[0029] Step S102: Determine the invalid neurons and key neurons corresponding to each sample category in the preset neural network model according to the neuron output value.

[0030] Step S103: Determine the prediction discrimination of the preset neural network model for each sample category according to the model output value.

[0031] Step S104: perform adversarial sample detection on the data to be detected based on the invalid neurons, key neurons and model prediction discrimination to determine whether the data to be detected is adversarial sample data.

[0032] In the prior art, for the detection of adversarial samples, it is usually necessary to generate adversarial samples in advance, and then use the generated adversarial samples to train a dedicated adversarial sample detection model to detect adversarial samples. The detection effect depends on whether the generated adversarial sample types are comprehensive, but since adversarial samples cannot be fully enumerated, it is very difficult to generate adversarial samples with comprehensive types. In order to ensure the detection effect, a large number of adversarial samples need to be constructed, which makes the construction process of the adversarial sample detection model too complicated and costly. Moreover, when the adversarial sample completely reuses the neurons activated by the normal sample, the adversarial sample cannot be effectively detected using the adversarial sample detection model. Based on this, the embodiment of the present application proposes a method for adversarial sample detection of a neural network model, which can realize real-time detection of adversarial samples when the neural network model is running, and can detect adversarial sample attacks on neurons activated by reusing normal samples, without relying on complex adversarial sample prior knowledge, and the implementation process is simple and easy. And the neuron output analysis and model output analysis are used at the same time, which effectively reduces the false negative rate of adversarial sample detection. In the embodiment of the present application, the preset neural network model is a multi-classification neural network model as an example for explanation.

[0033] It can be understood that M is a multi-classification neural network model, C = {c1, c2, ..., c n} is a set of n neurons of model M, T = {T1, T2, ..., T m} is the training data set, T contains m different types of samples, T i is the data subset consisting of the i-th type of samples, i is a positive integer, 1≤i≤m.

[0034] Specifically, for each type of sample data set T in the training data set i ,|T i | is the data set T i The number of samples, the processor will T i Each sample in is input into the model M one by one, and the output value of each neuron in the model M and the model output value of the model M are obtained. Among them, the jth neuron c j |T i | output values ​​constitute the set CO ij , 1≤j≤n, model M for T i The m+1 predicted output values ​​of the kth sample in constitute the set MO ik , 1≤k≤|T i|. After completing data collection, that is, obtaining the output value of each neuron in model M and the model output value of model M for each sample, the processor can perform neuron output analysis and model output analysis on the acquired data to determine the invalid neurons and model prediction discrimination for the sample category. Among them, neuron analysis is to determine the invalid neurons and key neurons corresponding to the samples of each sample category in the preset neural network model according to the neuron output values ​​of the samples of each sample category; model output analysis is to determine the prediction discrimination of model M for each sample category according to the model output value. Finally, according to the invalid neurons, key neurons and model prediction discrimination of each category of samples, adversarial sample detection is performed on the data to be detected, and it can be determined whether the data to be detected is adversarial sample data. Among them, adversarial sample detection includes neuron anomaly detection and model output anomaly detection. When the data to be detected meets at least one of neuron anomaly and model anomaly, the data to be detected is determined as adversarial sample data.

[0035] The above technical scheme obtains the neuron output values ​​and model output values ​​corresponding to the sample data of different sample categories in the preset neural network model, and determines the invalid neurons and key neurons corresponding to each sample category in the preset neural network model according to the neuron output values, and then determines the prediction discrimination of the preset neural network model for each sample category according to the model output value, so as to perform adversarial sample detection on the data to be detected according to the invalid neurons, key neurons and model prediction discrimination, so as to determine whether the data to be detected is adversarial sample data. The present application can detect adversarial samples in real time when the neural network model is running, does not rely on complex prior knowledge of adversarial samples, and the implementation process is simple and easy, which improves the detection efficiency of adversarial samples. In addition, by simultaneously using neuron output analysis and model output analysis for adversarial sample detection, the false negative rate of adversarial sample detection is effectively reduced.

[0036] In an embodiment of the present application, determining, based on neuron output values, invalid neurons and key neurons corresponding to each sample category in a preset neural network model may include: for a set of neuron output values ​​of any neuron in any sample category, judging whether the data in the set are all 0; when it is determined that the data in the set are all 0, determining that any neuron is an invalid neuron in the classification task of any sample category; obtaining a set of invalid neurons for any sample category based on all invalid neurons in the sample classification task of any sample category; when it is determined that the data in the set are not 0, determining that any neuron is a key neuron in the classification task of any sample category; obtaining a set of key neurons for any sample category based on all key neurons in the sample classification task of any sample category.

[0037] Specifically, for the set of neuron output values ​​of any neuron in any sample category, the jth neuron c j |T i |The set of output values ​​CO ij , 1≤j≤n as an example, if the set CO ij If the values ​​of all data in are 0, then the jth neuron c j In the classification task of the i-th sample, it is an invalid neuron. All invalid neurons in the classification task of the i-th sample form a set IV i ; If the set CO ij If all the data values ​​in are not 0, then the jth neuron c j In the classification task of the i-th sample, it is the key neuron. All the key neurons in the classification task of the i-th sample form a set V i .

[0038] In an embodiment of the present application, determining the predictive discrimination of the preset neural network model for each sample category based on the model output value may include: obtaining multiple first model output values ​​of the preset neural network model for any sample in each sample category; determining the predictive discrimination of the preset neural network model for each sample category based on the maximum value and the second largest value among the multiple first model output values.

[0039] Specifically, for a plurality of model output values ​​of any sample in each sample category, namely, the first model output value, the model M is used for T i Taking the m+1 model output values ​​of the kth sample in as an example, model M is for T i The m+1 model output values ​​of the kth sample in constitute the set MO ik , set MO ik The maximum and second largest values ​​among the m+1 data are recorded as and According to the maximum value and the second largest value The prediction discrimination D of model M for the i-th type of sample can be calculated i . D i Yes | T i | The minimum value in .

[0040] In the embodiment of the present application, the prediction discrimination of the neural network model for each sample category satisfies formula (1):

[0041]

[0042] Among them, D i is the predicted discrimination of the preset neural network model for the i-th type of sample; |T i| is the dataset T consisting of samples of the i-th category i The number of samples; The data set T composed of the i-th type of samples for the preset neural network model i The maximum value among the m+1 model output values ​​of the kth sample in ; The data set T composed of the i-th type of samples for the preset neural network model i The second largest value among the m+1 model output values ​​of the kth sample in .

[0043] In an embodiment of the present application, adversarial sample detection is performed on the data to be detected based on invalid neurons, key neurons and model prediction discrimination to determine whether the data to be detected is adversarial sample data, which may include: inputting the data to be detected into a preset neural network model to obtain the predicted category of the data to be detected, and the neurons activated in the preset neural network model; determining whether the predicted category of the data to be detected belongs to the sample category; when it is determined that the predicted category of the data to be detected belongs to the sample category, performing neuron anomaly detection on the data to be detected based on the invalid neurons, key neurons and activated neurons in the preset neural network model corresponding to the predicted category; and performing model output anomaly detection on the data to be detected based on the predicted discrimination of the predicted category.

[0044] Specifically, according to the invalid neurons, key neurons and model prediction discrimination of each type of samples obtained above, adversarial sample detection can be performed on the data to be detected to determine whether the data to be detected is adversarial sample data. Among them, adversarial sample detection includes neuron anomaly detection and model output anomaly detection. When the data to be detected satisfies at least one of neuron anomaly and model anomaly, the data to be detected is determined to be adversarial sample data. After the data to be detected is input into the model M, the processor can record the activated neurons in the model M and the predicted category c of the data to be detected, 1≤c≤m+1. The processor first determines whether the predicted category c of the data to be detected belongs to the sample category, which is all the sample categories in the training data set. In the case where it is determined that the predicted category c of the data to be detected belongs to the sample category, neuron anomaly detection is performed on the data to be detected according to the invalid neurons, key neurons and activated neurons in the model M corresponding to the predicted category c; and model output anomaly detection is performed on the data to be detected according to the predicted discrimination of the predicted category c.

[0045] In an embodiment of the present application, performing neuronal anomaly detection on the data to be detected based on invalid neurons, key neurons corresponding to the prediction category, and neurons activated in a preset neural network model may include: judging whether invalid neurons of an invalid neuron set belonging to the prediction category are activated in a classification task of samples of the prediction category; judging whether key neurons of a key neuron set belonging to the prediction category are not activated in a classification task of samples of the prediction category; and determining that the data to be detected is adversarial sample data when it is determined that invalid neurons of an invalid neuron set belonging to the prediction category are activated and / or key neurons of a key neuron set belonging to the prediction category are not activated.

[0046] Specifically, when it is determined that the predicted category c of the data to be detected belongs to the sample category, the processor obtains all invalid neurons in the classification task of the c-th sample to form a set IV c , and all the key neurons in the classification task of the c-th sample form a set V c Then, we determine whether there are samples belonging to set IV in the classification task of the c-th sample. c The invalid neurons are activated, whether there are samples belonging to the set V in the classification task of the c-th sample c The key neurons of the prediction category are not activated. c The inactive neurons are activated and / or there is a critical neuron set V belonging to the predicted category c When the key neurons are not activated, the data to be detected is determined to be adversarial sample data.

[0047] In an embodiment of the present application, performing model output anomaly detection on the data to be detected based on the prediction discrimination of the prediction category may include: obtaining multiple second model output values ​​of a preset neural network model for the data to be detected; calculating the difference between the maximum value and the second largest value among the multiple second model output values; judging whether the difference is less than the prediction discrimination of the preset neural network model for the prediction category; and determining that the data to be detected is adversarial sample data when it is judged that the difference is less than the prediction discrimination of the preset neural network model for the prediction category.

[0048] Specifically, when it is determined that the predicted category c of the data to be detected belongs to the sample category, the processor first obtains a plurality of second model output values ​​of the model M for the data to be detected, that is, model output value m+1 model output values, and the predicted discrimination degree D of the model M for the c-th class sample. c Then calculate the difference between the maximum value and the second largest value among the m+1 model output values, and determine whether the difference is less than the prediction discrimination D of the model M for the c-th class sample. c , when the difference is determined to be less than the predicted discrimination D of the model M for the c-th class sample c, the data to be detected is determined to be adversarial sample data, otherwise it is normal data.

[0049] In the embodiment of the present application, the method may further include: when it is determined that the predicted category of the data to be detected does not belong to the sample category, terminating the detection of the data to be detected, and outputting that the security of the data to be detected is unknown.

[0050] Specifically, after the data to be detected is input into the model M, the processor can record the activated neurons in the model M and the predicted category c of the data to be detected, 1≤c≤m+1. The processor first determines whether the predicted category c of the data to be detected belongs to the sample category, which is all the sample categories in the training data set. In the case where it is determined that the predicted category of the data to be detected does not belong to the sample category, it means that the data to be detected does not belong to any of the known m categories. The processor terminates the subsequent detection of the data to be detected and outputs that the security of the data to be detected is unknown.

[0051] An embodiment of the present application provides a processor configured to execute the above-mentioned method for detecting adversarial samples for a neural network model.

[0052] Specifically, in an embodiment of the present application, the processor can be configured to: obtain the neuron output values ​​and model output values ​​corresponding to the sample data of different sample categories in the preset neural network model; determine the invalid neurons and key neurons corresponding to each sample category in the preset neural network model according to the neuron output values; determine the prediction discrimination of the preset neural network model for each sample category according to the model output values; perform adversarial sample detection on the data to be detected based on the invalid neurons, key neurons and model prediction discrimination to determine whether the data to be detected is adversarial sample data.

[0053] In an embodiment of the present application, the processor can also be configured to: for a set of neuron output values ​​of any neuron in any sample category, determine whether the data in the set are all 0; when it is determined that the data in the set are all 0, determine that any neuron is an invalid neuron in the classification task of any sample category; based on all invalid neurons in the sample classification task of any sample category, obtain a set of invalid neurons for any sample category; when it is determined that the data in the set are not 0, determine that any neuron is a key neuron in the classification task of any sample category; based on all key neurons in the sample classification task of any sample category, obtain a set of key neurons for any sample category.

[0054] In an embodiment of the present application, the processor can also be configured to: obtain multiple first model output values ​​of the preset neural network model for any sample in each sample category; determine the predicted discrimination of the preset neural network model for each sample category based on the maximum value and the second largest value among the multiple first model output values.

[0055] In the embodiment of the present application, the prediction discrimination of the neural network model for each sample category satisfies formula (1):

[0056]

[0057] Among them, D i is the predicted discrimination of the preset neural network model for the i-th type of sample; |T i | is the dataset T consisting of samples of the i-th category i The number of samples; The data set T composed of the i-th type of samples for the preset neural network model i The maximum value among the m+1 model output values ​​of the kth sample in ; The data set T composed of the i-th type of samples for the preset neural network model i The second largest value among the m+1 model output values ​​of the kth sample in .

[0058] In an embodiment of the present application, the processor can also be configured to: input the data to be detected into a preset neural network model to obtain the predicted category of the data to be detected, and the neurons activated in the preset neural network model; determine whether the predicted category of the data to be detected belongs to the sample category; when it is determined that the predicted category of the data to be detected belongs to the sample category, perform neuron anomaly detection on the data to be detected based on the invalid neurons, key neurons corresponding to the predicted category, and the neurons activated in the preset neural network model; and perform model output anomaly detection on the data to be detected based on the predicted discrimination of the predicted category.

[0059] In an embodiment of the present application, the processor can also be configured to: determine whether in the classification task of the sample of the prediction category, whether invalid neurons of the invalid neuron set belonging to the prediction category are activated; determine whether in the classification task of the sample of the prediction category, whether key neurons of the key neuron set belonging to the prediction category are not activated; when it is determined that invalid neurons of the invalid neuron set belonging to the prediction category are activated and / or key neurons of the key neuron set belonging to the prediction category are not activated, determine that the data to be detected is adversarial sample data.

[0060] In an embodiment of the present application, the processor can also be configured to: obtain multiple second model output values ​​of the preset neural network model for the data to be detected; calculate the difference between the maximum value and the second largest value among the multiple second model output values; determine whether the difference is less than the predicted discrimination of the preset neural network model for the predicted category; if it is determined that the difference is less than the predicted discrimination of the preset neural network model for the predicted category, determine that the data to be detected is adversarial sample data.

[0061] In the embodiment of the present application, the processor may also be configured to: when it is determined that the predicted category of the data to be detected does not belong to the sample category, terminate the detection of the data to be detected and output that the security of the data to be detected is unknown.

[0062] The above technical scheme obtains the neuron output values ​​and model output values ​​corresponding to the sample data of different sample categories in the preset neural network model, and determines the invalid neurons and key neurons corresponding to each sample category in the preset neural network model according to the neuron output values, and then determines the prediction discrimination of the preset neural network model for each sample category according to the model output value, so as to perform adversarial sample detection on the data to be detected according to the invalid neurons, key neurons and model prediction discrimination, so as to determine whether the data to be detected is adversarial sample data. The present application can detect adversarial samples in real time when the neural network model is running, does not rely on complex prior knowledge of adversarial samples, and the implementation process is simple and easy, which improves the detection efficiency of adversarial samples. In addition, by simultaneously using neuron output analysis and model output analysis for adversarial sample detection, the false negative rate of adversarial sample detection is effectively reduced.

[0063] An embodiment of the present application also provides a machine-readable storage medium having instructions stored thereon, the instructions being used to enable a machine to execute the method for detecting adversarial samples for a neural network model in the above-mentioned embodiment.

[0064] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0065] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0066] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0067] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0068] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0069] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0070] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0071] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0072] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for detecting adversarial examples in a neural network model, characterized in that: include: Obtaining the neuron output values ​​and model output values ​​corresponding to the sample data of different sample categories in the preset neural network model; Determine, according to the neuron output values, the invalid neurons and the key neurons corresponding to each of the sample categories in the preset neural network model; Determining the prediction discrimination of the preset neural network model for each of the sample categories according to the model output value; According to the invalid neurons, the key neurons and the model prediction discrimination, performing adversarial sample detection on the data to be detected to determine whether the data to be detected is adversarial sample data; Wherein, the determining, according to the neuron output values, of the invalid neurons and key neurons respectively corresponding to each of the sample categories in the preset neural network model comprises: for a set of neuron output values ​​of any neuron in any sample category, judging whether the data in the set are all 0; in the case where it is determined that the data in the set are all 0, determining that the arbitrary neuron is an invalid neuron in the classification task of the arbitrary sample category; obtaining the invalid neuron set of the arbitrary sample category according to all the invalid neurons in the sample classification task of the arbitrary sample category; in the case where it is determined that the data in the set are not 0, determining that the arbitrary neuron is a key neuron in the classification task of the arbitrary sample category; obtaining the key neuron set of the arbitrary sample category according to all the key neurons in the sample classification task of the arbitrary sample category; Determining the prediction discrimination of the preset neural network model for each of the sample categories according to the model output value includes: obtaining multiple first model output values ​​of the preset neural network model for any sample in each of the sample categories; determining the prediction discrimination of the preset neural network model for each of the sample categories according to the maximum value and the second maximum value of the multiple first model output values, and the prediction discrimination of the neural network model for each sample category satisfies formula (1): Among them, D i is the predicted discrimination of the preset neural network model for the i-th type of samples; |T i | is the dataset T consisting of samples of the i-th category i The number of samples; The preset neural network model is a data set T composed of samples of the i-th category. i The maximum value among the m+1 model output values ​​of the kth sample in ; The preset neural network model is a data set T composed of samples of the i-th category. i The second largest value among the m+1 model output values ​​of the kth sample in .

2. The method according to claim 1, characterized in that The performing adversarial sample detection on the data to be detected according to the invalid neurons, the key neurons and the model prediction discrimination to determine whether the data to be detected is adversarial sample data includes: Inputting the data to be detected into the preset neural network model to obtain the predicted category of the data to be detected and the activated neurons in the preset neural network model; Determine whether the predicted category of the data to be detected belongs to the sample category; When it is determined that the predicted category of the data to be detected belongs to the sample category, performing neuron anomaly detection on the data to be detected according to the invalid neurons, key neurons corresponding to the predicted category and the activated neurons in the preset neural network model; and Model output anomaly detection is performed on the data to be detected according to the prediction discrimination of the prediction category.

3. The method according to claim 2, characterized in that Performing neuron anomaly detection on the data to be detected according to the invalid neurons, key neurons corresponding to the prediction category and the activated neurons in the preset neural network model includes: Determining whether an invalid neuron of an invalid neuron set belonging to the predicted category is activated in a classification task of the sample of the predicted category; Determine whether, in the classification task of the sample of the predicted category, a key neuron belonging to the key neuron set of the predicted category is not activated; When it is determined that an invalid neuron of an invalid neuron set belonging to the prediction category is activated and / or a key neuron of a key neuron set belonging to the prediction category is not activated, it is determined that the data to be detected is adversarial sample data.

4. The method according to claim 2, characterized in that: Performing model output anomaly detection on the to-be-detected data according to the prediction discrimination of the prediction category includes: Obtaining a plurality of second model output values ​​of the preset neural network model for the data to be detected; Calculate the difference between the maximum value and the second maximum value among the plurality of second model output values; Determining whether the difference is less than the prediction discrimination of the preset neural network model for the prediction category; When it is determined that the difference is less than the prediction discrimination of the preset neural network model for the prediction category, it is determined that the data to be detected is adversarial sample data.

5. The method according to claim 2, characterized in that: The method further comprises: When it is determined that the predicted category of the data to be detected does not belong to the sample category, the detection of the data to be detected is terminated, and it is output that the security of the data to be detected is unknown.

6. A processor, characterized in that: The method is configured to perform the method for detecting adversarial samples for a neural network model according to any one of claims 1 to 5.

7. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores instructions for causing a machine to execute a method for detecting adversarial samples for a neural network model according to any one of claims 1 to 5.