Complementary attention dynamic convolution method for image classification

By introducing global and local attention branches and weighted fusion modules in convolutional neural networks, the convolution nucleus for dynamic convolution is generated, solving the problem of static convolution methods that are difficult to integrate image global and local characteristics, and improve the image classification Mission performance.

CN119360184APending Publication Date: 2025-01-24BAOJI UNIV OF ARTS & SCI
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411618141.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

The existing static convolution method is difficult to effectively integrate the global and local features of the image, and the computational overhead is high, which limits the performance of convolutional neural networks when processing complex image tasks.

Method used

Put forward a complementary dynamic convolution method. By introducing global and local attention branches to generate different focus characteristic charts, it integrates it through the weighted fusion module to generate the convolution nuclear for dynamic convolutional volume nuclei Essence

Benefits of technology

A more effective features are achieved that it can better integrate global and local characteristics and improve the performance of convolutional neural networks in image classification tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119360184A_ABST
    Figure CN119360184A_ABST
Patent Text Reader

Abstract

The invention discloses a complementary attention dynamic convolution method for image classification, and belongs to the technical field of artificial intelligence and computer vision. The method comprises the following steps: S1, data set preparation and training environment setting, S2, network layer structure replacement, S3, attention branch input: image data to be classified are respectively input into two attention branches, each attention branch independently processes an input image, and attention feature maps with different emphasis are generated; the invention provides a new dynamic convolution method which is complementary attention dynamic convolution, and the dynamic convolution method comprises the following steps: S1, dynamic convolution, S2, dynamic convolution, S4, weighted fusion, S5, dynamic convolution and S6, classification processing and output. According to the method, features captured by global and local attention branches are used at the same time and pooled in two directions to extract the features, statistical information of a feature map is fully utilized, convolution kernels with specific spatial positions and specific channel domains are generated, and therefore better feature representation is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence and computer vision technology, and more specifically, to a complementary attention dynamic convolution method for image classification. Background Art

[0002] In the field of artificial intelligence and computer vision technology, Convolutional Neural Networks (CNNs) have become the mainstream method. The convolution operation is the basic building block in convolutional neural networks. Thanks to its simple representation and efficient implementation, the effectiveness of convolutional neural networks has been recognized. In a convolution layer, the convolution operation is calculated by applying the same convolution kernel to each input sample to obtain an output. We call such a convolution a standard convolution or static convolution. In CNN, features are extracted by stacking multiple convolution layers. Such a fixed static convolution kernel is difficult to adapt to the diverse structural information in the image, especially difficult to process complex, high-dimensional image data.

[0003] The static convolution method has two major defects: the ability to integrate global and local features is weak, and the computational overhead is high. Therefore, many improved convolution methods have been proposed to address the defects of static convolution. One of the research hotspots is dynamic convolution. Dynamic convolution adaptively generates convolution kernels based on input data, eliminating the content-independent characteristics of static convolution. In addition, the use of dynamic convolution methods also improves the performance of convolutional neural networks.

[0004] The basic idea of ​​dynamic convolution is to replace the static convolution kernel with a combination of multiple convolution kernels of the same dimension, and the coefficient before each convolution kernel weight is the scalar attention generated by the input-related attention module. However, most of the existing dynamic convolution methods only focus on extracting channel domain features or spatial domain features, and have limitations in extracting image features. For example, it is impossible to flexibly adjust its key focus for different input images or different areas in the image, which limits the performance of CNN in processing complex image tasks. Summary of the invention

[0005] The object of the present invention is to provide a complementary attention dynamic convolution method for image classification to solve the problems raised in the above background technology:

[0006] To achieve the above object, the present invention provides the following technical solutions:

[0007] A complementary attention dynamic convolution method for image classification, comprising the following steps:

[0008] S1. Dataset preparation and training environment setup: Prepare a dataset for image classification, determine the convolutional neural network for training, and set the training framework and key parameters in the training process;

[0009] S2, network layer structure replacement: replace part of the network layer structure in the selected convolutional neural network to obtain a new convolutional neural network;

[0010] S3, attention branch input: two attention branches are introduced into the new convolutional neural network, and the image data to be classified are input into the two attention branches respectively. Each attention branch processes the input image independently to generate two attention feature maps with different focuses; the two attention branches are the global attention branch and the local attention branch;

[0011] S4, weighted fusion: The two attention feature maps are taken as input and sent to the weighted fusion module. The weighted fusion module puts in the fusion strategy according to the preset and performs weighted fusion on the two attention feature maps;

[0012] S5, dynamic convolution: based on the output of the weighted fusion module, generate a convolution kernel for complementary attention dynamic convolution, apply the generated dynamic convolution kernel to the input image or the intermediate feature map in the network, and perform a dynamic convolution operation;

[0013] S6, classification processing and output: The feature map after dynamic convolution processing is input into the network layer composed of FC fully connected layer and Softmax to perform the final image classification and finally output the classification result of the image.

[0014] Preferably, in step S1, key parameters in the training process include the number of training rounds and the optimizer type;

[0015] The datasets are CIFAR-10, CIFAR-100, and Mini-ImageNet;

[0016] Convolutional neural networks include ResNet series, GoogLeNet, and ShuffleNetV2;

[0017] The pytorch framework was selected as the training framework, the NVIDIA RTX8000 graphics card was used, the number of training rounds was 150, and the SGD stochastic gradient descent optimizer was selected as the optimizer.

[0018] Preferably, the network layer structure replacement includes:

[0019] S2.1 In the ResNet network, the Basic Block consists of two layers of 3×3 convolutions. The convolution kernel size in the complementary attention dynamic convolution is set to 3, replacing the second 3×3 convolution in the Basic Block;

[0020] S2.2 In the ShuffleNetV2 network, the basic unit consists of three layers of convolution, namely 1×1 convolution, 3×3 separable convolution, and 1×1 convolution. The convolution kernel size of the complementary attention dynamic convolution is set to 3, replacing the separable convolution.

[0021] S2.3 In GoogLeNet, the core structure consists of four branches, one of which has 3×3 convolutions. The convolution kernel size of the complementary attention dynamic convolution is set to 3, replacing all 3×3 convolutions in the branch.

[0022] Preferably, the global attention branch input includes S3.1 inputting the picture into the global attention branch and S3.2 inputting the picture into the global attention branch.

[0023] Preferably, S3.1 inputting the picture into the global attention branch includes:

[0024] S3.1.1. For each image of input size C×H×W, pooling is performed in the horizontal and vertical directions respectively to obtain two features of shape C×H×1 and C×1×W;

[0025] S3.1.2, perform one-bit convolution on the two features obtained in step S3.1.1, respectively, and then perform GroupNorm group normalization and Sigmoid activation function to obtain two features with shapes of C×H×1 and C×1×W;

[0026] S3.1.3, multiply the two features obtained in step S3.1.2 element by element to obtain a feature with a shape of C×H×W;

[0027] S3.1.4. Multiply the features obtained in step S3.1.3 by the original image element by element to obtain a feature with a shape of C×H×W as the output result of the global branch.

[0028] Preferably, S3.2 inputting the image into the local attention branch includes:

[0029] S3.2.1 For each image of input size C×H×W, channel average pooling and channel standard deviation pooling are calculated in the channel dimension respectively, and two features with shapes of 1×H×W and 1×H×W are obtained;

[0030] S3.2.2 concatenates the two features obtained in step S3.2.1 along the channel dimension to obtain a feature with a shape of 2×H×W;

[0031] S3.2.3 Perform 1×1 convolution on the features obtained in step S3.2.2 to reduce the dimension of the channel. The shape of the features after dimension reduction is 1×H×W;

[0032] S3.2.4 The features obtained in step S3.2.3 are subjected to BatchNorm batch normalization and Sigmoid activation function. At this time, the feature shape is still 1×H×W;

[0033] S3.2.5 multiplies the feature obtained in step S3.2.4 by the original image element by element to obtain a feature with a shape of C×H×W as the output result of the local branch.

[0034] Preferably, weighted fusion includes:

[0035] S4.1 performs an unfold operation on the results of step 3.1.4 and step 3.2.5 respectively to generate a convolution kernel;

[0036] S4.2 performs weighted fusion on the two types of convolution kernels generated in step S4.1, and respectively adds and multiplies the two types of convolution kernels element by element;

[0037] S4.3 passes the result of step S4.2 through a tanh activation function so that each parameter in the convolution kernel is fixed in the range of [-1, 1].

[0038] Preferably, the dynamic convolution comprises:

[0039] S5.1 uses the output of step S4.3 as the dynamically generated convolution kernel.

[0040] S5.2 performs a convolution operation on the convolution kernel generated in step S5.1 and the original input image to perform dynamic convolution.

[0041] Preferably, the classification processing and output is to input the result after the dynamic convolution in step S5.2 into the next network layer composed of a fully connected layer and a Softmax layer to perform the final image classification.

[0042] Compared with the prior art, the present invention has the following beneficial effects:

[0043] This paper proposes a new dynamic convolution method, called complementary attention dynamic convolution. By using the features captured by both the global and local attention branches at the same time, pooling in two directions to extract features, and making full use of the statistical information of the feature map, a spatial position-specific and channel-domain-specific convolution kernel is generated, thereby achieving better feature representation. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 The overall architecture diagram of the complementary attention dynamic convolution method;

[0045] Figure 2 Architectural details of the complementary attention dynamic convolution method. DETAILED DESCRIPTION

[0046] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0047] Example:

[0048] See also Figure 1-2 , a complementary attention dynamic convolution method for image classification, comprising the following steps:

[0049] Step S1, data set preparation and training environment setting: prepare a data set for image classification, determine the convolutional neural network for training, set the training framework, select and configure the graphics card device to be used, and set the key parameters in the training process, including the number of training rounds and optimizer type.

[0050] Among them, the data sets are CIFAR-10, CIFAR-100, and Mini-ImageNet; the convolutional neural networks are ResNet series, GoogLeNet, and ShuffleNetV2; the training framework selects the pytorch framework, uses the NVIDIA RTX8000 graphics card, the number of training rounds is 150, and the optimizer selects the SGD stochastic gradient descent optimizer.

[0051] Step S2, network layer structure replacement: In the selected convolutional neural network, replace part of the network layer structure to obtain a new convolutional neural network.

[0052] Specifically, the network layer structure is replaced by the following steps:

[0053] S2.1 In the ResNet network, the Basic Block consists of two layers of 3×3 convolutions. The convolution kernel size in the complementary attention dynamic convolution is set to 3, replacing the second 3×3 convolution in the Basic Block;

[0054] S2.2 In the ShuffleNetV2 network, the basic unit consists of three layers of convolution, namely 1×1 convolution, 3×3 separable convolution, and 1×1 convolution. The convolution kernel size of the complementary attention dynamic convolution is set to 3, replacing the separable convolution.

[0055] S2.3 In GoogLeNet, the core structure consists of four branches, one of which has 3×3 convolutions. The convolution kernel size of the complementary attention dynamic convolution is set to 3, replacing all 3×3 convolutions in the branch.

[0056] Step S3, attention branch input: two attention branches are introduced into the new convolutional neural network to optimize the network's ability to extract images, and the image data to be classified are input into the two attention branches respectively. Each attention branch processes the input image independently to obtain attention feature maps with different focuses; the two attention branches are global attention branches and local attention branches; the two attention branch inputs include S3.1 inputting the image into the global attention branch and S3.2 inputting the image into the local attention branch. By introducing the global attention mechanism and the local attention mechanism, the focus can be dynamically adjusted during the feature extraction process, so that the model can pay more attention to the key areas and key channels in the image, thereby more effectively extracting useful information and suppressing redundancy and noise.

[0057] The feature of this application is to use adaptively generated spatial-domain-specific and channel-domain-specific convolution kernels to achieve efficient integration of global and local features. It is mainly composed of two complementary attention branches and a weighted fusion module. One attention branch is mainly used to integrate global information, while the other branch mainly integrates local information. The features are decoupled into two branches, but when extracting features from each branch, the features of the other branch are still fully considered. Specifically, the complementarity of complementary attention dynamic convolution is reflected in that the local information of each row and column is fully extracted in the global branch. Similarly, the global information of each row and column will also be extracted in the branch of local features.

[0058] Specifically, S3.1 inputs the image into the global attention branch including:

[0059] S3.1.1. For each image of input size C×H×W, pooling is performed in the horizontal and vertical directions respectively to obtain two features of shape C×H×1 and C×1×W;

[0060] S3.1.2, perform one-bit convolution on the two features obtained in step S3.1.1, respectively, and then perform GroupNorm group normalization and Sigmoid activation function to obtain two features with shapes of C×H×1 and C×1×W;

[0061] S3.1.3, multiply the two features obtained in step S3.1.2 element by element to obtain a feature with a shape of C×H×W;

[0062] S3.1.4. Multiply the features obtained in step S3.1.3 by the original image element by element to obtain a feature with a shape of C×H×W as the output result of the global branch.

[0063] S3.2 Inputting the image into the local attention branch includes:

[0064] S3.2.1 For each image with an input size of C×H×W, channel average pooling and channel standard deviation pooling are performed in the channel dimension respectively, and two features with shapes of 1×H×W and 1×H×W are obtained.

[0065] S3.2.2 concatenates the two features obtained in step S3.2.1 along the channel dimension to obtain a feature with a shape of 2×H×W;

[0066] S3.2.3 Perform 1×1 convolution on the features obtained in step S3.2.2 to reduce the dimension of the channel. The shape of the features after dimension reduction is 1×H×W;

[0067] S3.2.4 The features obtained in step S3.2.3 are subjected to BatchNorm batch normalization and Sigmoid activation function. At this time, the feature shape is still 1×H×W;

[0068] S3.2.5 multiplies the feature obtained in step S3.2.4 by the original image element by element to obtain a feature with a shape of C×H×W as the output result of the local branch.

[0069] Step S4, weighted fusion: The two attention feature maps are taken as input and sent to the weighted fusion module. The weighted fusion module puts in a fusion strategy according to the preset, and performs weighted fusion on the two attention feature maps to generate a fused attention feature map, which combines the complementary information of the two branches;

[0070] Specifically, weighted fusion includes:

[0071] S4.1 performs an unfold operation on the results of step 3.1.4 and step 3.2.5 respectively to generate a convolution kernel;

[0072] S4.2 performs weighted fusion on the two types of convolution kernels generated in step S4.1, and respectively adds and multiplies the two types of convolution kernels element by element;

[0073] S4.3 passes the result of step S4.2 through a tanh activation function so that each parameter in the convolution kernel is fixed in the range of [-1, 1].

[0074] Step S5, dynamic convolution: Based on the output of the weighted fusion module, a convolution kernel for complementary attention dynamic convolution is generated, and the generated dynamic convolution kernel is applied to the input image or the intermediate feature map in the network to perform a dynamic convolution operation to further extract or enhance the deep features of the image.

[0075] Specifically, dynamic convolution includes:

[0076] S5.1 uses the output of step S4.3 as the dynamically generated convolution kernel.

[0077] S5.2 performs a convolution operation on the convolution kernel generated in step S5.1 and the original input image to perform dynamic convolution.

[0078] Step S6, classification processing and output: Input the feature map after dynamic convolution processing into the network layer composed of FC fully connected layer and Softmax, perform the final image classification, and finally output the classification result of the image, wherein the feature map is sent to the FC fully connected layer, and the classification processing is performed through the Softmax activation function, and finally the classification result of the image is output. The classification processing and output specifically inputs the result after dynamic convolution in step S5.2 into the network layer composed of fully connected layer and Softmax, and performs the final image classification.

[0079] The present invention uses the attention mechanism to consider the spatial position information and the information in the channel domain, combining the powerful feature extraction capability of the convolutional neural network with the enhanced information selectivity of the attention mechanism. Through the complementarity of global and local attention, key features can be extracted more accurately and efficiently in complex image tasks. The convolution kernel generated by this method can dynamically generate the convolution kernel adaptively according to the input, and has shown excellent performance in image classification tasks.

[0080] Experimental example:

[0081] The following Table 1 shows the computational complexity, parameter count, and classification accuracy of ResNet18, ResNet34, and ShuffleNetV2 on the CIFAR-10 dataset;

[0082] Table 1:

[0083]

[0084]

[0085] In the CIFAR-10 dataset, three networks were trained: ResNet18, ResNet34, and ShuffleNetV2. From the results in Table 1, it can be seen that the FLOPs and Params of ResNet18 and ResNet34 decreased by about 46.0% and 50.0% respectively, while Top1ACC also increased by about 1%, reaching 91.47% and 93.61% respectively. For ShuffleNetV2, after replacing the deep convolution of the original network with the method of this application, although the FLOPs and Params were slightly improved, the classification accuracy of Top1ACC was still improved. This proves the effectiveness of the method of this application.

[0086] Table 2 below shows the computational complexity, parameter count, and classification accuracy of ResNet18, ResNet34, ShuffleNetV2, and GoogLeNet on the CIFAR-100 dataset;

[0087] Table 2:

[0088]

[0089] In the CIFAR-100 dataset, four networks were trained: ResNet18, ResNet34, ShuffleNetV2, and GoogLeNet. From the results in Table 2, it can be seen that the FLOPs and Params of ResNet18 and ResNet34 decreased by about 46.0% and 50.0%, respectively. The FLOPs and Params of GoogLeNet decreased by about 44.46% and 43.59%, respectively, while the Top5 ACC of ResNet18 and ResNet34 also increased by about 1%, to 91.07% and 92.36%, respectively, and the Top5 ACC of GoogLeNet increased to 93.65%. For ShuffleNetV2, after replacing the deep convolution, although the FLOPs and Params increased slightly, the classification accuracy of Top1 ACC and Top5 ACC increased at the same time, reaching 63.35% and 87.84%, respectively. This further proves the effectiveness of the method of this application.

[0090] Table 3 below shows the computational complexity, parameter count, and classification accuracy of ResNet18, ResNet34, and ShuffleNetV2 on the Mini-ImageNet dataset;

[0091] Table 3:

[0092]

[0093] In the Mini-ImageNet dataset, four networks were trained: ResNet18, ResNet34, ShuffleNetV2, and GoogLeNet. From the results in Table III, it can be seen that training the Mini-ImageNet dataset is more challenging. Among them, the FLOPs and Params of ResNet18, ResNet34, and GoogLeNet are decreasing, while the model still maintains a comparable performance. On the other hand, for ShuffleNetV2, after replacing the deep convolution, at the cost of a significant increase in FLOPs and Params, the classification accuracy of Top1 ACC and Top5 ACC are simultaneously improved, reaching 61.76% and 85.26%, respectively. This further proves the effectiveness of the method of this application.

[0094] Table 4 below shows the ablation experiments of the two branches on the CIFAR-10 dataset;

[0095] Table 4:

[0096]

[0097] Table 5 below shows the ablation experiments of the two branches on the CIFAR-100 dataset;

[0098] Table 5:

[0099]

[0100] In order to verify the impact of the two branches on the performance of the model, comparative experiments were conducted on the CIFAR-10 and CIFAR-100 datasets using ResNet18 and ResNet34 networks. By comparing FLOPs and Params, it can be seen from the results in Tables 4 and 5 that using only one branch reduces FLOPs and the number of parameters does not change significantly. However, by using both branches at the same time, we can achieve the same parameter reduction while improving accuracy. Taking the CIFAR-100 dataset as an example, when ResNet34 is used as the training model, FLOPs and Params decreased by 44.74% and 44.23% respectively, while the Top5 ACC increased by 0.3%. This shows that the convolution kernels generated by the two branches have a positive impact on the entire model.

[0101] Table 6 below shows the ablation experiment of the dynamic convolution method replacing the position on the CIFAR-10 dataset;

[0102] Table 6:

[0103]

[0104] Table 7 below shows the ablation experiment of the dynamic convolution method replacing the position on the CIFAR-100 dataset;

[0105] Table 7:

[0106]

[0107]

[0108] For ResNet networks, both ResNet18 and ResNet34 are composed of Basic Block. This Block is mainly composed of two convolutions. The method of this application can replace any convolution as a plug-and-play method, that is, both convolutions in Basic Block can be replaced. However, replacing one or both of them is a question worth considering.

[0109] As can be seen from Tables 6 and 7, replacing both convolutions at the same time will significantly reduce FLOPs and Params, but the model performance will also drop sharply, so it is not advisable. When replacing the first convolution, FLOPs and Params will increase, and the model performance is at an average level. Finally, it can be observed that compared with replacing the first convolution, replacing only the second convolution will reduce both FLOPs and Params, and the model performance will be significantly improved, so this application chooses to replace only the second convolution.

[0110] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited by the above embodiments. The above embodiments and descriptions are only preferred examples of the present invention and are not intended to limit the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention. The scope of protection of the present invention is defined by the attached claims and their equivalents.

Claims

1. A complementary attention dynamic convolution method for image classification, characterized in that The steps include: S1. Dataset preparation and training environment setup: Prepare a dataset for image classification, determine the convolutional neural network for training, and set the training framework and key parameters in the training process; S2, network layer structure replacement: replace part of the network layer structure in the selected convolutional neural network to obtain a new convolutional neural network; S3, attention branch input: two attention branches are introduced into the new convolutional neural network, and the image data to be classified are input into the two attention branches respectively. Each attention branch processes the input image independently to generate two attention feature maps with different focuses. The two attention branches are the global attention branch and the local attention branch; S4, weighted fusion: The two attention feature maps are taken as input and sent to the weighted fusion module. The weighted fusion module puts in the fusion strategy according to the preset and performs weighted fusion on the two attention feature maps; S5, dynamic convolution: based on the output of the weighted fusion module, generate a convolution kernel for complementary attention dynamic convolution, apply the generated dynamic convolution kernel to the input image or the intermediate feature map in the network, and perform a dynamic convolution operation; S6, classification processing and output: The feature map after dynamic convolution processing is input into the network layer composed of FC fully connected layer and Softmax to perform the final image classification and finally output the classification result of the image.

2. The complementary attention dynamic convolution method for image classification according to claim 1, characterized in that: In step S1, the key parameters in the training process include the number of training rounds and the optimizer type; The datasets are CIFAR-10, CIFAR-100, and Mini-ImageNet; The convolutional neural network is ResNet series, GoogLeNet, ShuffleNetV2; The training framework selected the pytorch framework, used the NVIDIA RTX8000 graphics card, the number of training rounds was 150, and the optimizer selected the SGD stochastic gradient descent optimizer.

3. The complementary attention dynamic convolution method for image classification according to claim 2, characterized in that: The network layer structure replacement includes: S2.1 In the ResNet network, the Basic Block consists of two layers of 3×3 convolutions. The convolution kernel size in the complementary attention dynamic convolution is set to 3, replacing the second 3×3 convolution in the Basic Block; S2.2 In the ShuffleNetV2 network, the basic unit consists of three layers of convolution, namely 1×1 convolution, 3×3 separable convolution, and 1×1 convolution. The convolution kernel size of the complementary attention dynamic convolution is set to 3, replacing the separable convolution. S2.3 In GoogLeNet, the core structure consists of four branches, one of which has 3×3 convolutions. The convolution kernel size of the complementary attention dynamic convolution is set to 3, replacing all 3×3 convolutions.

4. The complementary attention dynamic convolution method for image classification according to claim 3, characterized in that: The attention branch input includes S3.1 inputting the image into the global attention branch and S3.2 inputting the image into the local attention branch.

5. The complementary attention dynamic convolution method for image classification according to claim 4, characterized in that: S3.1 Inputting the image into the global attention branch includes: S3.1.

1. For each image of input size C×H×W, pooling is performed in the horizontal and vertical directions respectively to obtain two features of shape C×H×1 and C×1×W; S3.1.2, perform one-dimensional convolution on the two features obtained in step S3.1.1 to extract features, and then perform GroupNorm group normalization and Sigmoid activation function to obtain two features with shapes of C×H×1 and C×1×W; S3.1.3, multiply the two features obtained in step S3.1.2 element by element to obtain a feature with a shape of C×H×W; S3.1.

4. Multiply the feature obtained in step S3.1.3 by the original image element by element to obtain a feature with a shape of C×H×W as the output result of the global branch.

6. The complementary attention dynamic convolution method for image classification according to claim 5, characterized in that: S3.2 Inputting the image into the local attention branch includes: S3.2.1 For each image of input size C×H×W, channel average pooling and channel standard deviation pooling are calculated in the channel dimension respectively, and two features with shapes of 1×H×W and 1×H×W are obtained; S3.2.2 concatenates the two features obtained in step S3.2.1 along the channel dimension to obtain a feature with a shape of 2×H×W; S3.2.3 Perform 1×1 convolution on the features obtained in step S3.2.2 to reduce the dimension of the channel. The shape of the features after dimension reduction is 1×H×W; S3.2.4 The features obtained in step S3.2.3 are subjected to BatchNorm batch normalization and Sigmoid activation function. The feature shape at this time is still 1×H×W; S3.2.5 multiplies the feature obtained in step S3.2.4 by the original image element by element to obtain a feature with a shape of C×H×W as the output result of the local branch.

7. The complementary attention dynamic convolution method for image classification according to claim 6, characterized in that: Weighted fusion includes: S4.1 performs an unfold operation on the results of step 3.1.4 and step 3.2.5 respectively to generate a convolution kernel; S4.2 performs weighted fusion on the two types of convolution kernels generated in step S4.1, and respectively adds and multiplies the two types of convolution kernels element by element; S4.3 passes the result of step S4.2 through a tanh activation function so that each parameter in the convolution kernel is fixed in the range of [-1, 1].

8. The complementary attention dynamic convolution method for image classification according to claim 7, characterized in that: Dynamic convolution includes: S5.1 uses the output of step S4.3 as the dynamically generated convolution kernel. S5.2 performs a convolution operation on the convolution kernel generated in step S5.1 and the original input image to perform dynamic convolution.

9. The complementary attention dynamic convolution method for image classification according to claim 8, characterized in that: Specifically, step S6 inputs the result of the dynamic convolution in step S5.2 into the network layer composed of the fully connected layer and the Softmax layer.

Citation Information

Cited By

  • Lightweight network-based Mars surface stone extraction method and system

    CN119625501A

  • A Method and System for Extracting Mars Surface Rocks Based on a Lightweight Network

    CN119625501B