Model construction method based on iterative re-parameterization and network architecture search
By employing iterative reparameterization and network architecture search methods, we extend and select multi-branch structures for lightweight neural networks, solving the problems of high computational cost and accuracy bottlenecks. This achieves both accuracy improvement and speed maintenance, making it suitable for deployment in vision tasks on embedded devices.
Patent Information
- Application Number
- CN202410845592.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-09-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing lightweight neural network models suffer from high computational cost, poor hardware adaptability, and accuracy bottlenecks on embedded devices, making them particularly difficult to deploy in applications with high real-time requirements, such as autonomous driving.
We employ iterative reparameterization and network architecture search to extend the baseline network into a multi-branch structure. We then select and merge branch networks through path sampling training and network architecture search, and combine structural reparameterization techniques to optimize the model structure to improve accuracy and maintain inference speed.
It effectively improves model accuracy while maintaining the original inference speed, enhances the model's applicability on embedded devices, and is suitable for backbone network deployment for various vision tasks.
Smart Images

Figure CN118657199A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of deep learning technology, and specifically relates to a model construction method based on iterative reparameterization and network architecture search. Background Art
[0002] In recent years, with the continuous development of deep learning technology, the application field of neural network models has become wider and wider, which has greatly promoted industrial production and daily life conditions. However, neural network models will always encounter various practical problems when they are finally deployed. For example, the on-board visual recognition system of autonomous driving has extremely high real-time requirements, and the resources on embedded devices are limited, which puts forward requirements for model size and computing power. Therefore, it is necessary to design a lightweight neural network model to meet the needs of practical deployment.
[0003] The backbone networks of current lightweight neural networks can be roughly divided into two categories: transformer and convolutional neural network (CNN). Although the transformer-based model has higher accuracy, the computational complexity of the self-attention module is quadratic with the input image size, and the hardware adaptability is relatively poor, so it often faces the problem of slow speed. Although the CNN network is more hardware-friendly and has better adaptability, it has certain accuracy bottlenecks. Summary of the invention
[0004] In order to overcome the shortcomings of the prior art, the present invention provides a model construction method based on iterative reparameterization and network architecture search, firstly, the baseline network is expanded to obtain a multi-branch network that can be reparameterized and merged; next, the expanded baseline network is trained; then the trained branch network is selected using the network architecture search method; then the searched branch network is merged using the structural reparameterization method; finally, it is determined whether to continue training; if the network accuracy has not been improved within 5 consecutive rounds of training, the training ends, otherwise it continues to repeat. The present invention can solve the problem of convergence of the final effect during multi-branch network training, thereby combining the accuracy improvement with the characteristics of retaining the original structure of the model by structural reparameterization to the greatest extent, and enhancing its practicality.
[0005] The technical solution adopted by the present invention to solve the technical problem is as follows:
[0006] Step 1: Expand the baseline network to obtain a multi-branch network that can be reparameterized and merged;
[0007] Take each KxK convolution as the main branch and expand it into a four-way multi-branch structure, including 1x1 convolution, 1x1 convolution followed by KxK convolution, 1x1 convolution followed by average pooling, and KxK convolution, where K is the size of the convolution kernel; and connect a BN layer after each convolution and pooling layer; then initialize the weights of the newly expanded branches and keep the weights of the original main branches unchanged;
[0008] Step 2: Train the expanded baseline network;
[0009] Path sampling is added during training, that is, n branches are randomly selected each time for forward and backward propagation and gradient update;
[0010] The training process is:
[0011] The public image classification dataset is used as the training set input to the expanded baseline network for forward propagation. When encountering the branch structure constructed in step 1, n branches including the trunk branch are randomly selected to continue forward propagation. After that, the network output is compared with the true value of the annotation of the image classification dataset to calculate the loss, and then the parameters are updated through backpropagation, and iterated for multiple rounds until convergence.
[0012] Step 3: Use the network architecture search method to select the trained branch network;
[0013] Traverse different branch combinations and test their accuracy on the test set of the public dataset, and select the branch combination with the highest accuracy;
[0014] Step 4: Merge the branch networks obtained in step 3 using the method of structural reparameterization; first, unify the convolution kernels in each branch into the same size by padding them with zeros, then merge the batch normalization layer into the convolution layer, merge an unbiased convolution kernel and batch normalization into a biased convolution kernel, and finally add the parameters of each convolution kernel to obtain a completely equivalent single-channel structure; merge a four-way multi-branch module into a single-channel KxK convolution module;
[0015] Step 5: Determine whether to continue training;
[0016] If the network accuracy does not improve within 5 consecutive rounds of training, end the training, otherwise continue to step 1.
[0017] Preferably, the baseline network is a lightweight image classification model implemented based on CNN, including MobileNet, MobileOne and shuffleNet.
[0018] Preferably, the public image classification dataset is a training set of ImageNet-1k.
[0019] Preferably, n=2.
[0020] The beneficial effects of the present invention are as follows:
[0021] The present invention proposes a model design method that is widely applicable, can effectively improve accuracy and retain the original reasoning speed of the model. It combines structural reparameterization with network architecture search technology to solve the problem of convergence of final effects during multi-branch network training, and automatically selects branches that can effectively improve accuracy through network architecture search, thereby combining the accuracy improvement with the characteristics of structural reparameterization retaining the original structure of the model to the greatest extent, enhancing its practicality. In addition, the model finally obtained can be used as the backbone network of various visual tasks and deployed on various downstream tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flow chart of the method of the present invention.
[0023] Figure 2 It is a schematic diagram of merging a four-way multi-branch structure into a single-branch structure. DETAILED DESCRIPTION
[0024] The present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0025] In order to improve the accuracy of the existing CNN-based lightweight neural network and obtain better results in actual deployment, the present invention provides a model construction method based on iterative reparameterization and network architecture search, which specifically includes:
[0026] According to the specific business scenario, select a suitable lightweight CNN-based baseline model, which can be MobileNet, MobileOne, etc.
[0027] To build a corresponding structural reparameterization model based on this model, you can refer to the DiverseBranch Block (DBB). Here, you need to design a variety of branches to make the final captured features more distinct.
[0028] Initialize the newly created branches in the re-parameterized model, and then train the entire neural network end-to-end. Path sampling (drop path) is required during training, which can be referred to in the proxylessNAS article. This prevents different branches from being affected by the same gradient backpropagation during training and becoming similar, further enhancing the diverse feature representation between branches. At the same time, because only a few random paths are activated in one forward propagation and backpropagation, the video memory usage and computing power overhead during training are reduced.
[0029] Then, we perform a network architecture search (NAS) on the trained model to select useful branches for merging. The general structure reparameterization method has bottlenecks in improving accuracy. The reasons include that training multiple branches together leads to the gradual convergence of branches. In addition, not every feature representation in each branch is useful. If some branches representing redundant features are merged into the trunk indiscriminately, the accuracy improvement will quickly saturate. Therefore, the network architecture search method is introduced here to search for the optimal network including branches, which can effectively improve accuracy.
[0030] The searched branch network is then merged into the main network using the structural reparameterization method to obtain a concise network with the same structure as the baseline network. The branches are then expanded again, and training and searching are continued. This allows the accuracy improvement brought by multi-branch networks to be maximized by structural reparameterization network training, and finally an inference model with the same structure as the baseline network can be obtained, taking into account both speed and accuracy.
[0031] Example:
[0032] The present invention proposes a model construction method based on iterative reparameterization and network architecture search, such as Figure 1 As shown, the method comprises the following steps:
[0033] Step 101, expand the baseline network to obtain a multi-branch network that can be re-parameterized and merged. The baseline network must be a lightweight image classification model based on CNN, such as MobileNet, MobileOne, shuffleNet, and the specific network is specified by the user. In the process of expanding the convolutional layer of the baseline network, branch diversity is required. For example, a 3x3 convolution kernel can be expanded into a network module with n 3x3, 1x1, 3x1, 1x3, average pooling (Avgpooling), and skip connection (skipconnection) branches, and batch normalization (Batch Normalization, BN) is added to each branch. Here, refer to the multi-branch module DBB, and expand each KxK convolution into a four-way multi-branch structure, including 1x1 convolution, 1x1 convolution followed by KxK convolution, 1x1 convolution followed by average pooling, and KxK convolution, where K is the size of the convolution kernel. And a BN layer is connected after each convolution and pooling layer, such as Figure 2 As shown in Figure 2. This increases the capacity of the network and the diversity of feature representation during training. Then, the weights of the newly expanded branches are initialized, and the weights of the original trunk branches are kept unchanged.
[0034] Step 102, train the expanded network. For the multi-branch structure, in order to make the difference of feature representation between branches more obvious, so as to improve the accuracy after the final merger, path sampling (drop path) is added during training, that is, n branches are randomly selected each time for forward and backward propagation and gradient update. This can not only prevent the same gradient backpropagation from making the feature representation between different branches converge when multiple branches are trained simultaneously, but also effectively reduce the memory usage and computing power overhead during training. Therefore, the specific training process is to first input the public image classification dataset, such as the training set of ImageNet-1k, into the network for forward propagation. When encountering the branch structure constructed in step 101, two branches including the trunk branch are randomly selected to continue forward propagation (n=2). The trunk branch here is the branch expanded in step 101. Then, the output of the network is compared with the true value of the annotation of the image classification dataset, such as ImageNet-1k, and the parameters are updated by backpropagation, and iterate for multiple rounds until convergence.
[0035] Step 103, use the network architecture search method to select the trained branch network. Here, the search and training have been completely decoupled. It is only necessary to traverse different branch combinations and test their accuracy on the test set of public data sets (such as ImageNet-1k), and select the branch combination with the highest accuracy. In this way, by adding the selection of branches instead of direct merging, redundant branches can be effectively eliminated, making the feature representation obtained by the final merger more effective for improving accuracy, and further improving the upper limit of accuracy that can be achieved by the structural reparameterization method.
[0036] Step 104, merge the branch networks searched in step 103 using the method of structural reparameterization. The specific merging method can refer to the multi-branch module DBB. First, the convolution kernels in each branch are unified into the same size by padding with zeros, then the batch normalization layer is integrated into the convolution layer, and an unbiased convolution kernel and batch normalization are merged into a biased convolution kernel. Finally, the parameters of each convolution kernel are added to obtain a completely equivalent single-channel structure. The effect of branch merging is as follows: Figure 2 As shown in Figure 1, a four-way multi-branch module is merged into a single KxK convolution module, where K is the size of the convolution kernel.
[0037] Step 105, determine whether to continue training. If the network accuracy does not improve within 5 consecutive rounds of training, the training ends, otherwise continue to step 101. This is an iterative reparameterization method that can maximize the accuracy improvement brought by the multi-branch network while keeping the original structure of the model unchanged during inference.
Claims
1. A model construction method based on iterative reparameterization and network architecture search, characterized in that: The steps include: Step 1: Expand the baseline network to obtain a multi-branch network that can be reparameterized and merged; Take each KxK convolution as the main branch and expand it into a four-way multi-branch structure, including 1x1 convolution, 1x1 convolution followed by KxK convolution, 1x1 convolution followed by average pooling, and KxK convolution, where K is the size of the convolution kernel; and connect a BN layer after each convolution and pooling layer; then initialize the weights of the newly expanded branches and keep the weights of the original main branches unchanged; Step 2: Train the expanded baseline network; Path sampling is added during training, that is, n branches are randomly selected each time for forward and backward propagation and gradient update; The training process is: The public image classification dataset is used as the training set input to the expanded baseline network for forward propagation. When encountering the branch structure constructed in step 1, n branches including the trunk branch are randomly selected to continue forward propagation. After that, the network output is compared with the true value of the annotation of the image classification dataset to calculate the loss, and then the parameters are updated through backpropagation, and iterated for multiple rounds until convergence. Step 3: Use the network architecture search method to select the trained branch network; Traverse different branch combinations and test their accuracy on the test set of the public dataset, and select the branch combination with the highest accuracy; Step 4: Merge the branch networks obtained in step 3 using the method of structural reparameterization; first, unify the convolution kernels in each branch into the same size by padding them with zeros, then merge the batch normalization layer into the convolution layer, merge an unbiased convolution kernel and batch normalization into a biased convolution kernel, and finally add the parameters of each convolution kernel to obtain a completely equivalent single-channel structure; merge a four-way multi-branch module into a single-channel KxK convolution module; Step 5: Determine whether to continue training; If the network accuracy does not improve within 5 consecutive rounds of training, end the training, otherwise continue to step 1.
2. A model construction method based on iterative reparameterization and network architecture search according to claim 1, characterized in that: The baseline network is a lightweight image classification model based on CNN, including MobileNet, MobileOne and shuffleNet.
3. The model construction method based on iterative reparameterization and network architecture search according to claim 1, characterized in that: The public image classification dataset is the training set of ImageNet-1k.
4. The model construction method based on iterative reparameterization and network architecture search according to claim 1, characterized in that: Said n=2.
Citation Information
Patent Citations
Method for recognizing pedestrians by selecting hyper-parameters in parallel and designing multi-branch convolutional neural network
CN111582094A
Parameter-free automatic adaptive method of pre-training neural network based on re-parameterization
CN114821270A
Infrared ship target detection method based on improved yolov7
CN117152691A
Twin network target tracking method and system capable of re-parameterizing multi-branch convolution
CN117197490A
Lightweight anti-interference real-time target detection network design method
CN118171427A
