Image classification method based on wavelet attention mechanism
By constructing the MWTNet network and utilizing wavelet attention mechanism for multi-directional frequency band decomposition and feature fusion, the problem of insufficient feature interaction in image classification is solved, and high-precision image classification is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAN UNIV OF TECH
- Filing Date
- 2026-02-27
- Publication Date
- 2026-05-01
AI Technical Summary
Existing image classification methods suffer from insufficient feature interaction during multi-scale feature fusion, leading to low image classification accuracy.
An image classification method based on wavelet attention mechanism is adopted. By constructing the MWTNet network, wavelet transform is used to perform multi-directional frequency band decomposition, and dual feature fusion in the spatial and frequency domains is combined to enhance the global feature learning ability.
While reducing the number of parameters, it significantly improves image classification accuracy to 83.54%, enhancing the model's learning and generalization abilities while reducing computational burden.
Smart Images

Figure CN121962771A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, specifically relating to an image classification method based on wavelet attention mechanism. Background Technology
[0002] Image classification has been widely applied in various fields such as medicine, transportation, and security, and has become a key fundamental task in computer vision. Its core objective is to accurately classify images into predetermined categories based on their content, providing support for subsequent intelligent analysis and decision-making.
[0003] With the development of deep learning technology, Convolutional Neural Networks (CNNs) and Transformer models based on self-attention mechanisms have become mainstream methods for improving image classification performance. Among them, the SwinTransformer, by introducing shifted window attention and a hierarchical pyramid structure, achieves multi-scale feature extraction while reducing computational complexity, demonstrating excellent performance in image classification tasks. However, the attention mechanism of the SwinTransformer is essentially still limited to interactions within a local window, making it difficult to achieve global context modeling across scales; at the same time, its feature fusion method between layers is relatively simple, failing to fully promote deep interactions between different semantic information. Therefore, this leads to inaccurate image classification and low precision. Summary of the Invention
[0004] The purpose of this invention is to provide an image classification method based on wavelet attention mechanism. This method solves the problem of low image classification accuracy caused by insufficient feature interaction during the multi-scale feature fusion process in existing image classification methods.
[0005] The technical solution adopted in this invention is an image classification method based on wavelet attention mechanism, specifically:
[0006] Step 1: Select the training sample set and the test sample set, and perform preprocessing operations on the images in the training sample set and the test sample set; Step 2: Construct MWTNet (Multi-scale Wavelet Transform Network). Use the MWTNet network to process the image obtained in Step 1 to obtain feature maps. The overall architecture of MWTNet continues the classic hierarchical pyramid structure, dividing the network processing flow into four continuous and progressive stages. Step 3: Input the feature map obtained in Step 2 into the classification head for classification and obtain the classification result.
[0007] The invention is further characterized in that: The specific process of step 1 is as follows: Step 1.1: Select m images of size 3×H×W as the training sample set; select n images of size 3×H×W as the test sample set; Step 1.2 involves preprocessing the images in the training and testing sample sets obtained in Step 1.1, including random horizontal flipping, random cropping, random rotation, and normalization, to ensure consistency in the size and number of channels of the input images, thus obtaining the input image. ; The specific process of step 2 is as follows: Step 2.1: Construct the first stage of MWTNet. The first stage consists of one Stem module and three WMB (WaveletMixing Blocks). The WMB module structure includes a bottleneck structure, a Wavelet Attention module, and an MLP module; the input image obtained in Step 1.2 is then processed. The feature maps learned in the first stage are passed to the first stage of MWTNet to obtain the feature maps learned in the first stage. Step 2.2: Construct the second stage of MWTNet. The second stage consists of a Patch Embedding module and 6 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M1 obtained in Step 2.1.5 is passed to the second stage of MWTNet to obtain the feature map learned by the second stage. Step 2.3: Construct the third stage of MWTNet. The third stage consists of a Patch Embedding module and 12 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M2 obtained in Step 2.2.5 is passed to the third stage of MWTNet to obtain the feature map learned by the third stage. Step 2.4: Construct the fourth stage of MWTNet. The fourth stage consists of a Patch Embedding module and three WMB modules. The WMB module contains a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M3 obtained in step 2.3.5 is passed to the fourth stage of MWTNet to obtain the feature map learned by the fourth stage.
[0008] Step 2.1 specifically involves: Step 2.1.1: First, determine that the Stem module contains two 3×3 Conv (convolutional layers) for the input image. Perform initial feature extraction and reduce spatial dimensions; then, use the input image obtained in step 1.2. After passing through two 3×3 Conv modules in the Stem module, the feature map is reduced to 1 / 4 of its original size, and the number of channels is increased to C1, thus obtaining the feature map. Where C1 represents the number of channels in the feature map, H represents the height of the feature map, and W represents the width of the feature map; Step 2.1.2: First, the bottleneck structure is determined to include two 1×1 Convs and one 3×3 DWConv (depthsively separable convolutions) to enhance the network's expressive power; then, the feature maps obtained in Step 2.1.1 are... The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv with a bottleneck structure, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.1.3: Process the feature map from step 2.1.2. The input is fed into the Wavelet Attention module to obtain the feature map. ; The Wavelet Attention module structure is as follows: Figure 3 As shown, the Wavelet Attention module is first determined to consist of a projection matrix, two 1×1 Convs, a Wavelet Transformer, and a Scaled Dot-Product Attention. Then, the feature map obtained in step 2.1.2 Expand into a sequence form, then use a projection matrix to perform linear projection to generate a query. ,key ,value Three tensors, as shown in formula (1): (1) Among them, W qkv The projection matrix is learnable; Then, the value V is input into the Wavelet Transformer, and a wavelet transform operation is applied to the value V; The Wavelet Transformer consists of a Discrete Wavelet, two 1×1 Conv operations, a Concat operation, and an Interpolate operation. The feature processing flow of Wavelet Transformer is as follows: Step 1: Perform frequency domain decomposition on the value V using the Discrete Wavelet operation to obtain low-frequency components with structural feature information and high-frequency components with detailed feature information. The low-frequency components contain low-frequency information components. The high-frequency components include high-frequency information components in three directions, namely the horizontal information components. Vertical information components and diagonal information components The Discrete Wavelet operation is as shown in formulas (2)(3)(4)(5): (2) (3) (4) (5) Where Low(·) represents a low-frequency filter and High(·) represents a high-frequency filter; Step 2: Learn the feature representation of LL using 1×1 Conv, and upsample LL to the same spatial dimension as the input using the Interpolate operation to obtain the low-frequency feature V. L Simultaneously, the three high-frequency components HL, LH, and HH are concatenated, and the spatial dimension is restored through a 1×1 Conv operation using channel compression and interpolation to obtain the high-frequency feature V. H As shown in formulas (6) and (7): (6) (7) Where Concat(·) represents the concatenation operation, and Interpolate(·) represents the interpolation operation; Next, the low-frequency feature V L Element-wise multiplication with key K essentially uses global structural information as a priori to enhance the response of key K in key regions, achieving semantic aggregation guided by low frequency. After passing through a 1×1 Conv, as shown in formula (8), the feature map is obtained. Simultaneously utilizing high-frequency feature V H Element-wise multiplication of query Q makes it focus more on regions with significant local changes, thereby enhancing the model's ability to distinguish details and achieving high-frequency enhanced detail matching. After passing through a 1×1 Conv, as shown in formula (9), the feature map is obtained. The expressions for formulas (8) and (9) are as follows: (8) (9) in, This indicates element-wise multiplication; Finally, , The sum V is input into Scaled Dot-Product Attention. First, the attention weights are calculated, and then the original value V is weighted and aggregated using the attention weights to generate the final attention output Out, as shown in Equation (10): (10) Input feature map A residual connection is made with the attention output Out to obtain the feature map. ; Step 2.1.4: First, determine that the MLP module consists of two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.1.3... After passing through a 1×1 Conv layer, followed by a Dropout layer to reduce dependencies between neurons and enhance the model's generalization ability, and then through another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are then residually connected to obtain the feature map. ; Step 2.1.5: Iterate through steps 2.1.2 to 2.1.4 three times to obtain the output of the first stage of MWTNet. ; Step 2.2 specifically involves: Step 2.2.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.1.5 After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C2, thus obtaining the feature map. ; Step 2.2.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.2.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.2.3: Process the feature map from step 2.2.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.2.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in Step 2.2.3... After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.2.5: Iterate through steps 2.2.2 to 2.2.4 six times to obtain the output of the second stage of MWTNet. ; Step 2.3 specifically involves: Step 2.3.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.2.5... After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C3, thus obtaining the feature map. ; Step 2.3.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.3.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.3.3: Process the feature map after step 2.3.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.3.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.3.3. After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.3.5: Iterate through steps 2.3.2 to 2.3.4 12 times to obtain the output of the third stage of MWTNet. .
[0009] Step 2.4 specifically involves: Step 2.4.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.3.5 After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C4, thus obtaining the feature map. ; Step 2.4.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.4.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.4.3: Process the feature map from step 2.4.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.4.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.4.3... After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.4.5: Iterate through steps 2.4.2 to 2.4.4 three times to obtain the output of the fourth stage of MWTNet. .
[0010] Step 3 specifically involves: The feature map obtained in step 2.4.5 After passing through a batch normalization (BN) layer, global average pooling is performed, which averages the feature maps across the spatial dimension to obtain a one-dimensional feature vector. Finally, this feature vector is passed through a fully connected classification head to obtain the score for each category, and the category with the highest score is the classification result for the image.
[0011] The beneficial effects of this invention are: (1) The image classification method based on wavelet attention mechanism of the present invention significantly improves the image classification accuracy while reducing the number of parameters compared with other image classification methods based on SwinTransformer network. The accuracy reaches 83.54% and the number of parameters is 13.8M.
[0012] (2) The method of the present invention introduces wavelet transform to perform multi-directional frequency band decomposition of the image, effectively capturing global structural features and local detail features, thereby improving the learning and generalization capabilities of MWTNet; and combined with the dual feature fusion of spatial and frequency domains, through structured wavelet frequency band division and attention weight separation mechanism, it enhances the learning ability of MWTNet to multi-scale global features, enabling MWTNet to concentrate computing resources to capture key features of the image, effectively reducing the number of parameters and computational burden of MWTNet, and also improving the classification accuracy of MWTNet. Attached Figure Description
[0013] Figure 1 This is a framework diagram of the MWTNet method of the present invention; Figure 2 This is a structural diagram of the WMB module in the MWTNet method of the present invention; Figure 3 This is a structural diagram of the Wavelet Attention module in the MWTNet method of this invention; Figure 4 This is a structural diagram of Wavelet Transform in the MWTNet method of this invention. Detailed Implementation
[0014] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0015] This invention provides an image classification method based on wavelet attention mechanism, such as... Figure 1 As shown, specifically: Step 1: Select the training sample set and the test sample set, and perform preprocessing operations on the images in the training sample set and the test sample set; The specific process of step 1 is as follows: Step 1.1: Select m images of size 3×H×W as the training sample set; select n images of size 3×H×W as the test sample set; Step 1.2 involves preprocessing the images in the training and testing sample sets obtained in Step 1.1, including random horizontal flipping, random cropping, random rotation, and normalization, to ensure consistency in the size and number of channels of the input images, thus obtaining the input image. ; Step 2: Construct MWTNet and use the MWTNet network to process the image obtained in Step 1. The overall architecture of MWTNet continues the classic hierarchical pyramid structure, dividing the network processing flow into four continuous and progressive stages. The specific process of step 2 is as follows: Step 2.1: Construct the first stage of MWTNet. The first stage consists of one Stem module and three WMBs. The structure of the WMB module is as follows: Figure 2 As shown, it includes a bottleneck structure, a Wavelet Attention module, and an MLP module; the input image obtained in step 1.2 is... The feature maps learned in the first stage are passed to the first stage of MWTNet to obtain the feature maps learned in the first stage. Step 2.1 specifically involves: Step 2.1.1: First, determine that the Stem module contains two 3×3 Convs for the input image. Perform initial feature extraction and reduce spatial dimensions; then, use the input image obtained in step 1.2. After passing through two 3×3 Conv modules in the Stem module, the feature map is reduced to 1 / 4 of its original size, and the number of channels is increased to C1, thus obtaining the feature map. Where C1 represents the number of channels in the feature map, H represents the height of the feature map, and W represents the width of the feature map; Step 2.1.2: First, the bottleneck structure is determined to include two 1×1 Convs and one 3×3 DWConv to enhance the network's expressive power; then, the feature maps obtained in Step 2.1.1 are... The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv with a bottleneck structure, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.1.3: Process the feature map from step 2.1.2. The input is fed into the Wavelet Attention module to obtain the feature map. ; The Wavelet Attention module structure is as follows: Figure 3 As shown, the Wavelet Attention module is first determined to consist of a projection matrix, two 1×1 Convs, a Wavelet Transformer, and a Scaled Dot-ProductAttention; Then, the feature map obtained in step 2.1.2 Expand into a sequence form, then use a projection matrix to perform linear projection to generate a query. ,key ,value Three tensors, as shown in formula (1): (1) Among them, W qkv The projection matrix is learnable; Then, the value V is input into the Wavelet Transformer, and a wavelet transform operation is applied to the value V, such as... Figure 4 As shown; The Wavelet Transformer consists of a Discrete Wavelet, two 1×1 Conv operations, a Concat operation, and an Interpolate operation. The feature processing flow of Wavelet Transformer is as follows: Step 1: Perform frequency domain decomposition on the value V using the Discrete Wavelet operation to obtain low-frequency components with structural feature information and high-frequency components with detailed feature information. The low-frequency components contain low-frequency information components. The high-frequency components include high-frequency information components in three directions, namely the horizontal information components. Vertical information components and diagonal information components The Discrete Wavelet operation is as shown in formulas (2)(3)(4)(5): (2) (3) (4) (5) Where Low(·) represents a low-frequency filter and High(·) represents a high-frequency filter; Step 2: Learn the feature representation of LL using 1×1 Conv, and upsample LL to the same spatial dimension as the input using the Interpolate operation to obtain the low-frequency feature V.L Simultaneously, the three high-frequency components HL, LH, and HH are concatenated, and the spatial dimension is restored through a 1×1 Conv operation using channel compression and interpolation to obtain the high-frequency feature V. H As shown in formulas (6) and (7): (6) (7) Where Concat(·) represents the concatenation operation, and Interpolate(·) represents the interpolation operation; Next, the low-frequency feature V L Element-wise multiplication with key K essentially uses global structural information as a priori to enhance the response of key K in key regions, achieving semantic aggregation guided by low frequency. After passing through a 1×1 Conv, as shown in formula (8), the feature map is obtained. Simultaneously utilizing high-frequency feature V H Element-wise multiplication of query Q makes it focus more on regions with significant local changes, thereby enhancing the model's ability to distinguish details and achieving high-frequency enhanced detail matching. After passing through a 1×1 Conv, as shown in formula (9), the feature map is obtained. The expressions for formulas (8) and (9) are as follows: (8) (9) in, This indicates element-wise multiplication; Finally, , The sum V is input into Scaled Dot-Product Attention. First, the attention weights are calculated, and then the original value V is weighted and aggregated using the attention weights to generate the final attention output Out, as shown in Equation (10): (10) Input feature map A residual connection is made with the attention output Out to obtain the feature map. ; Step 2.1.4: First, determine that the MLP module consists of two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.1.3... After passing through a 1×1 Conv layer, followed by a Dropout layer to reduce dependencies between neurons and enhance the model's generalization ability, and then through another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are then residually connected to obtain the feature map. ; Step 2.1.5: Iterate through steps 2.1.2 to 2.1.4 three times to obtain the output of the first stage of MWTNet. ; Step 2.2: Construct the second stage of MWTNet. The second stage consists of a Patch Embedding module and 6 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M1 obtained in Step 2.1.5 is passed to the second stage of MWTNet to obtain the feature map learned by the second stage. Step 2.2 specifically involves: Step 2.2.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.1.5 After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C2, thus obtaining the feature map. ; Step 2.2.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.2.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.2.3: Process the feature map from step 2.2.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.2.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in Step 2.2.3... After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.2.5: Iterate through steps 2.2.2 to 2.2.4 six times to obtain the output of the second stage of MWTNet. ; Step 2.3: Construct the third stage of MWTNet. The third stage consists of a Patch Embedding module and 12 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M2 obtained in Step 2.2.5 is passed to the third stage of MWTNet to obtain the feature map learned by the third stage. Step 2.3 specifically involves: Step 2.3.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.2.5... After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C3, thus obtaining the feature map. ; Step 2.3.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.3.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.3.3: Process the feature map after step 2.3.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.3.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.3.3. After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.3.5: Iterate through steps 2.3.2 to 2.3.4 12 times to obtain the output of the third stage of MWTNet. ; Step 2.4: Construct the fourth stage of MWTNet. The fourth stage consists of a Patch Embedding module and three WMB modules. The WMB module contains a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M3 obtained in step 2.3.5 is passed to the fourth stage of MWTNet to obtain the feature map learned by the fourth stage. Step 2.4 specifically involves: Step 2.4.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.3.5 After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C4, thus obtaining the feature map. ; Step 2.4.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.4.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.4.3: Process the feature map from step 2.4.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.4.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.4.3... After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.4.5: Iterate through steps 2.4.2 to 2.4.4 three times to obtain the output of the fourth stage of MWTNet. .
[0016] Step 3, use the feature map obtained in step 2.4.5 The data is input into the classification head for classification, and the classification result is obtained. Step 3 specifically involves: The feature map obtained in step 2.4.5 After passing through a batch normalization (BN) layer, global average pooling is performed, which averages the feature maps across the spatial dimension to obtain a one-dimensional feature vector. Finally, this feature vector is passed through a fully connected classification head to obtain the score for each category, and the category with the highest score is the classification result for the image.
[0017] Example 1 The CIFAR-100 dataset is a commonly used image classification dataset. Each image is a 32×32 color image with 3 channels, which is resized to 224×224 during training. The dataset contains 100 different classes, with 60,000 images per class, of which 50,000 are used for training and 10,000 for testing. The optimizer used is AdamW. The base learning rate is set to 2e-3, and a cosine annealing learning rate scheduling strategy is employed during optimization. The warm-up phase consists of 20 epochs with an initial learning rate of 1e-4, and the minimum learning rate decays to 1e-5. The total number of training epochs is 300, the batch size is 128, and the default number of workers is 8.
[0018] An image classification method based on wavelet attention mechanism, the method framework diagram is as follows: Figure 1 As shown, the specific steps include the following: Step 1: Select 50,000 and 10,000 images of size 3×32×32 as training sample set and test sample set respectively, and perform preprocessing operations on the images in the training sample set and test sample set. The specific process of step 1 is as follows: Step 1.1: Select 50,000 images of size 3×H×W as the training sample set; select 10,000 images of size 3×H×W as the test sample set; Step 1.2 and Step 1.1 involve preprocessing the images in the training and testing sample sets obtained from the training and testing sample sets. This includes random horizontal flipping, random cropping, random rotation, and normalization to ensure consistency in the size and number of channels of the input images, thus obtaining the input image. ; Step 2: Construct MWTNet and use the MWTNet network to process the image obtained in Step 1. The overall architecture of MWTNet continues the classic hierarchical pyramid structure, dividing the network processing flow into four continuous and progressive stages. The specific process of step 2 is as follows: Step 2.1: Construct the first stage of MWTNet. The first stage consists of one Stem module and three WMBs. The structure of the WMB module is as follows: Figure 2 As shown, it includes a bottleneck structure, a Wavelet Attention module, and an MLP module; the input image obtained in step 1.2 is... The feature maps learned in the first stage are passed to the first stage of MWTNet to obtain the feature maps learned in the first stage. Step 2.1 specifically involves: Step 2.1.1: First, determine that the Stem module contains two 3×3 Convs for the input image. Perform initial feature extraction and reduce spatial dimensions; then, use the input image obtained in step 1.2. After passing through two 3×3 Conv modules in the Stem module, the feature map is reduced to 1 / 4 of its original size, and the number of channels is increased to 64 dimensionality to obtain the feature map. ; Step 2.1.2: First, the bottleneck structure is determined to include two 1×1 Convs and one 3×3 DWConv to enhance the network's expressive power; then, the feature maps obtained in Step 2.1.1 are... The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv with a bottleneck structure, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.1.3: Process the feature map from step 2.1.2. The input is fed into the Wavelet Attention module to obtain the feature map. ; The Wavelet Attention module structure is as follows: Figure 3 As shown, the Wavelet Attention module is first determined to consist of a projection matrix, two 1×1 Convs, a Wavelet Transformer, and a Scaled Dot-ProductAttention; Then, the feature map obtained in step 2.1.2 Expand into a sequence form, then use a projection matrix to perform linear projection to generate a query. ,key ,value Three tensors, as shown in formula (1): (1) Among them, Wqkv The projection matrix is learnable; Then, the value V is input into the Wavelet Transformer, and a wavelet transform operation is applied to the value V, such as... Figure 4 As shown; The Wavelet Transformer consists of a Discrete Wavelet, two 1×1 Conv operations, a Concat operation, and an Interpolate operation. The feature processing flow of Wavelet Transformer is as follows: Step 1: Perform frequency domain decomposition on the value V using the Discrete Wavelet operation to obtain low-frequency components with structural feature information and high-frequency components with detailed feature information. The low-frequency components contain low-frequency information components. The high-frequency components include high-frequency information components in three directions, namely the horizontal information components. Vertical information components and diagonal information components DiscreteWavelet operations are as shown in formulas (2)(3)(4)(5): (2) (3) (4) (5) Where Low(·) represents a low-frequency filter and High(·) represents a high-frequency filter; Step 2: Learn the feature representation of LL using 1×1 Conv, and upsample LL to the same spatial dimension as the input using the Interpolate operation to obtain the low-frequency feature V. L Simultaneously, the three high-frequency components HL, LH, and HH are concatenated, and the spatial dimension is restored through a 1×1 Conv operation using channel compression and interpolation to obtain the high-frequency feature V. H As shown in formulas (6) and (7): (6) (7) Where Concat(·) represents the concatenation operation, and Interpolate(·) represents the interpolation operation; Next, the low-frequency feature V LElement-wise multiplication with key K essentially uses global structural information as a priori to enhance the response of key K in key regions, achieving semantic aggregation guided by low frequency. After passing through a 1×1 Conv, as shown in formula (8), the feature map is obtained. Simultaneously utilizing high-frequency feature V H Element-wise multiplication of query Q makes it focus more on regions with significant local changes, thereby enhancing the model's ability to distinguish details and achieving high-frequency enhanced detail matching. After passing through a 1×1 Conv, as shown in formula (9), the feature map is obtained. The expressions for formulas (8) and (9) are as follows: (8) (9) in, This indicates element-wise multiplication; Finally, , The sum V is input into Scaled Dot-Product Attention. First, the attention weights are calculated, and then the original value V is weighted and aggregated using the attention weights to generate the final attention output Out, as shown in Equation (10): (10) Input feature map A residual connection is made with the attention output Out to obtain the feature map. ; Step 2.1.4: First, determine that the MLP module consists of two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.1.3... After passing through a 1×1 Conv layer, followed by a Dropout layer to reduce dependencies between neurons and enhance the model's generalization ability, and then through another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are then residually connected to obtain the feature map. ; Step 2.1.5: Iterate through steps 2.1.2 to 2.1.4 three times to obtain the output of the first stage of MWTNet. ; Step 2.2: Construct the second stage of MWTNet. The second stage consists of a Patch Embedding module and 6 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M1 obtained in Step 2.1.5 is passed to the second stage of MWTNet to obtain the feature map learned by the second stage. Step 2.2 specifically involves: Step 2.2.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.1.5 After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to 128, thus obtaining the feature map. ; Step 2.2.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.2.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.2.3: Process the feature map from step 2.2.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.2.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in Step 2.2.3... After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.2.5: Iterate through steps 2.2.2 to 2.2.4 six times to obtain the output of the second stage of MWTNet. ; Step 2.3: Construct the third stage of MWTNet. The third stage consists of a Patch Embedding module and 12 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M2 obtained in Step 2.2.5 is passed to the third stage of MWTNet to obtain the feature map learned by the third stage. Step 2.3 specifically involves: Step 2.3.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.2.5... After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to 256, thus obtaining the feature map. ; Step 2.3.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.3.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.3.3: Process the feature map after step 2.3.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.3.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.3.3. After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.3.5: Iterate through steps 2.3.2 to 2.3.4 12 times to obtain the output of the third stage of MWTNet. ; Step 2.4: Construct the fourth stage of MWTNet. The fourth stage consists of a Patch Embedding module and three WMB modules. The WMB module contains a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M3 obtained in step 2.3.5 is passed to the fourth stage of MWTNet to obtain the feature map learned by the fourth stage. Step 2.4 specifically involves: Step 2.4.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.3.5 After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to 512, thus obtaining the feature map. ; Step 2.4.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.4.1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.4.3: Process the feature map from step 2.4.2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.4.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.4.3... After passing through a 1×1 Conv layer, a Dropout layer, and another 1×1 Conv layer to further enrich the features, the input of the first 1×1 Conv layer and the output of the last 1×1 Conv layer are residually connected to obtain the feature map. ; Step 2.4.5: Iterate through steps 2.4.2 to 2.4.4 three times to obtain the output of the fourth stage of MWTNet. .
[0019] Step 3, use the feature map obtained in step 2.4.5 The data is input into the classification head for classification, and the classification result is obtained. Step 3 specifically involves: The feature map obtained in step 2.4.5 After passing through a batch normalization (BN) layer, global average pooling is performed, which averages the feature maps across the spatial dimension to obtain a one-dimensional feature vector. Finally, this feature vector is passed through a fully connected classification head to obtain the score for each category, and the category with the highest score is the classification result for the image.
[0020] Performance comparison: To verify the feasibility of the MWTNet method of this invention, image classification methods with ViT and Swin Transformer as the backbone network were selected for comparison, specifically including ViT-B, DaiT-Small, PVTv1-Small, PVTv2-B2, SwinV2-Small, Swin-Small, Swin-Base, MobileViT-S, and CoAtNet1. The accuracy of these methods on the CIFAR100 validation set was summarized, and the parameters included: number of parameters (Params (M)), computational complexity (FLOPs (G)), and evaluation accuracy (Top-1 (%) and Top-5 (%)).
[0021] As shown in Table 1, the MWTNet method of this invention achieves a high classification accuracy (83.54) with 13.8M parameters, which is higher than that of the PVTv1 method (65.39), the SwinV2 method (67.47), and the Swin Transformer method (73.47).
[0022] Table 1 shows the experimental results of each method on the Cifar100 dataset.
[0023] Example 2 The image classification method based on wavelet attention mechanism is as follows: Step 1: Select the training sample set and the test sample set, and perform preprocessing operations on the images in the training sample set and the test sample set; Step 2: Construct the MWTNet network and use the MWTNet network to process the image obtained in Step 1 to obtain feature maps; Step 3: Input the feature map obtained in Step 2 into the classification head for classification and obtain the classification result.
[0024] Example 3 The image classification method based on wavelet attention mechanism is as follows: Step 1: Select the training sample set and the test sample set, and perform preprocessing operations on the images in the training sample set and the test sample set; The specific process of step 1 is as follows: Step 1.1: Select m images of size 3×H×W as the training sample set; select n images of size 3×H×W as the test sample set; Step 1.2 involves preprocessing the images in the training and testing sample sets obtained in Step 1.1, including random horizontal flipping, random cropping, random rotation, and normalization, to ensure consistency in the size and number of channels of the input images, thus obtaining the input image. .
[0025] Step 2: Construct the MWTNet network and use the MWTNet network to process the image obtained in Step 1 to obtain feature maps; Step 3: Input the feature map obtained in Step 2 into the classification head for classification and obtain the classification result.
[0026] Example 4 The image classification method based on wavelet attention mechanism is as follows: Step 1: Select the training sample set and the test sample set, and perform preprocessing operations on the images in the training sample set and the test sample set; The specific process of step 1 is as follows: Step 1.1: Select m images of size 3×H×W as the training sample set; select n images of size 3×H×W as the test sample set; Step 1.2 involves preprocessing the images in the training and testing sample sets obtained in Step 1.1, including random horizontal flipping, random cropping, random rotation, and normalization, to ensure consistency in the size and number of channels of the input images, thus obtaining the input image. .
[0027] Step 2: Construct the MWTNet network and use the MWTNet network to process the image obtained in Step 1 to obtain feature maps; Step 3: Input the feature map obtained in Step 2 into the classification head for classification and obtain the classification result.
[0028] Example 5 The image classification method based on wavelet attention mechanism is as follows: Step 1: Select the training sample set and the test sample set, and perform preprocessing operations on the images in the training sample set and the test sample set; The specific process of step 1 is as follows: Step 1.1: Select m images of size 3×H×W as the training sample set; select n images of size 3×H×W as the test sample set; Step 1.2 involves preprocessing the images in the training and testing sample sets obtained in Step 1.1, including random horizontal flipping, random cropping, random rotation, and normalization, to ensure consistency in the size and number of channels of the input images, thus obtaining the input image. .
[0029] Step 2: Construct the MWTNet network and use the MWTNet network to process the image obtained in Step 1 to obtain feature maps; The specific process of step 2 is as follows: Step 2.1: Construct the first stage of MWTNet. The first stage consists of one Stem module and three WMB modules. The WMB module structure includes a bottleneck structure, a Wavelet Attention module, and an MLP module; the input image obtained in Step 1.2 is then processed. The feature maps learned in the first stage are passed to the first stage of MWTNet to obtain the feature maps learned in the first stage. Step 2.2: Construct the second stage of MWTNet. The second stage consists of a Patch Embedding module and 6 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M1 obtained in Step 2.1.5 is passed to the second stage of MWTNet to obtain the feature map learned by the second stage. Step 2.3: Construct the third stage of MWTNet. The third stage consists of a Patch Embedding module and 12 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M2 obtained in Step 2.2.5 is passed to the third stage of MWTNet to obtain the feature map learned by the third stage. Step 2.4: Construct the fourth stage of MWTNet. The fourth stage consists of a Patch Embedding module and three WMB modules. The WMB module contains a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M3 obtained in step 2.3.5 is passed to the fourth stage of MWTNet to obtain the feature map learned by the fourth stage.
[0030] Step 3: Input the feature map obtained in Step 2 into the classification head for classification and obtain the classification result.
[0031] Example 6 The image classification method based on wavelet attention mechanism is as follows: Step 1: Select the training sample set and the test sample set, and perform preprocessing operations on the images in the training sample set and the test sample set; The specific process of step 1 is as follows: Step 1.1: Select m images of size 3×H×W as the training sample set; select n images of size 3×H×W as the test sample set; Step 1.2 involves preprocessing the images in the training and testing sample sets obtained in Step 1.1, including random horizontal flipping, random cropping, random rotation, and normalization, to ensure consistency in the size and number of channels of the input images, thus obtaining the input image. .
[0032] Step 2: Construct the MWTNet network and use the MWTNet network to process the image obtained in Step 1 to obtain feature maps; The specific process of step 2 is as follows: Step 2.1: Construct the first stage of MWTNet. The first stage consists of one Stem module and three WMB modules. The WMB module structure includes a bottleneck structure, a Wavelet Attention module, and an MLP module; the input image obtained in Step 1.2 is then processed. The feature maps learned in the first stage are passed to the first stage of MWTNet to obtain the feature maps learned in the first stage. Step 2.2: Construct the second stage of MWTNet. The second stage consists of a Patch Embedding module and 6 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M1 obtained in Step 2.1.5 is passed to the second stage of MWTNet to obtain the feature map learned by the second stage. Step 2.3: Construct the third stage of MWTNet. The third stage consists of a Patch Embedding module and 12 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M2 obtained in Step 2.2.5 is passed to the third stage of MWTNet to obtain the feature map learned by the third stage. Step 2.4: Construct the fourth stage of MWTNet. The fourth stage consists of a Patch Embedding module and three WMB modules. The WMB module contains a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M3 obtained in step 2.3.5 is passed to the fourth stage of MWTNet to obtain the feature map learned by the fourth stage.
[0033] Step 3: Input the feature map obtained in Step 2 into the classification head for classification and obtain the classification result.
[0034] Step 3 specifically involves: The feature map obtained in step 2.4 is passed through a Batch Normalization (BN) layer, and then global average pooling is performed, which means averaging the feature map in the spatial dimension to obtain a one-dimensional feature vector. Finally, this feature vector is passed through a fully connected classification head to obtain the score of each category, and the category with the highest score is the classification result of the image.
Claims
1. An image classification method based on wavelet attention mechanism, characterized in that, Specifically: Step 1: Select the training sample set and the test sample set, and perform preprocessing operations on the images in the training sample set and the test sample set; Step 2: Construct the MWTNet network and use the MWTNet network to process the image obtained in Step 1 to obtain feature maps; Step 3: Input the feature map obtained in Step 2 into the classification head for classification and obtain the classification result.
2. The image classification method based on wavelet attention mechanism according to claim 1, characterized in that, The specific process of step 1 is as follows: Step 1.1: Select m images of size 3×H×W as the training sample set; select n images of size 3×H×W as the test sample set; Step 1.2 involves preprocessing the images in the training and testing sample sets obtained in Step 1.1, including random horizontal flipping, random cropping, random rotation, and normalization, to ensure consistency in the size and number of channels of the input images, thus obtaining the input image. .
3. The image classification method based on wavelet attention mechanism according to claim 1, characterized in that, The specific process of step 2 is as follows: Step 2.1: Construct the first stage of MWTNet. The first stage consists of one Stem module and three WMB modules. The WMB module structure includes a bottleneck structure, a Wavelet Attention module, and an MLP module; the input image obtained in Step 1.2 is then processed. The feature maps learned in the first stage are passed to the first stage of MWTNet to obtain the feature maps learned in the first stage. Step 2.2: Construct the second stage of MWTNet. The second stage consists of a Patch Embedding module and 6 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M1 obtained in Step 2.1.5 is passed to the second stage of MWTNet to obtain the feature map learned by the second stage. Step 2.3: Construct the third stage of MWTNet. The third stage consists of a Patch Embedding module and 12 WMBs. The WMB module includes a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M2 obtained in Step 2.2.5 is passed to the third stage of MWTNet to obtain the feature map learned by the third stage. Step 2.4: Construct the fourth stage of MWTNet. The fourth stage consists of a Patch Embedding module and three WMB modules. The WMB module contains a bottleneck structure, a Wavelet Attention module, and an MLP module. The feature map M3 obtained in step 2.3.5 is passed to the fourth stage of MWTNet to obtain the feature map learned by the fourth stage.
4. The image classification method based on wavelet attention mechanism according to claim 3, characterized in that, Step 2.1 specifically involves: Step 2.1.1: First, determine that the Stem module contains two 3×3 Convs for the input image. Perform initial feature extraction and reduce spatial dimensions; then, use the input image obtained in step 1.
2. After passing through two 3×3 Conv modules in the Stem module, the feature map is reduced to 1 / 4 of its original size, and the number of channels is increased to C1, thus obtaining the feature map. Where C1 represents the number of channels in the feature map, H represents the height of the feature map, and W represents the width of the feature map; Step 2.1.2: First, determine that the bottleneck structure includes two 1×1 Convs and one 3×3 DWConv; then, use the feature map obtained in Step 2.1.
1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv with a bottleneck structure, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.1.3: Process the feature map from step 2.1.
2. The input is fed into the Wavelet Attention module to obtain the feature map. ; Specifically, the Wavelet Attention module consists of a projection matrix, two 1×1 Convs, a WaveletTransformer, and a Scaled Dot-Product Attention. Then, the feature map obtained in step 2.1.2 Expand into a sequence form, then use a projection matrix to perform linear projection to generate a query. ,key ,value Three tensors, as shown in formula (1): (1) Among them, W qkv The projection matrix is learnable; Then, the value V is input into the Wavelet Transformer, and a wavelet transform operation is applied to the value V; The Wavelet Transformer consists of a Discrete Wavelet, two 1×1 Conv operations, a Concat operation, and an Interpolate operation. The feature processing flow of Wavelet Transformer is as follows: Step 1: Perform frequency domain decomposition on the value V using the Discrete Wavelet operation to obtain low-frequency components with structural feature information and high-frequency components with detailed feature information. The low-frequency components contain low-frequency information components. The high-frequency components include high-frequency information components in three directions, namely the horizontal information components. Vertical information components and diagonal information components The Discrete Wavelet operation is as shown in formulas (2)(3)(4)(5): (2) (3) (4) (5) Where Low(·) represents a low-frequency filter and High(·) represents a high-frequency filter; Step 2: Learn the feature representation of LL using 1×1 Conv, and upsample LL to the same spatial dimension as the input using the Interpolate operation to obtain the low-frequency feature V. L Simultaneously, the three high-frequency components HL, LH, and HH are concatenated, and the spatial dimension is restored through a 1×1 Conv operation using channel compression and interpolation to obtain the high-frequency feature V. H As shown in formulas (6) and (7): (6) (7) Where Concat(·) represents the concatenation operation, and Interpolate(·) represents the interpolation operation; Next, the low-frequency feature V L Element-wise multiplication with key K essentially uses global structural information as a priori to enhance the response of key K in key regions, achieving semantic aggregation guided by low frequency. After passing through a 1×1 Conv, as shown in formula (8), the feature map is obtained. Simultaneously utilizing high-frequency feature V H Element-wise multiplication of query Q makes it focus more on regions with significant local changes, thereby enhancing the model's ability to distinguish details and achieving high-frequency enhanced detail matching. After passing through a 1×1 Conv, as shown in formula (9), the feature map is obtained. The expressions for formulas (8) and (9) are as follows: (8) (9) in, This indicates element-wise multiplication; Finally, , The sum V is input into Scaled Dot-Product Attention. First, the attention weights are calculated, and then the original value V is weighted and aggregated using the attention weights to generate the final attention output Out, as shown in Equation (10): (10) Input feature map A residual connection is made with the attention output Out to obtain the feature map. ; Step 2.1.4: First, determine that the MLP module consists of two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.1.3... After passing through a 1×1 Conv layer, followed by a Dropout layer to reduce dependencies between neurons and enhance the model's generalization ability, and then through another 1×1 Conv layer, the input of the first 1×1 Conv layer is residually connected to the output of the last 1×1 Conv layer to obtain the feature map. ; Step 2.1.5: Iterate through steps 2.1.2 to 2.1.4 three times to obtain the output of the first stage of MWTNet. .
5. The image classification method based on wavelet attention mechanism according to claim 3, characterized in that, Step 2.2 specifically involves: Step 2.2.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.1.5... After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C2, thus obtaining the feature map. ; Step 2.2.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.2.
1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.2.3: Process the feature map from step 2.2.
2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.2.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in Step 2.2.3... The feature map is obtained by passing the input of the first 1×1 Conv layer, the output of the last 1×1 Conv layer, and then the input of the first 1×1 Conv layer is followed by the output of the last 1×1 Conv layer. ; Step 2.2.5: Iterate through steps 2.2.2 to 2.2.4 six times to obtain the output of the second stage of MWTNet. .
6. The image classification method based on wavelet attention mechanism according to claim 3, characterized in that, Step 2.3 specifically involves: Step 2.3.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.2.5... After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C3, thus obtaining the feature map. ; Step 2.3.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.3.
1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.3.3: Process the feature map after step 2.3.
2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.3.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.3.
3. The feature map is obtained by passing the input of the first 1×1 Conv layer, the output of the last 1×1 Conv layer, and then the input of the first 1×1 Conv layer is followed by the output of the last 1×1 Conv layer. ; Step 2.3.5: Iterate through steps 2.3.2 to 2.3.4 12 times to obtain the output of the third stage of MWTNet. .
7. The image classification method based on wavelet attention mechanism according to claim 3, characterized in that, Step 2.4 specifically involves: Step 2.4.1: First, determine that the Patch Embedding module contains a 3×3 Conv, and reduce the spatial resolution and expand the number of channels of the input feature map; then, use the feature map obtained in step 2.3.5 After passing through a 3×3 Conv, the feature map is reduced to half its original size, and the number of channels is increased to C4, thus obtaining the feature map. ; Step 2.4.2: First, determine that the bottleneck structure consists of two 1×1 Convs and one 3×3 DWConv. Then, use the feature map obtained in Step 2.4.
1. The feature map is obtained by performing dimensionality upscaling through a 1×1 Conv, followed by a 3×3 DW Conv, and finally another 1×1 Conv for dimensionality reduction. The input of the first 1×1 Conv is then residually connected to the output of the last 1×1 Conv to obtain the feature map. ; Step 2.4.3: Process the feature map from step 2.4.
2. The input is fed into the same WaveletAttention module as in the first stage to obtain the feature map. ; Step 2.4.4: First, determine that the MLP module includes two 1×1 Conv layers and one Dropout layer, providing a high-dimensional representation space for the features and enabling full interaction between features from different channels; then, use the feature map obtained in step 2.4.3... The feature map is obtained by passing the input of the first 1×1 Conv layer, the output of the last 1×1 Conv layer, and then the input of the first 1×1 Conv layer is followed by the output of the last 1×1 Conv layer. ; Step 2.4.5: Iterate through steps 2.4.2 to 2.4.4 three times to obtain the output of the fourth stage of MWTNet. .
8. The image classification method based on wavelet attention mechanism according to claim 7, characterized in that, Step 3 specifically involves: The feature map obtained in step 2.4.5 After passing through a BN layer, global average pooling is then performed, which means averaging the feature maps in the spatial dimension to obtain a one-dimensional feature vector. Finally, this feature vector is passed through a fully connected classification head to obtain the score for each category, and the category with the highest score is the classification result for the image.