A black-box neural network detection method using small amounts of data and adversarial attacks
By constructing multiple alternative networks with different structures and training them using knowledge distillation techniques, the problems of large data requirements and numerous accesses in black-box neural network detection are solved, achieving efficient black-box neural network type detection.
Patent Information
- Application Number
- CN202111424226.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-26
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-11-26
AI Technical Summary
Existing technologies require large datasets and multiple accesses when probing black-box neural networks, leading to difficulties in data collection and high overhead.
Multiple alternative networks with different structures are constructed, and knowledge distillation is used to train the alternative networks to reduce data requirements. Furthermore, the training data is expanded by generating adversarial examples and attack sample sets to reduce the number of times the black-box neural network is accessed.
This method enables the training of high-performance alternative networks with limited data, reducing the number of accesses to black-box neural networks and resource consumption, and improving detection efficiency.
Smart Images

Figure CN114077871B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and further relates to a method for detecting the type of black box neural network using a small amount of data and counterattack in the field of artificial intelligence technology. The present invention can be used to detect the type of black box neural network that only has access rights of a cloud service platform. Background Art
[0002] The use of neural networks has formed a business model. Major IT companies have launched their own platforms to train their own neural networks for data owners who do not have the training capabilities based on their own data and application scenarios, and then open access interfaces for data owners to use. Neural networks are very valuable intellectual property assets in artificial intelligence systems. The leakage of neural networks will not only cause economic losses to the providers, but also cause the leakage of user sensitive information. Therefore, such platforms only allow data owners and other users to access the neural network through interfaces to achieve the purpose of data prediction, and do not provide additional information about the neural network. Therefore, if you want to obtain other information about the neural network, you can only attack the platform.
[0003] Depending on the information the attacker has, the attack methods can be divided into two categories: black-box attack and white-box attack. Both attacks require the attacker to have access to the neural network. When the attacker knows the type and parameters of the attacked neural network, it is a white-box attack, otherwise it is a black-box attack. Because black-box attacks do not require detailed information about the attacked neural network, they only need to submit attack samples to the target neural network and analyze the results given by the neural network to indirectly obtain information about the target neural network, which is more in line with practical applications and is therefore widely used. Therefore, due to the limited information available, if you want to attack the neural network of the neural network service platform, you can only use the black-box attack method.
[0004] Shanghai Guanan Information Technology Co., Ltd. disclosed a method for detecting black-box neural networks based on directed attacks in its patent document "Method, device, processing equipment, and storage medium for exploring black-box neural networks using directed attacks" (patent application number 202110717049.9, application publication number CN113298238 A). The method first selects a data set and selects a trained alternative network based on the data set. Secondly, it determines the directed attack direction for each sample in the selected data set, and then uses one or more directed attack algorithms and multiple alternative networks to generate adversarial samples for each sample to form an adversarial sample set; then, the adversarial sample set is used to attack the alternative network and the black-box neural network to be detected respectively; finally, the parameters and structure of the black-box neural network to be detected are determined by comparing the attack results. The method believes that the closer the attack results are, the more similar their structures and parameters are. However, this method still has two shortcomings: 1) This method selects a trained alternative network based on the selected data set, which requires the selected data set to contain a large amount of data, and data collection is difficult; 2) When this method detects the black-box neural network to be detected, the sample set used contains a large number of samples, and it is necessary to generate adversarial samples for each sample in the sample set to attack the black-box neural network to be detected. The black-box neural network to be detected is visited many times, which is costly. Summary of the invention
[0005] The purpose of the present invention is to address the deficiencies of the above-mentioned prior art and propose a method for detecting black-box neural network types using a small amount of data and adversarial attacks, so as to solve the problems of difficulty in data collection, large number of times of accessing the black-box neural network to be detected during the detection process, and high overhead.
[0006] The specific idea for achieving the purpose of the present invention is: the present invention uses a small number of collected pictures and the corresponding category probability arrays output by the black box neural network to be detected to form a training set. The category probability array output by the black box neural network to be detected can be used to repeatedly use the output of the black box neural network to be detected for the same picture, thereby reducing the number of visits to the black box neural network to be detected and reducing overhead. The present invention constructs multiple alternative networks with different structures of convolutional neural networks, recurrent neural networks, and fully connected networks. The same neural network builds multiple alternative networks with different structures to avoid contingency. The present invention uses knowledge distillation technology when training alternative networks, that is, the category probability array output by the black box neural network to be detected and the category probability array output by the alternative network are used to calculate the loss value of the alternative network, which can significantly reduce the amount of data required to train the alternative network, so the present invention can use a small amount of data to train an alternative network with good performance. The present invention uses the alternative network and the selected algorithm for generating adversarial samples to generate adversarial sample images after each training of the alternative network. After obtaining the category probability array of the black box neural network to be detected for the adversarial sample image, the adversarial sample image and its corresponding category probability array are added to the current training set, the training data set is expanded, the richness of the training data is increased, and the trained alternative network is avoided from overfitting, so that the present invention can train a good performance alternative network based on a small amount of data. The present invention uses the trained alternative network to construct an attack sample set to attack the black box neural network to be detected. When constructing the attack sample set, the pictures selected are pictures that can successfully attack the alternative network. Such pictures are more targeted to the alternative network, and can highlight the difference between the alternative network and the black box neural network to be detected when used to attack the black box neural network to be detected. The present invention also adds the attack sample and its corresponding category probability array to the training set to expand the training set. After all alternative networks generate attack samples and attack the black box neural network to be detected, the present invention determines the type of the black box neural network to be detected by comparing the attack success rate of each type of alternative network.
[0007] The specific steps of the present invention are as follows:
[0008] Step 1: Generate training set:
[0009] (1a) Select at least 500 images to form a dataset, which contains at least three types of images with the same number but different types;
[0010] (1b) All images are resized to 28 × 28 pixels and then normalized;
[0011] (1c) Input each normalized image into the black box neural network to be detected, and output the category probability array corresponding to each image;
[0012] (1d) All normalized images and their corresponding category probability arrays form a training set;
[0013] Step 2, build an alternative network:
[0014] (2a) Build c × k alternative networks, each of which has at least r layers and has a different structure. c represents the type of alternative network, which is usually a convolutional neural network, a recurrent neural network, or a fully connected network. k represents the number of alternative networks of each type. The value of k is determined based on the software and hardware resources of the application environment, k ≥ 3, r ≥ 3.
[0015] (2b) When the alternative network is a convolutional neural network and the input image is a grayscale image, its input dimension is 1, and when it is a color image, the input dimension is 3; when the alternative network is a recurrent neural network and the input image is a grayscale image, its input dimension is 28, and when it is a color image, the input dimension is 84; when the alternative network is a fully connected network and the input image is a grayscale image, its input dimension is 784, and when it is a color image, the input dimension is 2352; the output layer of all alternative networks is a fully connected layer, the activation function is softmax, and the output dimension is equal to the number of image types in the training set;
[0016] Step 3, arbitrarily select an untrained alternative network;
[0017] Step 4: Train the selected alternative network:
[0018] Input the current training set into the selected alternative network, calculate the loss value of the alternative network, and use the back propagation algorithm to update the selected alternative network with the loss value; repeat this process three times to obtain the alternative network after three updates and the average of the loss values of the alternative network when the alternative network is updated three times;
[0019] Step 5: Expand the current training set:
[0020] (5a) Select at least 100 images that can be correctly classified;
[0021] (5b) using the selected images and the updated alternative network, using the adversarial sample generation algorithm to generate noisy adversarial sample images corresponding to each selected image;
[0022] (5c) Input each adversarial sample image into the black box neural network to be detected, and output the category probability array corresponding to the adversarial sample image;
[0023] (5d) Add all adversarial sample images and the category probability array corresponding to each image to the current training set to obtain an updated training set;
[0024] Step 6, determine whether the updated alternative network meets the training termination condition. If so, get the trained alternative network and execute step 7. Otherwise, take the updated training set as the current training set and execute step 4.
[0025] Step 7: Use adversarial attack to detect black box neural network:
[0026] (7a) Select at least 300 images that can be correctly classified;
[0027] (7b) Using the selected images and the trained alternative network, adopt the same method as steps (5b) and (5c) to obtain at least 300 adversarial sample images and a category probability array corresponding to each adversarial sample image; select adversarial sample images that can successfully attack the trained alternative network from all adversarial sample images to form an attack sample set;
[0028] (7c) Input the images in the attack sample set into the black box neural network to be detected in sequence, and output the category probability array corresponding to the attack sample;
[0029] (7d) Dividing the total number of images that can successfully attack the black-box neural network to be detected by the total number of images in the attack sample set that can successfully attack the trained alternative network, obtains the attack success rate of the attack sample set;
[0030] Step 8: Expand the current training set again:
[0031] Add the attack sample set and the category probability array corresponding to each image output by the black box neural network to be detected to the training set updated in step (5d) to obtain a further updated training set;
[0032] Step 9, determine whether all alternative networks have been selected. If so, execute step 10. Otherwise, use the updated training set as the current training set to execute step 3.
[0033] Step 10: Determine the type of black box neural network to be detected:
[0034] The attack success rates of the trained alternative networks of the same type in the alternative network are added together, and the type of the alternative network corresponding to the largest value is used as the type of the black box neural network to be detected.
[0035] Compared with the prior art, the present invention has the following advantages:
[0036] First, the present invention forms a training set with all normalized images and their corresponding category probability arrays, and uses the category probability array output by the black-box neural network to be detected, so as to reuse the output of the black-box neural network to be detected for the same image, reduce the number of visits to the black-box neural network to be detected, and reduce the overhead, thus overcoming the shortcomings of the prior art of visiting the black-box neural network to be detected many times and having high overhead, so that the present invention has the advantages of visiting the black-box neural network to be detected less times and consuming less resources.
[0037] Second, the present invention adds all adversarial sample images and the category probability array corresponding to each image to the current training set to obtain an updated training set, thereby increasing the richness of the training data and avoiding overfitting of the trained alternative network. This overcomes the defect of the difficulty in collecting data in the prior art, and enables the present invention to train an alternative network with good performance using a small amount of data. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0039] Reference Figure 1 The steps for implementing the present invention are further described in detail with reference to the accompanying drawings and embodiments.
[0040] Step 1: Generate a training set.
[0041] In the embodiment of the present invention, 500 pictures are selected to form a data set, and the data set contains 50 pictures of 10 different types.
[0042] The images used in the embodiment of the present invention are a subset of the public dataset mnist, which is a grayscale image with a size of 28×28 pixels. j =a j / 255 to normalize the image, where a j is the jth picture in the dataset.
[0043] An embodiment of the present invention uses the MNIST data set to train a 10-layer convolutional neural network as a black box neural network to be detected, and its structure is: a first convolutional layer, a first pooling layer, a second convolutional layer, a second pooling layer, a third convolutional layer, a third pooling layer, a fourth convolutional layer, a fifth convolutional layer, a fourth pooling layer, and a fully connected layer; the input dimensions of the first to fifth convolutional layers are set to 1, 64, 128, 256 and 512, respectively, the convolution kernel size is set to 3×3, the edge padding is set to 1, the sliding step is set to 1, the activation function is ReLU, and the output dimensions are set to 64, 128, 256, 512 and 512, respectively; the pooling windows of the first to fourth pooling layers are set to 2×2, and the sliding step is set to 2; the input dimension of the fully connected layer is set to 512, the output dimension is set to 10, and the activation function is softmax.
[0044] Input each normalized image into the black box neural network to be detected, and output the probability array of the category corresponding to each image.
[0045] The category probability array corresponding to the image refers to the calculation made by the black box neural network to be detected on the possibility that the image belongs to each category. The sum of all elements of the array is 1. In the embodiment of the present invention, the array contains 10 elements.
[0046] All normalized images and their corresponding category probability arrays form a training set.
[0047] The category probability array corresponding to the image refers to the calculation made by the black box neural network to be detected on the possibility that the image belongs to each category. The sum of all elements of the array is 1. In the embodiment of the present invention, the array contains 10 elements.
[0048] Step 2: The embodiment of the present invention constructs nine alternative networks.
[0049] Build a five-layer convolutional neural network with the following structure: first convolutional layer, first pooling layer, second convolutional layer, second pooling layer, fully connected layer; set the input dimensions of the first and second convolutional layers to 1 and 64 respectively, the convolution kernel size to 3×3, the edge padding to 1, the sliding step size to 1, the activation function to ReLU, and the output dimensions to 64 and 128 respectively; the pooling windows of the first and second pooling layers are both 2×2; the input dimension of the fully connected layer is set to 6272, the output dimension is set to 10, and the activation function is softmax.
[0050] Build a seven-layer convolutional neural network with the following structure: first convolutional layer, second convolutional layer, first pooling layer, third convolutional layer, fourth convolutional layer, second pooling layer, fully connected layer; set the input dimensions of the first to fourth convolutional layers to 1, 64, 64 and 128 respectively, the convolution kernel size is set to 3×3, the edge padding is set to 1, the sliding step is set to 1, the activation function is ReLU, and the output dimensions are set to 64, 64, 128 and 128 respectively; the pooling windows of the first and second pooling layers are both 2×2, and the sliding step is set to 2; the input dimension of the fully connected layer is set to 6272, the output dimension is set to 10, and the activation function is softmax.
[0051] Build a ten-layer convolutional neural network, whose structure is as follows: the first convolutional layer, the first pooling layer, the second convolutional layer, the second pooling layer, the third convolutional layer, the third pooling layer, the fourth convolutional layer, the fifth convolutional layer, the fourth pooling layer, and the fully connected layer; the input dimensions of the first to fifth convolutional layers are set to 1, 64, 128, 256 and 512 respectively, the convolution kernel size is set to 3×3, the edge padding is set to 1, the sliding step is set to 1, the activation function is ReLU, and the output dimensions are set to 64, 128, 256, 512 and 512 respectively; the pooling windows of the first to fourth pooling layers are set to 2×2, and the sliding step is set to 2; the input dimension of the fully connected layer is set to 512, the output dimension is set to 10, and the activation function is softmax.
[0052] Build a recurrent neural network consisting of a first simple recurrent neural network layer, a second simple recurrent neural network layer, and a fully connected layer. Set the input dimensions of the first and second simple recurrent neural network layers to 28 and 128 respectively, and the output dimensions are both set to 128; the input dimension of the fully connected layer is set to 128, and the output dimension is set to 10. The activation function is softmax.
[0053] Build a recurrent neural network consisting of a first long short-term memory unit layer, a second long short-term memory unit layer, and a fully connected layer. Set the input dimensions of the first and second long short-term memory unit layers to 28 and 128 respectively, and the output dimensions are both set to 128; the input dimension of the fully connected layer is set to 128, the output dimension is set to 10, and the activation function is softmax.
[0054] Build a recurrent neural network consisting of a first gating unit layer, a second gating unit layer, and a fully connected layer. Set the input dimensions of the first and second gating unit layers to 28 and 128 respectively, and the output dimensions to 128; the input dimension of the fully connected layer is set to 128, the output dimension is set to 10, and the activation function is softmax.
[0055] Build a fully connected network consisting of three fully connected layers in series. Set the input dimensions of the first to third fully connected layers to 784, 256, and 128, and the output dimensions to 256, 128, and 10, respectively. The activation functions of the first and second fully connected layers are both ReLU, and the activation function of the third fully connected layer is softmax.
[0056] Build a fully connected network consisting of four fully connected layers in series. Set the input dimensions of the first to fourth fully connected layers to 784, 256, 128, and 64, and the output dimensions to 256, 128, 64, and 10, respectively. The activation functions of the first to third fully connected layers are all ReLU, and the activation function of the fourth fully connected layer is softmax.
[0057] Build a fully connected network consisting of five fully connected layers in series. Set the input dimensions of the first to fifth fully connected layers to 784, 256, 128, 64, and 32, and the output dimensions to 256, 128, 64, 32, and 10, respectively. The activation functions of the first to fourth fully connected layers are all ReLU, and the activation function of the fifth fully connected layer is softmax.
[0058] Step 3: arbitrarily select an untrained alternative network.
[0059] Step 4: train the selected alternative network.
[0060] Input the current training set into the selected alternative network, calculate the loss value of the alternative network, and use the back propagation algorithm to update the selected alternative network with the loss value; repeat this process three times to obtain the alternative network after three updates and the average of the loss values of the alternative network when the alternative network is updated three times.
[0061] The loss value of the alternative network is, using the formula Calculate the loss value of the current alternative network for each image in the current training set each time the alternative network is updated, and take the sum of the loss values of all images as the loss value of the alternative network for the current training set, where: represents the loss value of the current alternative network for the i-th image when the alternative network is updated for the yth time, ∑ represents the summation operation, P i y Indicates that when the replacement network is updated for the yth time, the category probability array corresponding to the i-th picture in the current training set of the current replacement network is input, It represents the category probability array of the i-th image output by the current alternative network when the alternative network is updated for the yth time, y=1,2,3; i=1,2,3...w, and the value of w is the total number of images in the current training set.
[0062] The category probability array corresponding to the picture refers to the picture being input into a neural network, which calculates the possibility of the picture belonging to each category, and the sum of all elements of the array is 1. In the embodiment of the present invention, the array contains 10 elements.
[0063] Step 5: Expand the current training set.
[0064] In the first step, the embodiment of the present invention selects 100 pictures that can be correctly classified.
[0065] The picture that can be correctly classified refers to inputting the training set into the current replacement network to determine whether the category with the highest probability in the category probability array output by the network is the same as the category with the highest probability in the category probability array corresponding to the picture in the training set. If so, the picture is a picture that can be correctly classified, otherwise, it is a picture that cannot be correctly classified.
[0066] In the second step, the selected images and the updated alternative network are used to generate noisy adversarial sample images corresponding to each selected image using the adversarial sample generation algorithm.
[0067] The adversarial sample generation algorithm refers to an algorithm selected from the existing white-box adversarial sample generation algorithm and the existing black-box adversarial sample generation algorithm based on access network output, according to the hardware and software resources of the application environment and the requirements for the attack success rate.
[0068] The third step is to input each adversarial sample image into the black box neural network to be detected, and output the category probability array corresponding to the adversarial sample image.
[0069] The category probability array corresponding to the adversarial sample image refers to the calculation made by the network on the possibility of the image belonging to each category when the image is input into the black box neural network to be detected. The sum of all elements of the array is 1. In the embodiment of the present invention, the array contains 10 elements.
[0070] The fourth step is to add all adversarial sample images and the category probability array corresponding to each image to the current training set to obtain the updated training set.
[0071] The category probability array corresponding to the adversarial sample image refers to the calculation made by the network on the possibility of the image belonging to each category when the image is input into the black box neural network to be detected. The sum of all elements of the array is 1. In the embodiment of the present invention, the array contains 10 elements.
[0072] Step 6, determine whether the updated alternative network meets the training termination condition. If so, obtain the trained alternative network and execute step 7. Otherwise, use the updated training set as the current training set and execute step 4.
[0073] The training termination condition refers to that the difference between the mean values of the two loss values after two training of the replacement network is less than 0.05.
[0074] Step 7: Use adversarial attack method to detect black box neural network.
[0075] The embodiment of the present invention selects 300 pictures that can be correctly classified.
[0076] The picture that can be correctly classified refers to inputting the training set into the current replacement network to determine whether the category with the highest probability in the category probability array output by the network is the same as the category with the highest probability in the category probability array corresponding to the picture in the training set. If so, the picture is a picture that can be correctly classified, otherwise, it is a picture that cannot be correctly classified.
[0077] Using the selected images and the trained alternative network, the same method as the second and third steps in step 5 is used to obtain 300 adversarial sample images and the category probability array corresponding to each adversarial sample image; from all adversarial sample images, select adversarial sample images that can successfully attack the trained alternative network to form an attack sample set.
[0078] The adversarial sample images that can successfully attack the trained alternative network refer to determining whether the category with the highest probability in the category probability array of each adversarial sample image is the same as the category with the highest probability in the category probability array corresponding to the unnoised image in the training set. If so, it is determined to be an adversarial sample image that cannot successfully attack the alternative network. Otherwise, it is determined to be an adversarial sample image that can successfully attack the alternative network.
[0079] The images in the attack sample set are input into the black box neural network to be detected one by one, and the category probability array corresponding to the attack sample is output.
[0080] The category probability array corresponding to the adversarial sample image refers to the calculation made by the network on the possibility of the image belonging to each category when the image is input into the black box neural network to be detected. The sum of all elements of the array is 1. In the embodiment of the present invention, the array contains 10 elements.
[0081] The total number of images that can successfully attack the black-box neural network to be detected is divided by the total number of images in the attack sample set that can successfully attack the trained alternative network to obtain the attack success rate of the attack sample set.
[0082] The picture that can successfully attack the black box neural network to be detected refers to determining whether the category with the highest probability in the category probability array corresponding to the attack sample output by the black box neural network to be detected is the same as the category with the highest probability in the category probability array corresponding to the unnoised picture corresponding to the picture in the training set. If so, it is determined to be a picture that cannot successfully attack the black box neural network to be detected; otherwise, it is determined to be a picture that can successfully attack the black box neural network to be detected.
[0083] Step 8: Expand the current training set again.
[0084] Add the attack sample set and the category probability array corresponding to each image output by the black box neural network to be detected to the training set updated in the fourth step of step 5 to obtain a training set that has been updated again.
[0085] Step 9, determine whether all alternative networks have been selected. If so, execute step 10. Otherwise, execute step 3 using the updated training set as the current training set.
[0086] Step 10, determine the type of black box neural network to be detected.
[0087] The attack success rates of the trained alternative networks of the same type in the alternative network are added together, and the type of the alternative network corresponding to the largest value is used as the type of the black box neural network to be detected.
Claims
1. A method for detecting black box neural network types using small amounts of data and adversarial attacks, characterized in that: A substitute network is trained using a small amount of data and knowledge distillation technology, and after each training of the substitute network, the substitute network is used to generate adversarial samples to expand the training set; the steps of this method include the following: Step 1: Generate training set: (1a) Select at least 500 images to form a dataset, which contains at least three types of images with the same number but different types; (1b) All images are resized to 28 × 28 pixels and then normalized; (1c) Input each normalized image into the black box neural network to be detected, and output the category probability array corresponding to each image; (1d) All normalized images and their corresponding category probability arrays form a training set; Step 2, build an alternative network: (2a) Build c × k alternative networks, each of which has at least r layers and has a different structure. c represents the type of alternative network, which can be any of the three types of convolutional neural network, recurrent neural network, and fully connected network. k represents the number of alternative networks of each type. The value of k is determined according to the software and hardware resources of the application environment, k ≥ 3, r ≥ 3. (2b) When the alternative network is a convolutional neural network and the input image is a grayscale image, its input dimension is 1, and when it is a color image, the input dimension is 3; when the alternative network is a recurrent neural network and the input image is a grayscale image, its input dimension is 28, and when it is a color image, the input dimension is 84; when the alternative network is a fully connected network and the input image is a grayscale image, its input dimension is 784, and when it is a color image, the input dimension is 2352; the output layer of all alternative networks is a fully connected layer, the activation function is softmax, and the output dimension is equal to the number of image types in the training set; Step 3, arbitrarily select an untrained alternative network; Step 4: Train the selected alternative network: Input the current training set into the selected alternative network, calculate the loss value of the alternative network, and use the back propagation algorithm to update the selected alternative network with the loss value; repeat this process three times to obtain the alternative network after three updates and the average of the loss values of the alternative network when the alternative network is updated three times; Step 5: Expand the current training set: (5a) Select at least 100 images that can be correctly classified; (5b) using the selected images and the updated alternative network, using the adversarial sample generation algorithm to generate noisy adversarial sample images corresponding to each selected image; (5c) Input each adversarial sample image into the black box neural network to be detected, and output the category probability array corresponding to the adversarial sample image; (5d) Add all adversarial sample images and the category probability array corresponding to each image to the current training set to obtain an updated training set; Step 6, determine whether the updated alternative network meets the training termination condition. If so, get the trained alternative network and execute step 7. Otherwise, take the updated training set as the current training set and execute step 4. Step 7: Use adversarial attack to detect black box neural network: (7a) Select at least 300 images that can be correctly classified; (7b) Using the selected images and the trained alternative network, adopt the same method as steps (5b) and (5c) to obtain at least 300 adversarial sample images and a category probability array corresponding to each adversarial sample image; select adversarial sample images that can successfully attack the trained alternative network from all adversarial sample images to form an attack sample set; (7c) Input the images in the attack sample set into the black box neural network to be detected in sequence, and output the category probability array corresponding to the attack sample; (7d) Dividing the total number of images that can successfully attack the black-box neural network to be detected by the total number of images in the attack sample set that can successfully attack the trained alternative network, obtains the attack success rate of the attack sample set; Step 8: Expand the current training set again: Add the attack sample set and the category probability array corresponding to each image output by the black box neural network to be detected to the training set updated in step (5d) to obtain a further updated training set; Step 9, determine whether all alternative networks have been selected. If so, execute step 10. Otherwise, use the updated training set as the current training set and execute step 3. Step 10: Determine the type of black box neural network to be detected: The attack success rates of the trained alternative networks of the same type in the alternative network are added together, and the type of the alternative network corresponding to the largest value is used as the type of the black box neural network to be detected.
2. The method for detecting black box neural network types using a small amount of data and adversarial attacks according to claim 1, characterized in that: The loss value of the alternative network described in step 4 refers to the loss value of Formula, calculate the loss value of the current alternative network for each image in the current training set each time the alternative network is updated, and the sum of the loss values of all images is used as the loss value of the alternative network for the current training set, where, represents the loss value of the current alternative network for the i-th image when the alternative network is updated for the yth time, ∑ represents the summation operation, P i y Indicates that when the replacement network is updated for the yth time, the category probability array corresponding to the i-th picture in the current training set of the current replacement network is input, It represents the category probability array of the i-th image output by the current alternative network when the alternative network is updated for the yth time, y=1,2,3; i=1,2,3...w, and the value of w is the total number of images in the current training set.
3. The method for detecting black box neural network types using a small amount of data and adversarial attacks according to claim 1, characterized in that: The correctly classified pictures described in step (5a) and step (7a) refer to inputting the training set into the current replacement network, and determining whether the category with the highest probability in the category probability array output by the network is the same as the category with the highest probability in the category probability array corresponding to the picture in the training set. If so, the picture is a picture that can be correctly classified, otherwise, it is a picture that cannot be correctly classified.
4. The method for detecting black box neural network types using a small amount of data and adversarial attacks according to claim 1, characterized in that: The training termination condition described in step 6 refers to the difference between the mean of the two loss values after training the replacement network twice is less than 0.
05.
5. The method for detecting black box neural network types using a small amount of data and adversarial attacks according to claim 1, characterized in that: The adversarial sample images that can successfully attack the trained alternative network described in step (7b) refer to determining whether the category with the highest probability in the category probability array of each adversarial sample image is the same as the category with the highest probability in the category probability array corresponding to the unnoised image in the training set. If so, it is determined to be an adversarial sample image that cannot successfully attack the alternative network. Otherwise, it is determined to be an adversarial sample image that can successfully attack the alternative network.
6. The method for detecting black box neural network types using a small amount of data and adversarial attacks according to claim 1, characterized in that: The image that can successfully attack the black-box neural network to be detected in step (7d) refers to determining whether the category with the highest probability in the category probability array corresponding to the attack sample output by the black-box neural network to be detected is the same as the category with the highest probability in the category probability array corresponding to the unnoised image corresponding to the image in the training set. If so, it is determined to be an image that cannot successfully attack the black-box neural network to be detected; otherwise, it is determined to be an image that can successfully attack the black-box neural network to be detected.
