Neural network architecture construction and training method and system for image classification

The search space is built through the DARTS algorithm and PGD adversarial attack training is used to automatically design a lightweight CNN architecture, solving the robustness of the image recognition model under adversarial samples, and achieving efficient deployment and accurate classification on mobile devices.

CN116758325BActive Publication Date: 2025-08-29ZHEJIANG LAB +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310065582.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-16
Publication Date
2025-08-29
Estimated Expiration
2043-01-16

AI Technical Summary

Technical Problem

Existing image recognition CNN models are not robust enough when facing adversarial samples, and the model size is too large to be deployed on mobile devices. The existing combination of adversarial training and model compression techniques rely on the quality of pre-designed CNN architecture, resulting in unstable performance.

Method used

The search space is constructed using the DARTS algorithm, the architecture parameters are updated through unbiased estimators, the lightweight CNN architecture is generated, and the PGD adversarial attack method is used for training, and a neural network with high accuracy and robustness is automatically designed.

Benefits of technology

A lightweight CNN architecture is built that can accurately classify in the presence of adversarial samples, is suitable for mobile devices, without relying on manual experience, and has higher recognition accuracy and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116758325B_ABST
    Figure CN116758325B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for constructing and training a neural network architecture for image classification, wherein the construction and training method comprises obtaining a search space and assigning a weight to each search unit thereof to form a supernet; using an image classification training set to train and update the trainable weights in the supernet; training and updating the trainable weights in the trained supernet, and after each update of the trainable weights, updating the architecture parameters according to the unbiased estimators of all search units; selecting the search unit corresponding to the maximum value of all architecture parameters of each edge in the search space and storing them in a unit set; traversing the search units in the unit set, and adding the search units whose model parameters do not exceed a set threshold to the architecture to form a neural network architecture; connecting multiple neural network architectures to form an image classification neural network, and training the image classification neural network; inputting a collected classification image into the trained image classification neural network, and outputting the category of the classified image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image classification, and in particular to a method and system for constructing and training a neural network architecture for image classification. Background Art

[0002] Deep neural networks (DNNs), represented by convolutional neural networks (CNNs), have been applied to a variety of image-related scenarios in everyday life, such as facial recognition systems in access control systems, license plate recognition systems in traffic monitoring, and camera-based object recognition systems in mobile phones. However, current research shows that most image recognition CNNs used in real-world scenarios lack robustness and are susceptible to adversarial examples, leading to incorrect judgments and posing security risks. An adversarial example is an image generated by modifying some pixels of the original input image. For example, in a license plate recognition system, if a digit in a license plate is partially obscured by black stains, some pixels in the input image will be altered (the area obscured by the stains) compared to the original, unobstructed license plate. Such adversarial examples can easily cause the license plate recognition system to misjudge the image.

[0003] In order to make CNNs used for image recognition more robust and thus more accurately classify such adversarial examples, the current mainstream technology is to use adversarial training methods to train CNNs, thereby making CNNs more robust. Adversarial training refers to a method of training CNNs after generating adversarial examples using a specific algorithm. However, existing research shows that if a robust CNN is obtained through adversarial training, a larger CNN is usually required for training. For example, on MNIST, the simplest handwritten digit classification dataset for machine learning, to obtain a robust CNN, the number of parameters within the network must be about four times larger than that of a CNN that only needs to perform normal classification tasks. However, the excessive size of the CNN model makes it impossible to deploy it on mobile devices such as cameras, affecting normal use.

[0004] To obtain a robust and lightweight CNN model, existing technical solutions mainly combine adversarial training with model compression technology, making the CNN model lightweight while improving its robustness. In this type of method, the model compression technology used is mainly divided into two categories: model pruning and model quantization. Among them, for the first category, model pruning refers to a method that evaluates the importance of the internal weights of the CNN and eliminates redundant and non-critical weights, so that only the important weights are retained. This type of method can significantly reduce the size of the model by pruning the model weights. For the second category, model quantization is used. Model quantization refers to a technology that reduces the precision of the parameters in the model and then experiments with model compression.

[0005] However, these approaches, which combine adversarial training with model compression, also have drawbacks. They rely on a pre-designed CNN architecture to function, and their effectiveness is heavily dependent on the quality of this pre-designed CNN architecture. In other words, if the CNN architecture is designed by experienced domain experts and offers excellent performance, then adversarial training and model compression will yield good performance. Conversely, if the CNN architecture is poorly designed, then performance after adversarial training and model compression will be suboptimal. Summary of the Invention

[0006] In response to the above-mentioned deficiencies in the prior art, the present invention provides a method and system for constructing and training a neural network architecture for image classification, which solves the problem of poor robustness of neural networks for image classification in the prior art.

[0007] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:

[0008] In a first aspect, this solution provides a method for constructing and training a neural network architecture for image classification, which includes the following steps:

[0009] S1. Obtain the search space in the DARTS algorithm and assign a weight to each search unit in the search space to form a supernet;

[0010] S2. Obtain an image classification training set, input the image classification training set into the supernet, and use the image classification training set to train and update the trainable weights in the supernet;

[0011] S3. Use the optimizer to train and update the trainable weights in the trained supernet. After updating the trainable weights in each search cycle, update the architecture parameters based on the unbiased estimators of all search units.

[0012] S4. For each edge in the search space, select the search unit corresponding to the maximum value among all its architectural parameters and store it in the unit set;

[0013] S5, traverse each search unit in the unit set, add the search units whose model parameters do not exceed the set threshold into the architecture, and obtain the final neural network architecture after the traversal is completed;

[0014] S6. Connect multiple neural network architectures to form an image classification neural network, and train the image classification neural network using the image classification training set and the PGD adversarial attack method;

[0015] S7. Input the collected classification image into the trained image classification neural network, and output the category of the classification image.

[0016] The beneficial effects of the present invention are as follows: this scheme adopts the unbiased estimator of the search unit for updating, which can ensure that the search unit selected by the architecture parameters has high accuracy and robustness, thereby ensuring the construction of a robust and lightweight CNN architecture, satisfying the requirement of including as many high-value search units as possible in the architecture while achieving the lightweight architecture, making the architecture easier to deploy on mobile devices.

[0017] The neural network architecture obtained by this solution does not need to rely on manual experience to build the neural network model. The automatically designed model also has higher recognition accuracy, better robustness and better meets the needs of lightweight architecture compared to the manually designed model.

[0018] The CNN architecture found by the algorithm proposed in this solution is lightweight, making it more suitable for deployment on mobile devices such as cameras. Because these mobile devices often have limited computing resources and cannot deploy models with large parameters, the CNN architecture found in this solution is more suitable for such application scenarios.

[0019] The trained neural network from this approach can maintain high image recognition accuracy while accurately identifying anomalies. Because the network architecture found in this approach is robust, it can accurately classify images even in the presence of adversarial examples.

[0020] Furthermore, the calculation formula for updating the architecture parameters is:

[0021]

[0022] Among them, α k and α k-1 are the architecture parameters of the kth and k+1th search cycles respectively; η is the step size of each update of the architecture parameters; V k and V k-1are the vectors consisting of the values ​​of all search units in the supernet in the kth and k+1th search cycles respectively; ||V k || is V k The second norm value of ; ψ is the momentum parameter; is the trainable parameter ω in the k-th search cycle k Updated and architecture parameter α k-1 Unbiased estimator of the value of all search units in the supernet when not updated.

[0023] The beneficial effect of this technical solution is that it iteratively updates the architecture parameters by directly using the values ​​of all search units in the supernet, as evaluated during each search cycle. This ensures that the architecture parameters obtained are directly related to the values ​​of the search units and can be used as a direct basis for selection. Furthermore, the momentum update method employed during the search process facilitates faster and more effective convergence of the architecture parameters.

[0024] Furthermore, the value of the search unit is calculated as:

[0025]

[0026]

[0027]

[0028] in, Search unit o (i,j) The value of; N is the number of all search units in the search space; N! is the number of all possible addition orders of all search units; is the set of all possible joining orders of all search units; p is a permutation order among all possible permutations; and Under p, search unit o respectively (i,j) The contribution to the accuracy and robustness of the supernet; A(·) is the accuracy of the supernet; R(·) is the adversarial robustness of the supernet; p(pre(o (i,j) )) is the search unit o in p (i,j) Previous search unit; p(pre(o (i,j) )U{o (i,j)}) is the search unit o in the array p (i,j) Previous search unit and search unit o (i,j) A sequence that together constitutes.

[0029] The beneficial effect of the above technical solution is: the value calculation method of the search unit in the search space proposed in this solution can accurately calculate the value of each search unit to the architectural accuracy and architectural robustness, so that the architecture finally searched can contain as many high-value search units as possible, thereby achieving good accuracy and robustness.

[0030] Furthermore, the unbiased estimator of the value of the search unit is calculated as:

[0031]

[0032] Among them, p1, p2, ..., p n are n permutations drawn from all N! possible permutations; Search unit o (i,j) An unbiased estimator of the value of ; t is any of the n permutations;

[0033] Unbiased estimator of the value of all search units for:

[0034]

[0035] in, and Search unit o1 (0,1) , o m (0,1) , o1 (i,j) , and o m (i,j) Unbiased estimator of value.

[0036] The beneficial effect of the above technical solution is: this solution can significantly reduce the huge time overhead incurred when building a neural network by searching for an unbiased estimator of the unit value to approximate its value, thereby shortening the time cost of building the neural network.

[0037] Furthermore, between step S4 and step S5 of this solution, the search units in the unit set are sorted according to the size of their architecture parameters. Sorting the search units before traversal can significantly reduce the traversal time and further shorten the network architecture construction time.

[0038] Furthermore, the image classification training set is a data set containing a large number of face images for a face recognition system or a data set containing a large number of license plate images for a vehicle license plate recognition system in traffic monitoring.

[0039] Furthermore, the method of training the image classification neural network using the image classification training set and the PGD adversarial attack method includes:

[0040] Randomly initialize the weights of the neural network model;

[0041] In each training cycle, the PGD adversarial attack method is used to add perturbations to the original training images in the image classification training set to generate adversarial samples;

[0042] The neural network model is trained using adversarial samples, and the optimizer is used to update the weights of the neural network in each training cycle until the number of training cycles meets the preset number, at which point the training stops.

[0043] The beneficial effect of the above technical solution is that this solution trains the neural network model by generating adversarial samples, which can enable the trained neural network to have more accurate classification capabilities for such adversarial samples, thereby further improving the accuracy and robustness of the neural network model.

[0044] Secondly, this solution also provides a neural network architecture construction and training system for image classification, which includes:

[0045] The supernet generation module is used to obtain the search space in the DARTS algorithm and assign a weight to each search unit in the search space to form a supernet;

[0046] A supernet pre-training module is used to obtain an image classification training set, input the image classification training set into the supernet, and use the image classification training set to train and update the trainable weights in the supernet;

[0047] An architecture parameter update module is used to train and update the trainable weights in the trained supernet using an optimizer. After updating the trainable weights in each search cycle, the architecture parameters are updated based on the unbiased estimators of all search units.

[0048] A search unit selection module is used to select the search unit corresponding to the maximum value of all its architectural parameters for each edge in the search space and store it in a unit set;

[0049] The network architecture building module is used to traverse each search unit in the unit set, add the search units whose model parameters do not exceed the set threshold into the architecture, and obtain the final neural network architecture after the traversal is completed;

[0050] A neural network training module is used to connect multiple neural network architectures to form an image classification neural network, and train the image classification neural network using an image classification training set and the PGD adversarial attack method;

[0051] The image classification module is used to input the collected classification images into the trained image classification neural network and output the category of the classified images. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 Flowchart of the methodology for building and training a neural network architecture for image classification.

[0053] Figure 2 Schematic diagram of the search space structure. DETAILED DESCRIPTION

[0054] The specific embodiments of the present invention are described below to facilitate understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the appended claims, these changes are obvious, and all inventions and creations utilizing the concepts of the present invention are protected.

[0055] refer to Figure 1 , Figure 1 A flowchart of a neural network architecture construction and training method for image classification is shown; Figure 1 As shown, the method S includes steps S1 to S7.

[0056] In step S1, the search space in the DARTS algorithm is obtained, and a weight is assigned to each search unit in the search space to form a supernet; in order to facilitate the understanding of the search space, the following is combined with Figure 2 The search space example is given to illustrate:

[0057] The search space structure of this scheme consists of nodes and edges. The search space contains two input nodes, four intermediate nodes and one output node. For convenience, Figure 2 The output nodes are omitted in the search space structure shown. For each edge in the search space, Figure 2 As shown by the edge (0, 3) in the figure, each edge contains five types of candidate operations, namely, separable convolution (Sep conv), dilated convolution (Dil conv), skip connection (Skip), maximum pooling (Maxpool), and average pooling (Avg pool).

[0058] This solution represents the search space as a set of search units, that is, S = {o (i ,j)} o∈o,(i,j)∈E , where S stands for Figure 2 The search space shown in ,o (i,j) Represents a search unit (such as Figure 2 (shown as the five search units between nodes 0 and 3 in the figure), o represents the operations contained in the search unit, and (i, j) represents the edges of the search unit (e.g. Figure 2(0, 3) in ), O and E represent the set of all types of operations and all existing edges in the search space respectively.

[0059] In step S2, an image classification training set is obtained, the image classification training set is input into the supernet, and the trainable weights in the supernet are trained and updated using the image classification training set; the image classification training set is a data set containing a large number of face images for a face recognition system (such as colorFERET, MTFL, etc.) or a data set containing a large number of license plate images for a vehicle license plate recognition system in traffic monitoring (such as the CCPD data set, etc.).

[0060] In step S3, the trainable weights in the trained supernet are trained and updated using an optimizer. After updating the trainable weights in each search cycle, the architecture parameters are updated based on the unbiased estimators of all search units.

[0061] In step S2 and step S3, the trainable weights may be trained and updated using an SGD optimizer or an Adam optimizer.

[0062] During implementation, the calculation formula for updating the architecture parameters of this solution is as follows:

[0063]

[0064] Among them, α k and α k-1 are the architecture parameters of the kth and k+1th search cycles respectively; η is the step size of each update of the architecture parameters; V k and V k-1 are the vectors consisting of the values ​​of all search units in the supernet in the kth and k+1th search cycles respectively; ||V k || is V k The second norm value of ; ψ is the momentum parameter; is the trainable parameter ω in the k-th search cycle k Updated and architecture parameter α k-1 Unbiased estimator of the value of all search units in the supernet when not updated.

[0065] The calculation formula for the value of the search unit is:

[0066]

[0067]

[0068]

[0069] in, Search unit o (i,j)The value of; N is the number of all search units in the search space; N! is the number of all possible addition orders of all search units; is the set of all possible joining orders of all search units; p is a permutation order among all possible permutations; and Under p, search unit o respectively (i,j) The contribution to the accuracy and robustness of the supernet; A(·) is the accuracy of the supernet; R(·) is the adversarial robustness of the supernet; p(pre(o (i,j) )) is the search unit o in p (i,j) Previous search unit; p(pre(o (i,j) )∪{o (i,j)}) is the search unit o in the array p (i,j) Previous search unit and search unit o (i,j) A sequence that together constitutes.

[0070] The unbiased estimator of the value of a search unit is given by:

[0071]

[0072] Among them, p1, p2, ..., p n are n permutations drawn from all N! possible permutations; Search unit o (i,j) An unbiased estimator of the value of ; t is any of the n permutations;

[0073] Unbiased estimator of the value of all search units for:

[0074]

[0075] in, and Search unit o1 (0,1) , o m (0,1) , o1 (i,j) , and o m (i,j) Unbiased estimator of value.

[0076] In step S4, for each edge in the search space, the search unit corresponding to the maximum value among all its architectural parameters is selected and stored in the unit set;

[0077] In step S5, each search unit in the unit set is traversed, and the search units whose model parameters do not exceed the set threshold are added to the architecture. After the traversal is completed, the final neural network architecture is obtained; the model parameter refers to the number of trainable weights in the supernet.

[0078] This solution preferably further includes sorting the search units in the unit set according to the size of their architecture parameters between step S4 and step S5. By sorting and then traversing, the traversal time can be greatly shortened.

[0079] In step S6, multiple neural network architectures are connected to form an image classification neural network, and the image classification training set and the PGD adversarial attack method are used to train the image classification neural network. The training method is:

[0080] Randomly initialize the weights of the neural network model;

[0081] In each training cycle, the PGD adversarial attack method is used to add perturbations to the original training images in the image classification training set to generate adversarial samples;

[0082] The neural network model is trained using adversarial samples, and the optimizer is used to update the weights of the neural network in each training cycle until the number of training cycles meets the preset number, at which point the training stops.

[0083] In step S7, the collected classification image is input into the trained image classification neural network, and the category of the classification image is output.

[0084] This solution also provides a neural network architecture construction and training system for image classification, which includes:

[0085] The supernet generation module is used to obtain the search space in the DARTS algorithm and assign a weight to each search unit in the search space to form a supernet;

[0086] A supernet pre-training module is used to obtain an image classification training set, input the image classification training set into the supernet, and use the image classification training set to train and update the trainable weights in the supernet;

[0087] An architecture parameter update module is used to train and update the trainable weights in the trained supernet using an optimizer. After updating the trainable weights in each search cycle, the architecture parameters are updated based on the unbiased estimators of all search units.

[0088] A search unit selection module is used to select the search unit corresponding to the maximum value of all its architectural parameters for each edge in the search space and store it in a unit set;

[0089] The network architecture building module is used to traverse each search unit in the unit set, add the search units whose model parameters do not exceed the set threshold into the architecture, and obtain the final neural network architecture after the traversal is completed;

[0090] A neural network training module is used to connect multiple neural network architectures to form an image classification neural network, and train the image classification neural network using an image classification training set and the PGD adversarial attack method;

[0091] The image classification module is used to input the collected classification images into the trained image classification neural network and output the category of the classified images.

[0092] The following compares the searched network architecture with the existing model and evaluates its performance:

[0093] A. Dataset Construction and Evaluation Indicators

[0094] We used CIFAR-10, CIFAR-100, and Tiny-ImageNet, two widely used benchmark datasets in image classification, as experimental datasets to validate the accuracy and robustness of the network architecture we discovered. These datasets contain images from 10, 100, and 200 categories, respectively. The CIFAR-10 and CIFAR-100 datasets consist of 50,000 training images and 10,000 test images, each with a 32×32 pixel size. The Tiny-ImageNet dataset consists of 100,000 training images and 10,000 test images, each with a 64×64 pixel size.

[0095] When the searched network architecture is used in actual scenarios, for example, when it is deployed in traffic cameras to recognize license plates, the dataset used is a dataset containing a large number of license plate images; when it is deployed in cameras in access control systems to perform face recognition, the dataset used is a dataset containing a large number of face images.

[0096] B. Algorithm parameter settings

[0097] During architecture search, we set the search epoch count to 60, including 15 epochs in step S2 and 45 epochs in step S3. During this training phase, the architecture parameters need to be updated simultaneously. The trainable weights in the supernet are updated using the SGD optimizer with a learning rate of 0.1, momentum of 0.9, and weight decay of 0.0003. ψ is 0.2, and η is 0.1.

[0098] C. Comparison of results

[0099] On three benchmark datasets, we evaluated the model size (measured by the number of parameters), accuracy, and robustness of the searched architectures (the accuracy of the models was evaluated under the conditions of FGSM, PGD, and C&W adversarial attacks. Adversarial attacks are a general term for algorithms that add perturbations to the input data to test the robustness of the model). The evaluation results are shown below:

[0100] Table 1 Evaluation results on the CIFAR-10 dataset

[0101]

[0102] Table 2 Evaluation results on the CIFAR-100 dataset

[0103]

[0104]

[0105] Table 3 Evaluation results on the Tiny-ImageNet dataset

[0106]

[0107] As can be seen from the experimental results in Tables 1-3 (the best results are shown in bold), the network architecture searched by the algorithm proposed in this solution has a smaller number of parameters than the compared architectures, and better meets the requirements for model size on mobile devices; at the same time, the network architecture searched by the algorithm proposed in this solution also has higher accuracy and robustness for image classification after training than the compared architectures.

Claims

1. A neural network architecture construction and training method for image classification, characterized by: Including steps: S1. Obtain the search space in the DARTS algorithm and assign a weight to each search unit in the search space to form a supernet; S2. Obtain an image classification training set, input the image classification training set into the supernet, and use the image classification training set to train and update the trainable weights in the supernet; S3. Use the optimizer to train and update the trainable weights in the trained supernet. After updating the trainable weights in each search cycle, update the architecture parameters based on the unbiased estimators of all search units. The calculation formula for updating the architecture parameters is: , in, and Respectively k and k - 1 search cycle for architectural parameters; is the step size for updating the architecture parameters each time; and Respectively k and k - A vector consisting of the values ​​of all search units in the supernet during one search cycle; for The two-norm value of ; is the momentum parameter; For the k In the search cycle, the trainable parameters Updated and schema parameters Unbiased estimator of the value of all search units in the supernet when not updated; The value of a search unit is calculated as: in, Search unit the value of N is the number of all search units in the search space; The number of all possible join orders for all search units; is the set of all possible joining orders of all search units; p is one of all possible permutations; and Respectively in p Next, search for the unit For contributions to the accuracy and robustness of SuperNet; is the accuracy of the supernet; For the adversarial robustness of the supernet; For Ranking in search unit Previous search unit; For arrangement Ranking in search unit Previous Search Unit vs. Search Unit a sequence of components; S4. For each edge in the search space, select the search unit corresponding to the maximum value among all its architectural parameters and store it in the unit set; S5, traverse each search unit in the unit set, add the search units whose model parameters do not exceed the set threshold into the architecture, and obtain the final neural network architecture after the traversal is completed; S6. Connect multiple neural network architectures to form an image classification neural network, and train the image classification neural network using the image classification training set and the PGD adversarial attack method; S7. Input the collected classification image into the trained image classification neural network, and output the category of the classification image.

2. The method for constructing and training a neural network architecture for image classification according to claim 1, characterized in that: The unbiased estimator of the value of a search unit is given by: in, For all Extracted from the possible permutations n permutations; Search unit An unbiased estimator of the value of ; t for n Any of the permutations; Unbiased estimator of the value of all search units for: in, 、 、 and Search Unit , , ,as well as Unbiased estimator of value.

3. The method for constructing and training a neural network architecture for image classification according to claim 1, wherein: Between step S4 and step S5, the step further includes sorting the search units in the unit set according to the sizes of their architecture parameters.

4. The method for constructing and training a neural network architecture for image classification according to claim 1, wherein: The image classification training set is a data set containing a large number of face images used in a face recognition system or a data set containing a large number of license plate images used in a vehicle license plate recognition system in traffic monitoring.

5. The method for constructing and training a neural network architecture for image classification according to any one of claims 1 to 4, characterized in that: Methods for training image classification neural networks using image classification training sets and PGD adversarial attack methods include: Randomly initialize the weights of the neural network model; In each training cycle, the PGD adversarial attack method is used to add perturbations to the original training images in the image classification training set to generate adversarial samples; The neural network model is trained using adversarial samples, and the optimizer is used to update the weights of the neural network in each training cycle until the number of training cycles meets the preset number, at which point the training stops.

Citation Information

Patent Citations

  • Embedded target detection model generation method based on multi-target neural network search

    CN113283426A