Neural network image classification method based on gated local channel attention
By introducing a gated local channel attention module into the deep convolutional neural network and using a multi-branch structure and 1D convolution kernels of different sizes to generate channel attention weights, the problem of cumbersome 1D convolution kernel size selection in the ECA module is solved. Improves the performance of the network in image classification and target detection tasks, and reduces the need for hyperparameter adjustment.
Patent Information
- Application Number
- CN202111550197.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-17
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-12-17
AI Technical Summary
In deep convolutional neural networks, when the ECA module is used to obtain local channel correlation, the process of selecting the 1D convolution kernel size is cumbersome and requires manual adjustment, resulting in an increase in the number of parameters and excessive consumption of computing resources, making it difficult to introduce too many parameters without introducing too much Improve network expression ability with additional parameters.
The gated local channel attention module is used, and the aggregation module is used to perform global average pooling and multi-branch structures in the excitation module. 1D convolution kernels of different sizes and gated structures are used to generate channel attention weights, reducing the need for hyperparameter adjustment. requirements and improve the performance of the network in image classification and target detection tasks.
It effectively improves the performance of deep convolutional neural networks in image classification and target detection tasks, reduces the need for manual adjustment of hyperparameters, improves the performance of the channel attention module, and controls the consumption of computing resources.
Smart Images

Figure CN114419361B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of neural network and image detection technology, and in particular to a neural network image classification method based on gated local channel attention. Background Art
[0002] Deep convolutional networks have been widely used in the field of image detection. Their greatest advantage and function is that they can effectively extract features from input images and use them in a series of tasks in the field of computer vision, such as image classification and target detection. The performance of the model in these tasks is related to the feature expression ability of the deep convolutional neural network used. People have made many attempts to improve the expression ability of deep convolutional neural networks, such as increasing the depth and width of the network, but this method will increase the number of network parameters and increase the possibility of network overfitting. In order to improve the expression ability of the network without introducing too many additional parameters, people have proposed inserting an attention module into the deep convolutional neural network. Its main function is to obtain information on the spatial dimension or channel dimension from the feature map, and generate a weight matrix with attention information, which is multiplied point by point with the original feature map to complete the reweighting of the original feature map.
[0003] The reweighting in the channel dimension is done by the channel attention module, among which the more representative ones are the SE module (Sequeeze-and-Excitation module) and the ECA module (Efficient Channel Attention module). Taking the SE module as an example, the correlation between channels is learned through aggregation and excitation operations, and a weight vector in the channel dimension is generated to reweight the feature map. As a lightweight module, the SE module can be embedded in the existing deep convolutional network that has been proven to be effective. While introducing fewer parameters, it effectively improves the performance of the backbone network in downstream tasks such as target detection and image classification.
[0004] It is worth emphasizing that the SE module uses a fully connected layer to obtain global channel feature correlation. In the recent work ECANet, a new idea is proposed, that is, using a 1D convolution layer (i.e., a one-dimensional convolution layer, which is different from the traditional two-dimensional convolution layer applied to a three-dimensional feature map, and a one-dimensional convolution is applied to a one-dimensional vector) to obtain local channel correlation. Compared with the SE module, the ECA module introduces fewer parameters, and experiments have also proved that this method of obtaining local channel correlation is also effective enough in image classification and target detection tasks.
[0005] However, for the ECA module, it uses 1D convolution to obtain the correlation between adjacent channels, but the unresolved issue is how to choose the size of the 1D convolution kernel. In computer vision tasks, deeper deep convolutional neural networks are often used, and multiple ECA modules are inserted into various positions of the network. The number of channels of the feature map input to each ECA module is not the same, and manually adjusting the 1D convolution kernel size of each ECA module will bring a huge additional workload.
[0006] In the field of computer vision in recent years, people often use architecture search to solve the problem of adjusting a large number of discrete hyperparameters. The general solution is to build a super network containing multiple network or structure branches, train the entire super network at the same time, and select the output of some networks or structures through certain algorithms to select the best network or structure. Summary of the invention
[0007] In order to overcome the shortcomings of the prior art, the present invention aims to propose a new neural network image classification method to improve the performance of neural networks in image classification and target detection tasks. To this end, the technical solution adopted by the present invention is a neural network image classification method based on gated local channel attention, the steps are as follows:
[0008] Use the front-end deep convolutional network to obtain the feature map of the input image;
[0009] Using an aggregation module to process the feature map, the aggregation module includes an average pooling layer, which performs global average pooling on the input feature map in the spatial dimension to obtain a feature vector containing channel global information;
[0010] The feature vector is processed using an excitation module, which includes a branch structure of n+1 branches, where n branches are used to aggregate local channel correlations to generate channel attention weights, and each branch includes a one-dimensional 1D convolution layer and an S-type Sigmoid activation function, using k i To represent the size of the 1D convolution kernel used in the i-th branch. Here, 1D convolution kernels of different sizes are used to aggregate channel correlation information of different scales. Another branch is used to implement the gating structure. This branch contains a fully connected layer and a normalized exponential function Softmax activation layer, which is used to determine the importance of the output of the other n branches based on the global channel information and generate a re-weighted feature map.
[0011] The reweighted feature map is used as the input of the subsequent deep convolutional network to continue the convolution operation to extract features and complete the image classification and target detection tasks.
[0012] The detailed steps are as follows:
[0013] The input feature map is processed by the average pooling layer to generate a feature vector with the same dimension as the number of channels of the input feature map;
[0014] Take the feature vector as input and process it in n+1 branches at the same time;
[0015] Among them, n branches are responsible for generating local channel correlation attention weights according to the feature vector output by the aggregation module. The specific method is to process the feature vector using a 1D convolution kernel and use the Sigmoid activation function to compress the output to the range of 0-1 as the channel attention weight generated by the branch;
[0016] The branch that implements the gated structure is used to select the other n branches. The specific method is to use the fully connected layer to process the feature vector output by the aggregation module to generate a feature vector with a dimension of n. The value of each element of the feature vector represents the importance of its corresponding branch. The network selects the largest K values, sets the other nK values of the feature vector to negative infinity, and then uses the Softmax activation function to process the processed feature vector to generate a feature vector with a dimension of n as the weight vector of the n branches, where the weights corresponding to the less important nK branches are 0, and the sum of the weights corresponding to the more important K branches is 1;
[0017] The outputs of the n branches are weighted and summed using the weight vector with dimension n to obtain a channel weight vector generated according to the local channel correlation of the feature map;
[0018] The feature vector with the same dimension as the number of channels of the input feature map is dot-producted channel by channel with the feature map output by the convolutional layer of the deep convolutional network preceding the module, which is equivalent to reweighting the deep convolutional neural network in the channel dimension, and a feature map with the same size as the feature map output by the convolutional layer of the deep convolutional network preceding the module is obtained as the output of the training phase of the aggregation and excitation steps.
[0019] The characteristics and beneficial effects of the present invention are:
[0020] The present invention proposes a neural network method based on gated local channel attention for image classification and target detection tasks. By utilizing a constructed gated local channel attention module, the performance of the existing channel attention module is improved, the need for manual adjustment of hyperparameters is reduced, and on this basis, the performance of the deep convolutional neural network using the module in image classification and target detection tasks is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 The structure of the aggregation module in the module of the present invention;
[0022] Figure 2The structure of the excitation module in the module of the present invention;
[0023] Figure 3 This is a schematic diagram of the actual use of the module described in the present invention in the ResNet18 network. DETAILED DESCRIPTION
[0024] The present invention proposes a neural network method based on gated local channel attention for image classification and target detection tasks, constructs a gated local channel attention module, improves the performance of the existing channel attention module, reduces the need for manual adjustment of hyperparameters, and on this basis improves the performance of the deep convolutional neural network using this module in image classification and target detection tasks.
[0025] The core of the neural network method based on gated local channel attention for image classification and target detection tasks described in the present invention is to insert the gated local channel attention module into a specific position of the deep convolutional neural network. The module includes two sub-modules, namely the aggregation module and the excitation module. In actual use, it also involves a deep convolutional network with a front-end module and a deep convolutional network with a back-end module.
[0026] Aggregation modules such as Figure 1 As shown in Figure 1, it contains an average pooling layer. The input of the aggregation module is the feature map output by the convolutional layer of the deep convolutional neural network in front of the module, and the output is a feature vector containing the channel information of the feature map. The feature map as input is globally averaged pooled in the spatial dimension to obtain a feature vector containing the global information of the channel.
[0027] The structure of the excitation module is as follows Figure 2 As shown in Figure 1, its main component is a branch structure consisting of n+1 branches, where n branches are used to aggregate local channel correlations to generate channel attention weights. Each branch contains a 1D convolution layer and a Sigmoid activation function, using k i To represent the size of the 1D convolution kernel used in the i-th branch, 1D convolution kernels of different sizes are used here to gather channel correlation information of different scales. Another branch is used to implement the gating structure, which contains a fully connected layer and a Softmax activation layer to determine the importance of the output of the other n branches based on the global channel information.
[0028] The specific process of operating the input feature map in the local channel attention module of the gated structure proposed in the present invention is as follows:
[0029] 1. The input feature map is processed by the global average pooling layer in the aggregation module to generate a feature vector with the same dimension as the number of channels of the input feature map.
[0030] 2. Take the feature vector output by the aggregation module as input and process it in n+1 branches at the same time.
[0031] 3. Among them, n branches are responsible for generating local channel correlation attention weights based on the feature vector output by the aggregation module. The specific method is to process the feature vector using a 1D convolution kernel and compress the output to the range of 0-1 using the Sigmoid activation function. This is used as the channel attention weight generated by this branch.
[0032] 4. Use the branch that implements the gated structure to select the other n branches. Specifically, use the fully connected layer to process the feature vector output by the aggregation module to generate a feature vector with a dimension of n. The value of each element of the feature vector represents the importance of its corresponding branch. The network selects the largest K values, sets the other nK values of the feature vector to negative infinity, and then uses the Softmax activation function to process the processed feature vector to generate a feature vector with a dimension of n as the weight vector of the n branches, where the weights corresponding to the less important nK branches are 0, and the sum of the weights corresponding to the more important K branches is 1.
[0033] 5. Use the weight vector of dimension n to perform weighted summation on the outputs of the n branches to obtain the channel weight vector generated by the module based on the local channel correlation of the feature map.
[0034] 6. Perform channel-by-channel dot product on the feature vector and the feature map output by the deep convolutional network convolutional layer in front of the module, which is equivalent to reweighting the deep convolutional neural network in the channel dimension, and obtain a feature map with the same size as the feature map output by the deep convolutional network convolutional layer in front of the module, as the output of the local channel attention module described in the present invention in the training stage.
[0035] Such a setting can ensure that the module can obtain local channel correlations at multiple scales to generate channel attention weights, and at the same time only considering the most important k branches can ensure that its computing resource consumption is controlled within a certain range.
[0036] During the use of the neural network method based on gated local channel attention described in the present invention, the reweighted feature map output by the gated local attention module will also be used as the input of the deep convolutional network after the module, and the convolution operation will continue to be performed. Finally, the feature map output by the deep convolutional neural network with the local channel attention module is used to perform image classification and target detection tasks.
[0037] The module described in the present invention can be applied to a variety of backbone networks, so no specific description is given for the deep convolutional network before the module and the deep convolutional network after the module. Now assume that the feature map output by the deep convolutional network before the module is X∈R W×H×C , W and H are the width and height of the feature map, and C is the number of channels of the feature map.
[0038] In the aggregation module, the feature map X is taken as input and processed by the average pooling layer to perform global average pooling on the spatial dimension to obtain the feature vector s∈R C .
[0039] In the excitation module, the input is the feature vector s and the feature map X, where the feature vector s serves as the common input of n branches.
[0040] In the n branches responsible for generating channel attention weights, on each branch i, a step size of 1 is used and a padding of k is used. i / 2, the convolution kernel size is k i The 1D convolution layer is processed to obtain the feature vector that combines the local channel features Then use the Sigmoid activation function of the activation layer to perform the activation operation to obtain ω′ i =σ(ω i ), as the channel attention weight vector generated by this branch.
[0041] In the branch responsible for the gating structure, the feature vector s is processed using a fully connected layer to obtain a vector α=(α1,α2,…,α n ), use the TopK function to operate on α, keep the largest K parameters unchanged, and convert the remaining parameters to negative infinity, and get the vector α′=(α1,-inf,α3…-inf,α n ), where K is a manually set hyperparameter, and then the Softmax function is used to transform α′ into the weight vector corresponding to n branches β = Softmax(α′) = (β1,β2,…,β n ).
[0042] Use the weight vector β to i Perform weighted summation and get As the channel attention weight generated by this module, the weight vector is finally used to reweight the feature map X to obtain As the output of the excitation module in the testing phase.
[0043] The following will describe in more detail the application of the neural network method based on gated local channel attention for image classification and target detection tasks described in the present invention in image classification in conjunction with the accompanying drawings.
[0044] In this example, the dataset ImageNet (a large dataset commonly used in image classification tasks) is used for image classification tasks. When training the network model on the ImageNet dataset, the present invention uses the same data augmentation method as ResNet (residual convolutional network), including random cropping, random horizontal flipping and scaling.
[0045] In this example, the deep convolutional network used as the backbone network is ResNet-18. The uncertainty local channel attention module based on the multi-branch structure described in the present invention is inserted into the residual unit of ResNet-18 to obtain the network structure. For each channel attention module, the part of the deep convolutional network before the module can be abstracted as the "deep convolutional network before the module" of this module. Similarly, the part of the deep convolutional network after the module can be abstracted as the "deep convolutional network after the module" without discussing the specific structure of this part. That is to say, the channel attention module described in the present invention can be applied to any common deep convolutional network.
[0046] In this example, the input of the model is the picture that needs to be classified or detected. The deep convolutional network in front of the module is responsible for feature extraction and generates X∈R W×H×C , the ResNet-18 used in this example has inserted four channel attention modules, corresponding to the four basic convolution blocks of ResNet-18. The input feature map sizes of the four modules are:
[0047] W1=56, H1=56, C1=64;
[0048] W2=28, H2=28, C2=128;
[0049] W3=14, H3=14, C3=256;
[0050] W4=7, H4=7, C4=512;
[0051] In the four input modules corresponding to feature maps of different sizes, the channel attention module based on the gated structure is used to set the number of branches n = 4, and the corresponding convolution kernel size is k 1,2,3,4 =3, 5, 7, 9. The hyperparameter K selected for the gating structure is 1.
[0052] The channel attention module generates a feature map after X-weighting the input feature map It has the same size as X, but has stronger semantic features, so it can replace X and continue to participate in the feature extraction of the deep convolutional network after the module.
[0053] Finally, take the output feature map X( W4=7, H4=7, C4=512) is used as the output of the deep convolutional network.
[0054] In the image classification task, this example uses the Softmax classifier to obtain the classification result from the feature map X.
[0055] In the training phase of the image classification task, this example uses the training set in the ImageNet-1K dataset to train the ResNet-18 network with a local channel attention module based on a gated structure. During the training, the stochastic gradient descent algorithm (SGD) is used to optimize the network model parameters, with the weight decay parameter set to 1e-4, the momentum parameter to 0.9, the training data batch size to 256, the initial learning rate to 0.1, and the learning rate is reduced to 1 / 10 of the original after every 30 training iterations. The model training iterations are 100 times.
[0056] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of the present invention. It should therefore be understood that many modifications may be made to the exemplary embodiments and that other arrangements may be devised without departing from the spirit and scope of the present invention as defined by the appended claims. It should be understood that the different dependent claims and features described herein may be combined in a manner different from that described in the original claims. It will also be understood that the features described in conjunction with the individual embodiments may be used in other described embodiments.
Claims
1. A neural network image classification method based on gated local channel attention, characterized in that the steps as follows: Use the front-end deep convolutional network to obtain the feature map of the input image; Using an aggregation module to process the feature map, the aggregation module includes an average pooling layer, which performs global average pooling on the input feature map in the spatial dimension to obtain a feature vector containing channel global information; The feature vector is processed using an excitation module, which includes a branch structure of n+1 branches, where n branches are used to aggregate local channel correlations to generate channel attention weights, and each branch includes a one-dimensional 1D convolution layer and an S-type Sigmoid activation function, using k i To represent the size of the 1D convolution kernel used in the i-th branch. Here, 1D convolution kernels of different sizes are used to aggregate channel correlation information of different scales. Another branch is used to implement the gating structure. This branch contains a fully connected layer and a normalized exponential function Softmax activation layer, which is used to determine the importance of the output of the other n branches based on the global channel information and generate a re-weighted feature map. The reweighted feature map is used as the input of the subsequent deep convolutional network to continue the convolution operation to extract features and complete the image classification and target detection tasks.
2. The neural network image classification method based on gated local channel attention as claimed in claim 1, characterized in that: The detailed steps are as follows: The input feature map is processed by the average pooling layer to generate a feature vector with the same dimension as the number of channels of the input feature map; Take the feature vector as input and process it in n+1 branches at the same time; Among them, n branches are responsible for generating local channel correlation attention weights according to the feature vector output by the aggregation module. The specific method is to process the feature vector using a 1D convolution kernel and use the Sigmoid activation function to compress the output to the range of 0-1 as the channel attention weight generated by the branch; The branch that implements the gated structure is used to select the other n branches. The specific method is to use the fully connected layer to process the feature vector output by the aggregation module to generate a feature vector with a dimension of n. The value of each element of the feature vector represents the importance of its corresponding branch. The network selects the largest K values, sets the other nK values of the feature vector to negative infinity, and then uses the Softmax activation function to process the processed feature vector to generate a feature vector with a dimension of n as the weight vector of the n branches, where the weights corresponding to the less important nK branches are 0, and the sum of the weights corresponding to the more important K branches is 1; The outputs of the n branches are weighted and summed using the weight vector with dimension n to obtain a channel weight vector generated according to the local channel correlation of the feature map; The feature vector with the same dimension as the number of channels of the input feature map is dot-producted channel by channel with the feature map output by the convolutional layer of the deep convolutional network preceding the module, which is equivalent to reweighting the deep convolutional neural network in the channel dimension, and a feature map with the same size as the feature map output by the convolutional layer of the deep convolutional network preceding the module is obtained as the output of the training phase of the aggregation and excitation steps.
Citation Information
Patent Citations
Image Semantic Segmentation Method Based on Deep Full Convolutional Network and Conditional Random Field
AU2020103901A4
Artistic image classification method based on convolutional neural network
CN110427990A
