Image classification method and system based on improved lightweight channel attention mechanism
By using a lightweight channel attention mechanism with broadcasting and residual connections, the problems of high computational complexity and training difficulty in existing technologies are solved, improving the stability and feature extraction capabilities of the model. It is suitable for image classification tasks, especially for efficient operation on resource-constrained devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2026-03-24
AI Technical Summary
Existing channel attention mechanisms have high computational complexity and training difficulty in lightweight models, limited applicability, insufficient stability of lightweight designs, limited feature learning ability, and need to improve generalization ability.
A lightweight channel attention mechanism using broadcasting and residual connections is adopted. Channel attention weights are generated through global average pooling, 1×1 convolution and sigmoid activation function, and feature maps are optimized through residual connections and broadcasting mechanism to replace traditional fully connected layers, thereby reducing computational complexity and number of parameters.
It significantly reduces computational complexity and the number of parameters, improves model training stability and generalization ability, and enhances feature extraction capabilities. It is particularly suitable for image classification tasks, especially for efficient operation on resource-constrained devices.
Smart Images

Figure CN120451621B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of convolutional neural networks (CNN) in deep learning, and particularly relates to an image classification method and system based on an improved lightweight channel attention mechanism. BACKGROUND
[0002] SENet (Squeeze-and-Excitation Networks) is a classic channel attention mechanism, and its core idea is to dynamically recalibrate channel feature responses through the "squeeze" and "excitation" steps. The specific implementation process is as follows: the spatial dimensions of the feature map are compressed to 1×1 through global average pooling, and the global information of the channel dimensions is retained; the squeezed features are passed through two fully connected layers, the first fully connected layer reduces the channel number to 1 / r (r is the dimension reduction ratio) of the original, and the second fully connected layer restores the channel number to the original size and generates channel attention weights through the Sigmoid activation function; the generated channel attention weights are multiplied with the original feature map channel by channel, thereby enhancing important channel features and suppressing unimportant channel features. SENet can significantly improve the performance of convolutional neural networks, especially in image classification tasks, but SENet introduces additional fully connected layers, increasing the computational complexity and parameter quantity of the model, which is not conducive to the design of lightweight models. Although SENet can significantly improve the performance of convolutional neural networks, it has the following problems:
[0003] (1) High computational complexity: SENet introduces two fully connected layers, the first fully connected layer reduces the channel number to 1 / r (r is the dimension reduction ratio) of the original, and the second fully connected layer restores the channel number to the original size. This design increases the computational complexity and parameter quantity of the model, which is not conducive to the design of lightweight models.
[0004] (2) Difficulty in training: due to the introduction of additional fully connected layers, SENet is prone to gradient vanishing or gradient explosion problems during training, especially in deep networks, which will affect the convergence speed and final performance of the model.
[0005] (3) Limited application scenarios: SENet is designed to improve the performance of image classification tasks, but in some scenarios that require lightweight models (such as mobile devices or edge computing), its computational overhead and parameter quantity are too large, limiting its application range.
[0006] ECA-Net (Efficient Channel Attention Networks) is a lightweight channel attention mechanism designed to reduce the computational overhead of the fully connected layers in SENet. Its core idea is to replace the two fully connected layers in SENet with an adaptive convolution kernel, thereby efficiently generating channel attention weights. The specific implementation process is as follows: ECA-Net first compresses the spatial dimensions of the feature map to 1x1 through global average pooling; ECA-Net introduces an adaptive convolution kernel whose size is dynamically adjusted according to the number of channels. This convolution kernel weights the squeezed features through 1D convolution operation to generate channel attention weights; the generated channel attention weights are multiplied with the original feature map channel by channel to realize the re-rating of channel features. ECA-Net significantly reduces the computational complexity and parameter quantity while maintaining the performance of the channel attention mechanism, making it suitable for lightweight model design. However, the design of its adaptive convolution kernel may not be as stable as SENet in some complex scenarios. ECA-Net replaces the fully connected layers in SENet with an adaptive convolution kernel, reducing the computational complexity and parameter quantity, but in some complex scenarios, the following problems exist:
[0007] (1) Lack of stability: Although the adaptive convolution kernel design of ECA-Net reduces computational overhead, its performance may not be as stable as SENet when dealing with complex scenarios or tasks with large data distribution changes.
[0008] (2) Limited feature learning ability: ECA-Net sacrifices some feature learning ability in lightweight design, especially when dealing with small target detection or complex background tasks, its feature enhancement effect may not be as significant as SENet.
[0009] (3) Generalization ability needs to be improved: Since ECA-Net's design is more inclined to lightweight, it may not fully utilize the advantages of channel attention mechanism in some specific tasks (such as high-resolution image processing), resulting in limited generalization ability.
[0010] Through the above analysis, the problems and defects of the prior art are: the existing channel attention mechanism SENet has high computational complexity, difficult training, and limited application scenarios; while the lightweight channel attention mechanism ECA-Net lacks stability, has limited feature learning ability, and its generalization ability needs to be improved. SUMMARY
[0011] To overcome the problems of high computational complexity, unstable training, and limited feature extraction ability of existing channel attention mechanisms in lightweight models, the present disclosure provides an image classification method and system based on an improved lightweight channel attention mechanism. The technical solution is as follows:
[0012] The application is implemented based on an image classification method of an improved lightweight channel attention mechanism, and comprises the following steps:
[0013] S1, inputting a feature map, performing a global average pooling operation to compress a spatial dimension into 1x1 and reserve global information of a channel dimension, and obtaining a feature map after global average pooling;
[0014] S2, sequentially performing a 1x1 convolution and a Sigmoid activation function operation on the feature map after global average pooling, and obtaining channel attention weights .
[0015] S3, introducing a residual connection and setting a weight of the residual connection , multiplying the input feature map and the weight of the residual connection to obtain an output feature map .
[0016] S4, expanding the obtained channel attention weights to the obtained output feature map by a broadcast mechanism, so that the channel attention weights and the output feature map have the same dimension, and an attention map is obtained , adding the output feature map and to obtain a final output feature map .
[0017] In step S1, the dimension of the input feature map X is ; wherein, is a batch size, is a channel number, is a height of the feature map, is a width of the feature map.
[0018] In step S1, the global average pooling operation comprises: creating a global average pooling layer, dynamically calculating the size and step of the pooling window according to the size of the input feature map and the specified output size; performing an average pooling operation on each channel, and generating a single numerical output value for each input channel.
[0019] In step S1, the feature map after global average pooling is :
[0020] ;
[0021] wherein, is a height of the feature map, is a width of the feature map, is an index of the feature map in the height direction, the value range of h is from 1 to , This is the index of the feature map along the width direction. The value range is from 1 to , For feature map at location The value of .
[0022] In step S2, a convolutional layer is created, and the weight parameters of the 1×1 convolution are set to... , dimension The bias parameter is , dimension The features after global average pooling are weighted using 1×1 convolutions to generate raw scores for channel attention weights; the generated raw scores for channel attention weights are then normalized using the Sigmoid activation function to obtain the channel attention weights. This operation adjusts the channel attention weights. The value range is between 0 and 1, and the expression is:
[0023] ;
[0024] ;
[0025] In the formula, The Sigmoid activation function is used to normalize the raw scores of the generated channel attention weights to between 0 and 1. This is a 1×1 convolution operation used to perform a weighted summation of the feature values for each channel.
[0026] In step S3, residual connections are introduced, and the weights of the residual connections are set. Input feature map and Multiplication yields the output feature map. The expression is:
[0027] .
[0028] In step S4, the generated channel attention weights are directly fed into the output feature map via a broadcast mechanism. Add them together to get the final output feature map. The expression is:
[0029] ;
[0030] in, The dimension is Extended to via broadcast mechanism Same dimensions ; bro To adjust channel attention weights W att Broadcast for Attention maps with the same dimensional size; for Expanded attention map.
[0031] Furthermore, the broadcast mechanism follows these rules: align tensor dimensions from back to front; broadcast if two tensors have the same size in a certain dimension, or if one tensor has a size of 1 in that dimension; if one tensor has a size of 1 in a certain dimension, expand to the size of the other tensor in that dimension.
[0032] Another object of the present invention is to provide an image classification system based on an improved lightweight channel attention mechanism, which is used to regulate the image classification method based on the improved lightweight channel attention mechanism. The system includes:
[0033] The global average pooling module is used to compress the spatial dimension of the input feature map to 1×1 through the global average pooling operation, while retaining the global information of the channel dimension, to obtain the feature map after global average pooling.
[0034] The feature weighting module is used to weight the feature maps after global average pooling through 1×1 convolution operations, generating the original scores of channel attention weights, and then normalizing them using the Sigmoid activation function to obtain the channel attention weights. ;
[0035] The residual connection module is used to introduce residual connections, set the weights of the residual connections, and multiply the input feature map X by the weights of the residual connections to obtain the output feature map. ;
[0036] The image classification module is used to broadcast the channel attention weights of the feature weighting module. Extended to the obtained output feature map Having the same dimensions, we obtain an attention map. Output feature map and Add them together to obtain the final output feature map. .
[0037] Combining all the above technical solutions, the beneficial effects of this invention are as follows:
[0038] First, this invention relates to a lightweight channel attention mechanism based on broadcasting and residual connections, which is mainly used to improve the performance of convolutional neural networks in image classification tasks. By introducing a channel attention mechanism, this invention enables the model to better focus on important channel information in the input feature map, thereby improving the discriminative power of feature representation and the generalization ability of the model. Its key points are as follows:
[0039] (1) Lightweight design: This invention significantly reduces computational complexity and the number of parameters through broadcasting mechanism and lightweight convolution operation. This invention reduces the computational burden of the model and can better preserve feature information and improve performance through the design of residual connections.
[0040] (2) Combination of broadcasting mechanism and residual connection: The broadcasting mechanism makes the processing of channel features more efficient and can quickly weight global information, thereby enhancing important features. The residual connection effectively alleviates the gradient vanishing problem in deep networks and improves the training stability and generalization ability of the model.
[0041] (3) Optimization for Image Classification Tasks: This invention is specifically optimized for image classification tasks. Through lightweight design and optimized channel attention mechanism, the performance of the model in image classification tasks is significantly improved. This design allows the model to better extract and utilize image features while maintaining a lightweight design, thereby improving classification accuracy. The lightweight design also allows for better deployment on resource-constrained devices, such as mobile devices or edge computing platforms.
[0042] (4) Enhanced feature extraction capability: Through broadcasting mechanism and residual connection, the present invention can extract and utilize important features more effectively, especially in complex backgrounds and multi-class image classification scenarios, which can significantly improve the performance of the model. This enhanced feature extraction capability helps to improve the model's ability to distinguish between different categories of images, thereby improving classification accuracy.
[0043] (5) Efficiency and stability: While reducing the amount of computation and parameters, this invention maintains the high performance and stability of the model by optimizing the design of the channel attention mechanism. This gives this invention a significant advantage in lightweight models and enables it to better adapt to various application scenarios.
[0044] Second, this invention solves the following technical problems of existing channel attention mechanisms in lightweight models, thereby improving the performance and applicability of lightweight models in image classification tasks:
[0045] (1) Reducing computational complexity and number of parameters: Existing channel attention mechanisms (such as SENet) introduce multiple fully connected layers to recalibrate channel features, which improves performance but significantly increases the computational complexity and number of parameters of the model. This makes it difficult for the model to run efficiently on resource-constrained devices (such as mobile devices or edge computing platforms). Although ECA-Net reduces the amount of computation through adaptive convolutional kernels, its performance stability is insufficient in complex scenarios. Therefore, this invention proposes a lightweight channel attention mechanism based on broadcasting and residual connections, aiming to further reduce computational complexity and number of parameters while maintaining or improving model performance.
[0046] (2) Improve the training stability and generalization ability of the model: Existing lightweight models are prone to gradient vanishing or gradient exploding during training, resulting in slow convergence speed and limited generalization ability. This invention alleviates the gradient problem in deep networks by introducing residual connections, thereby improving the training stability and generalization ability of the model.
[0047] (3) Enhanced feature extraction capability: While reducing the number of parameters, lightweight models may lose some important feature information. This invention, through broadcasting mechanism and residual connection, can process channel features more efficiently and enhance the model's ability to extract important features.
[0048] (4) Optimization for Image Classification Tasks: This invention is specifically optimized for image classification tasks. Through lightweight design and optimized channel attention mechanism, the performance of the model in image classification tasks is significantly improved. This design allows the model to better extract and utilize image features while maintaining a lightweight design, thereby improving classification accuracy. The lightweight design also allows for better deployment on resource-constrained devices, such as mobile devices or edge computing platforms.
[0049] (5) Balance between efficiency and stability: While reducing the amount of computation and parameters, the high performance and stability of the model are maintained by optimizing the design of the channel attention mechanism. This balance allows the model to maintain high accuracy and high stability while being lightweight, making it particularly suitable for image classification tasks that require high efficiency. Attached Figure Description
[0050] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure;
[0051] Figure 1 This is a flowchart of an image classification method based on an improved lightweight channel attention mechanism provided in an embodiment of the present invention;
[0052] Figure 2 This is a schematic diagram of a lightweight channel attention mechanism based on broadcasting and residual connections provided in an embodiment of the present invention. Detailed Implementation
[0053] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0054] The innovation of this invention lies in:
[0055] (1) Lightweight Channel Attention Mechanism: A lightweight channel attention mechanism is proposed, which replaces the traditional fully connected layer with a broadcast mechanism and lightweight convolution operation (1×1 convolution), which significantly reduces the computational complexity and number of parameters. This design makes the model more suitable for running on resource-constrained devices while maintaining high performance.
[0056] (2) Application of broadcasting mechanism: The channel attention weights are directly added to the input feature map instead of multiplied by the broadcasting mechanism. This design enhances the model’s ability to extract important channel features.
[0057] (3) Optimization of residual connections: Residual connections are introduced, and the weighting ratio of input features and attention weights is adjusted by the hyperparameter α. Residual connections effectively alleviate the gradient vanishing problem in deep networks and improve the training stability and generalization ability of the model.
[0058] (4) Optimization for image classification tasks: This invention is specifically optimized for image classification tasks. Through lightweight design and optimized channel attention mechanism, the performance of the model in image classification tasks is significantly improved. This design enables the model to extract and utilize image features better while maintaining lightweight design, thereby improving classification accuracy.
[0059] (5) Balance between efficiency and stability: While reducing the amount of computation and parameters, the high performance and stability of the model are maintained by optimizing the design of the channel attention mechanism. This balance allows the model to maintain high accuracy and high stability while being lightweight, making it particularly suitable for image classification tasks that require high efficiency.
[0060] Example 1, as Figure 1 and Figure 2 As shown, the image classification method based on an improved lightweight channel attention mechanism provided in this embodiment of the invention includes the following steps:
[0061] S1, Input feature map, through global average pooling operation, the spatial dimension is compressed to 1×1, while retaining the global information of the channel dimension, to obtain the feature map after global average pooling;
[0062] Suppose the dimension of the input feature map X is... ,in, For batch size, For the number of channels, For the height of the feature map, The width of the feature map is given. The input feature map is then subjected to global average pooling, compressing its spatial dimension to 1×1 while preserving global information in the channel dimension, resulting in the globally average pooled feature map. As shown in the following formula:
[0063] ;
[0064] in, For the height of the feature map, The width of the feature map, This is the index of the feature map in the height direction. The value range is from 1 to , This is the index of the feature map along the width direction. The value range is from 1 to , For feature map at location The value of .
[0065] Let the weight parameters of the 1×1 convolution be... Its dimensions are The bias parameter is , dimension The features after global average pooling are weighted using a lightweight convolution operation (1×1 convolution) to generate raw channel attention weight scores; the generated raw channel attention weight scores are then normalized using the Sigmoid activation function to obtain the channel attention weights. This operation adjusts the channel attention weights. The value range of is between 0 and 1, as shown in the following formula:
[0066] ;
[0067] ;
[0068] In the formula, The Sigmoid activation function is used to normalize the raw scores of the generated channel attention weights to between 0 and 1. This is a 1×1 convolution operation used to perform a weighted summation of the feature values for each channel.
[0069] S2, perform 1×1 convolution and sigmoid activation function operations on the feature map after global average pooling to obtain the channel attention weights. ;
[0070] Introduce residual connections and set their weights. Input feature map and Multiplication yields the output feature map. As shown in the following formula:
[0071] ;
[0072] The generated channel attention weights are directly fed into the output feature map via a broadcast mechanism. Add them together to get the final output feature map. The expression is:
[0073] ;
[0074] in, bro To adjust channel attention weights Broadcast for Attention maps with the same dimensional size, The dimension is Extended to via broadcast mechanism Same dimensions , for Expanded attention map.
[0075] The pseudocode for steps S1 and S2 of this invention is shown in Table 1.
[0076] Table 1. Pseudocode Description of the Invention
[0077]
[0078] S3, Introduce residual connections and set the weights of the residual connections. The input feature map is multiplied by the weights of the residual connection to obtain the output feature map. ;
[0079] S4, through a broadcast mechanism, transmits the obtained channel attention weights. Extended to the obtained output feature map Having the same dimensions, we obtain an attention map. The output feature map and Add them together to obtain the final output feature map. .
[0080] Example 2: The image classification system based on the improved lightweight channel attention mechanism provided in this embodiment of the invention includes:
[0081] The global average pooling module is used to compress the spatial dimension of the input feature map to 1×1 through the global average pooling operation, while retaining the global information of the channel dimension, to obtain the feature map after global average pooling.
[0082] The feature weighting module is used to weight the feature maps after global average pooling through 1×1 convolution operations, generating the original scores of channel attention weights, and then normalizing them using the Sigmoid activation function to obtain the channel attention weights. ;
[0083] The residual connection module is used to introduce residual connections, set the weights of the residual connections, and multiply the input feature map X by the weights of the residual connections to obtain the output feature map. ;
[0084] The image classification module is used to broadcast the channel attention weights of the feature weighting module. Extended to the obtained output feature map Having the same dimensions, we obtain an attention map. Output feature map and Add them together to obtain the final output feature map. .
[0085] The lightweight channel attention mechanism based on broadcasting and residual connections proposed in this invention was inserted into the last layer of the backbone in the YOLOv8n-cls model. The dataset used was the public dataset CIFAR-100, with 200 epochs, 32 imgsz, and 200 batches. All other hyperparameters were set to default. The attention mechanism was also inserted into the last layer of the backbone in the ResNet34 model with 80 epochs. The Adam optimizer was used with a learning rate of 0.0001. The experimental equipment consisted of an i9-14900k (CPU) and an RTX-4090 (GPU). The experimental results are shown in Table 2.
[0086] Table 2 Experimental Results
[0087]
[0088] Experiments demonstrate that the lightweight channel attention mechanism based on broadcasting and residual connections proposed in this invention significantly improves the classification performance of YOLOv8n-cls and ResNet34 models on the CIFAR-100 dataset, while maintaining high computational efficiency and good generalization ability. This mechanism enhances the extraction capability of channel features, enabling the model to better focus on important features, thereby improving classification accuracy. Experimental results show that in the YOLOv8n-cls model, this invention significantly improves top-1 accuracy (0.68%) and slightly improves top-5 accuracy (0.18%). The original YOLOv8n-cls model has 1.57M parameters; after adding the attention mechanism of this invention, the number of parameters only increases to 1.63M, an increase of 0.06M (3.82%), indicating that the attention mechanism of this invention introduces only a very small number of additional parameters while improving performance, which is almost negligible. In the ResNet34 model, top-1 accuracy is improved by 0.29%, and top-5 accuracy by 0.07%. The original ResNet34 model has 21.34M parameters. After adding the attention mechanism of this invention, the number of parameters increases to 21.60M, an increase of 0.26M (approximately 1.22%). Again, this increase in parameters is very small and has almost no impact on the overall model complexity. In both the YOLOv8n-cls and ResNet34 models, the FLOPs remain unchanged after adding the attention mechanism of this invention (3.5G and 30.0G respectively). This indicates that the attention mechanism of this invention is highly efficient in design and does not significantly increase the computational complexity of the model, thus improving performance while maintaining high computational efficiency.
[0089] Furthermore, detailed ablation experiments were conducted to assess the classification performance of YOLOv8n-cls on the CIFAR-100 dataset. The input feature map-adaptive average pooling-fully connected layer-Sigmoid activation-channel attention weights were configured as module 1, the residual connections as module 2, and the broadcast-output feature map... F r As Module 3, if Module 3 is not used, the conventional operation within the domain is employed, multiplying the channel attention weights by the input feature map. The experimental design is shown in Table 3, and the ablation experimental results are shown in Table 4.
[0090] Table 3 Experimental Scheme
[0091]
[0092] Table 4 Ablation Experiment
[0093]
[0094] Solution 4 is the complete solution of this invention, utilizing Module 1, Module 2, and Module 3 simultaneously. Solution 4 achieves the highest top-1 and top-5 scores among all solutions, representing improvements of 0.50% and 0.30% respectively compared to Solution 1. Although using Module 1 and Module 3 simultaneously reduces performance, combining them with Module 2 significantly improves the model's classification performance. This demonstrates that each module can play a positive role when working synergistically with other modules.
[0095] Viewing the technical solution as a whole or from the perspective of the product, the present invention has the following effects, which are described in detail below:
[0096] (1) Significantly reduced computational complexity and storage requirements: Through broadcasting mechanisms and lightweight convolutional operations, this invention significantly reduces the amount of computation and parameters. Compared with the traditional SENet, this invention uses 1×1 convolutions instead of traditional fully connected layers and only uses them once, further reducing the computational complexity of the model. The storage space requirements of the lightweight model are significantly reduced, making it easier to store and transmit in bandwidth-constrained environments.
[0097] (2) Improve the training stability and generalization ability of the model: The present invention introduces residual connections, which effectively alleviates the gradient vanishing problem in deep networks and improves the training stability and generalization ability of the model. Residual connections allow input information to directly cross one or more layers and be added to the output of subsequent layers, thereby avoiding the gradient vanishing and gradient explosion problems in deep networks.
[0098] (3) Enhanced feature extraction capability: The broadcasting mechanism makes the processing of channel features more efficient and can quickly weight global information, thereby enhancing important features. Residual connections further improve the model's ability to extract important features, especially in small target detection and complex background scenes, which can significantly improve the model's performance.
[0099] (4) Energy saving and environmental benefits: Lightweight models typically consume fewer computing resources, thereby reducing energy consumption. This is especially important for devices that need to operate for extended periods, such as drones or sensor networks. In addition, the widespread deployment of lightweight models helps reduce the consumption of hardware resources, thus achieving environmental benefits.
[0100] (5) Reduce labor intensity and improve user experience: The rapid reasoning ability of lightweight models enables them to complete tasks in a shorter time, thereby improving the user experience. For example, in smart security cameras, lightweight target detection models can identify abnormal objects faster, issue alarms in a timely manner, and improve the response speed of the security system.
[0101] Experiments demonstrate that the lightweight channel attention mechanism based on broadcasting and residual connections proposed in this invention significantly improves the classification performance of YOLOv8n-cls and ResNet34 models on the CIFAR-100 dataset, while maintaining high computational efficiency and good generalization ability. This mechanism enhances the extraction capability of channel features, enabling the model to better focus on important features, thereby improving classification accuracy. Experimental results show that in the YOLOv8n-cls model, this invention significantly improves top-1 accuracy (0.68%) and slightly improves top-5 accuracy (0.18%). In the ResNet34 model, top-1 accuracy is improved by 0.29%, and top-5 accuracy by 0.07%, with both maintaining high efficiency during the training and inference phases.
[0102] This invention improves the accuracy and efficiency of image classification, thus enhancing the performance of various computer vision applications, such as autonomous driving, intelligent surveillance, medical image analysis, and smartphone photography. Secondly, due to its lightweight design, the method is particularly suitable for deployment on resource-constrained devices, such as mobile devices and edge computing platforms, which will further expand its application scope and market potential. Furthermore, the technology's efficiency and stability make it attractive to industries requiring fast and accurate image processing, such as online advertising, content recommendation systems, and real-time data processing services.
[0103] This invention addresses the problems of high computational complexity, training difficulty, and limited feature extraction capabilities in existing technologies by introducing a lightweight channel attention mechanism and a broadcasting mechanism. While existing channel attention mechanisms, such as SENet and ECA-Net, have achieved some success in improving model performance, they still have shortcomings in lightweight design, training stability, and generalization ability. The technical solution of this invention significantly reduces computational complexity and the number of parameters by optimizing the channel attention mechanism, while simultaneously improving the model's training stability and generalization ability. The combination of the broadcasting mechanism and residual connections in this invention provides a new optimization approach for image classification tasks, further promoting the technological development of deep learning in the field of image processing.
[0104] In the field of deep learning, especially in image classification tasks, designing lightweight models that are both efficient and accurate has always been a challenge for researchers and engineers. While existing channel attention mechanisms can improve model performance, they often come with high computational complexity and a large number of parameters, limiting their application on resource-constrained devices. This invention significantly reduces the computational complexity and number of parameters of the model by introducing a lightweight channel attention and broadcasting mechanism, while maintaining high performance, effectively solving this problem. Furthermore, this invention improves the training stability and generalization ability of the model through the design of residual connections, further promoting the development and application of lightweight models.
[0105] The technical solution of this invention overcomes the bias in existing technologies regarding the performance of lightweight models. In the field of deep learning, it is often believed that lightweight models, while reducing computational cost and parameter count, sacrifice model performance. However, this invention demonstrates, through optimizing the channel attention mechanism and introducing a broadcast mechanism, that lightweight models can still achieve high performance. This invention not only maintains high model performance while reducing computational cost and parameter count, but also improves the model's training stability and generalization ability through residual connection design, thereby overcoming the bias regarding the performance of lightweight models. Furthermore, the lightweight design and optimized channel attention mechanism of this invention make the model more suitable for deployment on resource-constrained devices, further broadening the application scope of deep learning technology.
[0106] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by those skilled in the art within the scope of the technology disclosed in the present invention and within the spirit and principles of the present invention should be covered within the scope of protection of the present invention.
Claims
1. An image classification method based on an improved lightweight channel attention mechanism, characterized in that, The method includes the following steps: S1, Input feature map, through global average pooling operation, the spatial dimension is compressed to 1×1, while retaining the global information of the channel dimension, to obtain the feature map after global average pooling; S2, perform 1×1 convolution and sigmoid activation on the feature map after global average pooling to obtain the channel attention weights. ; S3, Introduce residual connections and set the weights of the residual connections. The input feature map is multiplied by the weights of the residual connection to obtain the output feature map. ; S4, through a broadcast mechanism, transmits the obtained channel attention weights. Extended to the obtained output feature map Having the same dimensions, we obtain an attention map. The output feature map and Add them together to obtain the final output feature map. .
2. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that, In step S1, the dimension of the input feature map X is ;in, For batch size, For the number of channels, For the height of the feature map, The width of the feature map.
3. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that, In step S1, the global average pooling operation includes: creating a global average pooling layer; dynamically calculating the size and stride of the pooling window based on the size of the input feature map and the specified output size; performing average pooling operation on each channel, with each input channel generating a single numerical output.
4. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that, In step S1, the feature map after global average pooling for: ; in, For the height of the feature map, The width of the feature map, This is the index of the feature map in the height direction. The value range is from 1 to , This is the index of the feature map along the width direction. The value range is from 1 to , For feature map at location The value of .
5. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that, In step S2, a convolutional layer is created, and the weight parameters of the 1×1 convolution are set to... , dimension The bias parameter is , dimension The features after global average pooling are weighted using 1×1 convolutions to generate raw scores for channel attention weights; the generated raw scores for channel attention weights are then normalized using the Sigmoid activation function to obtain the channel attention weights. This operation adjusts the channel attention weights. The value range is between 0 and 1, and the expression is: ; ; In the formula, The Sigmoid activation function is used to normalize the raw scores of the generated channel attention weights to between 0 and 1. This is a 1×1 convolution operation used to perform a weighted summation of the feature values for each channel.
6. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that, In step S3, residual connections are introduced, and the weights of the residual connections are set. Input feature map and Multiplication yields the output feature map. The expression is: 。 7. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that, In step S4, the generated channel attention weights are directly fed into the output feature map via a broadcast mechanism. Add them together to get the final output feature map. The expression is: ; in, The dimension is Extended to via broadcast mechanism Same dimensions ; bro To adjust channel attention weights W att Broadcast for Attention maps with the same dimensional size; for The expanded attention map.
8. The image classification method based on the improved lightweight channel attention mechanism according to claim 7, characterized in that, The broadcast mechanism follows these rules: align tensor dimensions from back to front; broadcast if two tensors have the same size in a certain dimension, or if one tensor has a size of 1 in that dimension; if one tensor has a size of 1 in a certain dimension, expand it to the size of the other tensor in that dimension.
9. An image classification system based on an improved lightweight channel attention mechanism, characterized in that, This system is used to regulate the image classification method based on the improved lightweight channel attention mechanism as described in any one of claims 1-8, and the system comprises: The global average pooling module is used to compress the spatial dimension of the input feature map to 1×1 through the global average pooling operation, while retaining the global information of the channel dimension, to obtain the feature map after global average pooling. The feature weighting module is used to weight the feature maps after global average pooling through 1×1 convolution operations, generating the original scores of channel attention weights, and then normalizing them using the Sigmoid activation function to obtain the channel attention weights. ; The residual connection module is used to introduce residual connections, set the weights of the residual connections, and multiply the input feature map X by the weights of the residual connections to obtain the output feature map. ; The image classification module is used to broadcast the channel attention weights of the feature weighting module. Extended to the obtained output feature map Having the same dimensions, we obtain an attention map. Output feature map and Add them together to obtain the final output feature map. .
Citation Information
Patent Citations
Medical image super-resolution reconstruction method based on multi-attention residual feature fusion
CN113298717A
Lightweight image feature extraction method based on attention mechanism
CN116935145A