Visual transformer classification method based on shunt decomposition attention

By introducing a split-decomposition attention mechanism into the Transformer model, and combining position-dependent local attention and sparse global grid attention, the problems of high computational cost and loss of details in visual Transformer recognition of small targets are solved, achieving more efficient feature preservation and improved recognition performance.

CN119027709BActive Publication Date: 2026-11-24CHONGQING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410900869.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2026-11-24
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

When dealing with small objects, the visual Transformer model suffers from high computational cost and cannot effectively preserve local feature details.

Method used

A more efficient split-decomposed attention mechanism, SDSA, is designed by concatenating location-dependent local attention and sparse global grid attention, combined with a multi-branch structure, to improve the Transformer classification model.

Benefits of technology

While maintaining the computational efficiency of the model, it effectively preserves the local feature details of small targets, improving the Top-1 accuracy of the model on the Mini-ImageNet and CIFAR-10 datasets by 6.34% and 3.93%, respectively.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119027709B_ABST
    Figure CN119027709B_ABST
Patent Text Reader

Abstract

This invention discloses a visual Transformer classification method based on split-factor attention. The method improves upon the PVT image classification algorithm by designing a more efficient split-factor attention algorithm (SDSA). It proposes decomposing attention into position-dependent local attention (PWSA) and sparse global attention (GridSA). By incorporating positional information into the local attention, each position receives the information most strongly dependent on itself. Concatenating PWSA and GridSA with a multi-branch structure allows attention to receptive fields of different sizes within the same layer, which is more conducive to the recognition of multi-scale objects. It has only linear complexity and can simultaneously model local details and global dependencies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a visual Transformer classification method based on split attention decomposition. Background Technology

[0002] In the field of deep learning visual models, the Transformer architecture has garnered significant attention in recent years due to its superior performance, particularly in tasks such as image classification and object detection. The rise of this architecture has not only driven innovation in model architecture design but also brought broad application prospects to the deep learning field. However, visual Transformer models face a major challenge in practical applications: their massive computational cost. To reduce computational cost, a common approach is to divide the image into image patches and stretch them into one-dimensional vectors as input to the self-attention mechanism. The size of the image patch can be seen as the sampling granularity of the feature map. Larger image patches correspond to coarser-grained sampling and lower computational cost; smaller image patches correspond to finer-grained sampling and higher computational cost. To reduce computational cost, ViT divides the image into 16×16 patches, while PVT and Shunted Transformer downsample the K and V feature maps. Although this method significantly reduces the computational burden of the model, the coarse-grained partitioning of the image patches often leads to the loss of local feature details, especially when dealing with small objects, a problem that is particularly prominent and affects the model's recognition performance.

[0003] To address this challenge, researchers have proposed methods based on local attention. This approach effectively reduces computation by modeling relationships within a local window, while maintaining the ability to model local features. However, similar to convolutional methods, local attention also has limitations: it cannot directly model global dependencies. Obtaining global dependencies often requires stacking multiple layers of attention mechanisms, which contradicts the original intention of using attention mechanisms. Therefore, in the research of visual Transformer models, how to effectively preserve the local feature details of small objects while maintaining model computational efficiency remains a pressing problem. Summary of the Invention

[0004] In view of the above-mentioned technical problems in the background art, the technical problem to be solved by the present invention is: how to effectively preserve the local feature details of small targets while maintaining the computational efficiency of the model.

[0005] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: a visual Transformer classification method based on split attention, comprising the following steps:

[0006] S1: Obtain several publicly labeled images as a training set, with one image serving as a training sample.

[0007] S2: Construct and train an improved Transformer classification model. The improved Transformer classification model improves the attention mechanism of the existing Transformer classification model by replacing the spatial reduction attention with a more efficient split decomposition attention (SDSA). The SDSA is composed of a concatenated local attention PWSA and a sparse global grid attention GridSA, and a multi-branch structure is designed in PWSA and GridSA.

[0008] The training samples from the training set are input into the improved Transformer classification model. The model passes through an image patch embedding layer, a split-decomposition attention module, and a feedforward neural network, continuously updating the feature map. Finally, a linear layer outputs the final predicted classification result. The loss between the true and predicted labels of the training samples is calculated, and backpropagation is used to calculate the gradient of each layer's parameters. The model parameters are adjusted based on the calculated gradients to minimize the loss function. This process is iterated until the loss function is minimized, at which point the trained Transformer classification model is obtained.

[0009] S3: Input an image to be classified into the trained Transformer classification model. The trained Transformer classification model calculates the probability value of the image to be classified into each class and outputs the class corresponding to the highest probability value as the predicted class of the image to be classified.

[0010] Furthermore, in S2, the process of feeding the features output from the image patch embedding layer into SDSA to calculate the feature map corresponding to each training sample is as follows:

[0011]

[0012] X1 = X + Concat(head1, ..., head) h W O

[0013]

[0014] X2 = X1 + Concat(head1, ..., head) h W O

[0015] Output = X² + MSLE_FFN(LN(X²))

[0016] Among them, input features First, position-dependent local attention PWSA is applied, where k1 and k2 represent the window sizes used by the two attention heads, h represents the number of attention heads, and W... O X1 represents the linear projection layer that finally merges the multi-head attention. X1 represents the local attention calculation results of multiple heads, and performs residual connections. X1 is used as the input of the sparse global grid attention GridSA. The grid sizes of the two branches in the grid attention are G1 and G2. X2 represents the global attention results of multiple heads, and performs residual connections. Then, X2 is input into the feedforward neural network MSLE_FFN with multi-scale local enhancement. Output is the feature output of the attention module.

[0017] Furthermore, the PWSA processing procedure is as follows:

[0018]

[0019] Q i ,K i V i =Reshape(Q) i Win k (K i ),Win k (V i ))

[0020]

[0021] PWSA(X)=Concat(head0,…,head h W O

[0022] Where X represents the input feature, W i Q W i K W i V These are the initialization matrices corresponding to Q, K, and V of the i-th head, respectively. i K i V i This indicates that multiplying the input features by the corresponding matrix yields a feature map. Wink(·) represents the aggregation of features within a k×k window along the channel dimension. Q is updated through the Reshape operation. i K i V i Features, head i This represents the attention calculation result obtained by each attention head, where Softmax is the activation function, and d h Let W be the hidden layer dimension, PWSA represent location-dependent local attention, and W... OThis represents the linear projection layer that finally merges the multi-head attention.

[0023] Furthermore, the processing procedure for GridSA is as follows:

[0024] X' = ​​Split G (X)

[0025]

[0026] GridSA(X,G)=Concat(head0,…,head h W O

[0027] Among them, Split G This indicates that the Q, K, and V feature maps are divided into G×G image blocks, and GridSA indicates that grid attention is performed.

[0028] Compared with the prior art, the present invention has at least the following beneficial effects:

[0029] This invention addresses the limitation of the Visual Transformer (PVT) algorithm in simultaneously modeling local details and global dependencies. It improves upon the PVT image classification algorithm by designing a more efficient Split Decomposition Attention (SDSA) mechanism. This mechanism decomposes attention into Position-Related Local Attention (PWSA) and Sparse Global Grid Attention (GridSA). By incorporating positional information into local attention, each position receives interaction with information most strongly dependent on itself, thus facilitating the modeling of local information. Concatenating PWSA and GridSA with a multi-branch structure allows attention to receptive fields of different sizes within the same layer, improving the recognition of multi-scale objects. This approach boasts only linear complexity and can simultaneously model local details and global dependencies. Finally, the model combining image patch processing techniques and the split decomposition attention mechanism is named Split Decomposition Transformer (SDT). The effectiveness of the proposed model is validated on the Mini-ImageNet and CIFAR-10 datasets. Compared to the baseline model PVT, the Top-1 accuracy on both datasets is improved by 6.34% and 3.93%, respectively. Attached Figure Description

[0030] Figure 1 This is a location-dependent local attention mechanism.

[0031] Figure 2 This is a schematic diagram of grid attention.

[0032] Figure 3 This is a diagram illustrating the breakdown of attention.

[0033] Figure 4 Diagram of attention decomposition for stream diversion

[0034] Figure 5 The heatmap visualization results for four types of objects. Detailed Implementation

[0035] This invention proposes a more efficient attention mechanism that decomposes attention into local attention and sparse global attention, and sets up multi-branch attention to receptive fields of different scales on the local and global attention modules respectively, thereby improving the recognition performance of objects of different sizes.

[0036] 1. Location-dependent local attention mechanisms

[0037] In Swin's local attention approach, a k×k local window is defined, and a self-attention mechanism is performed within the window. However, this non-overlapping window partitioning method results in features at the window edges performing attention calculations on features on one side, lacking symmetrical features. Simultaneously, pixels at the window center receive more comprehensive local information than those at other locations. For example, in... Figure 1 In the left image, the pixel marked with a pentagram performs local attention calculations with all pixels in its upper left (within the black box), but lacks feature interactions with the right and bottom sides, thus disrupting symmetry and locality. According to ViT and DETR visualizations, queries within different semantic regions involve completely different key-value pairs; forcing all queries to process the same key and value pair may be suboptimal. Generally, images have a stronger visual dependence on nearby regions than on distant regions. Therefore, this invention proposes a position-related window self-attention (PWSA) mechanism based on the original local attention mechanism. It divides the window around the pixel's position (i, j), allowing each position to receive the information interaction most strongly related to itself. This overlapping division method preserves feature locality, such as... Figure 1 As shown in the right figure, a local window centered on the pixel itself is set.

[0038] Specifically, the input features are first multiplied by different weight matrices to obtain Q, K, and V feature maps. For the K and V feature maps, feature values ​​within a k×k region centered on the current position are aggregated at each location. In this way, each pixel on the Q feature map can correspond to K and V features related to its own position, thus realizing a position-related local attention mechanism. The overall calculation process is shown in formula (1).

[0039]

[0040] Where X represents the input feature, Wi Q W i K W i V These are the initialization matrices corresponding to Q, K, and V of the i-th head, respectively. i K i V i This indicates that multiplying the input features by the corresponding matrix yields a feature map. Wink(·) represents the aggregation of features within a k×k window along the channel dimension. Q is updated through the Reshape operation. i K i V i Features, head i This represents the attention calculation result obtained by each attention head, where Softmax is the activation function, and d h Let W be the hidden layer dimension, PWSA represent location-dependent local attention, and W... O Let represent the final linear projection layer that merges multi-head attention. Wink(·) represents the aggregation of features within a k×k window along the channel dimension. Therefore, the sizes of the K and V feature maps are...

[0041] Q i K i V i The transformations are as follows:

[0042]

[0043] Where d = C / h, h represents the number of attention heads, H, W, and C represent the height, width, and number of channels of the input feature, respectively, and k is the size of the local window.

[0044] 2. Sparse Global Grid Attention Mechanism

[0045] Grid attention employs an adaptive image patch size method, dividing the input image into a fixed number of G×G blocks. The size of the image patch is H / G × W / G. For example... Figure 2 As shown, the image is divided into 3×3 blocks, and pixels at the same position in each block are grouped together. Pixels of the same color calculate attention between each other, similar to dilated convolution, thus it is a sparse global attention mechanism.

[0046] The calculation process of the grid attention diagram is shown in formula (3).

[0047]

[0048] Among them, Split GThis indicates that the Q, K, and V feature maps are divided into G×G image blocks, where Q... i K i V i This indicates that multiplying the input features by the corresponding matrix yields a feature map, head. i This represents the attention calculation result obtained by each attention head, where Softmax is the activation function, and d h For the hidden layer dimension, GridSA indicates performing grid attention, W O This represents the linear projection layer that finally merges the multi-head attention.

[0049] Split G The transformation of (X) is as follows:

[0050]

[0051] Where d = C / h, and h represents the number of attention heads.

[0052] 3. Attention splitting mechanism

[0053] This invention proposes a decomposing attention mechanism that fuses local and global information, named DSA (Decomposing Self-Attention). Figure 3 As shown, by concatenating the location-dependent local attention proposed in this invention with sparse global grid attention, both local and global receptive fields can be acquired simultaneously in the same layer, enabling interaction between local and global information. This preserves locality while possessing the ability to model global dependencies. Compared to global self-attention, it retains local feature information; compared to local self-attention, it has the ability to model global dependencies. Furthermore, the performance and computational cost of the model can be balanced by adjusting the size of the local attention image patches and the number of grid attention points.

[0054] Due to the multi-scale nature of objects, existing attention mechanisms perform poorly in recognizing objects of different scales in natural scenes. This is attributed to the fact that each image patch in the attention layer has a uniform information granularity and a receptive field of the same size, thus failing to capture features of different scales simultaneously. To effectively model objects of different scales within the same layer, the "Shuted" concept from the Shunted Transformer is incorporated into DSA. Multiple branches are added to both location-dependent local attention and sparse global grid attention, obtaining receptive fields of different sizes within a single layer. This mechanism is named Shunted Decomposing Self-Attention (SDSA). Figure 4 As shown.

[0055] The calculation process for splitting and decomposing attention is as follows:

[0056]

[0057] X1 = X + Concat(head1, ..., head) h W O

[0058]

[0059] X2 = X1 + Concat(head1, ..., head) h W O

[0060] Output=X2+MSLE_FFN(LN(X2)) (5)

[0061] Among them, input features First, the local attention PWSA with two branches has local window sizes of k1 and k2. The local attention calculation results from multiple heads are aggregated and residual connections are made. The output is used as the input to the sparse global grid attention, where the grid sizes of the two branches are G1 and G2. The global attention results from multiple heads are aggregated as the output, residual connections are made, and the output is fed into the multi-scale local augmentation feedforward neural network MsLe_FFN.

[0062] 4. Analysis of the computational cost of attention decomposition

[0063] In the attention calculation, two matrix multiplications are used: multiplying an m×n matrix with an n×r matrix. Each position in the output (shown in the black box) undergoes n multiplications, resulting in a total of mnr operations. Since K and V are of the same size in the attention calculation, the computational cost of multiplying the three matrices Q, K, and V is 2mnr.

[0064] For a conventional multi-head self-attention MSA, for the input The computational cost is shown in formula (6), which mainly consists of the computational cost of obtaining the Q, K, and V matrices through linear transformation, the computational cost of multiplying the Q, K, and V matrices in the self-attention mechanism, and the computational cost of multiplying with the weight matrix when concatenating the multi-head attention.

[0065]

[0066] Where h represents the number of attention heads.

[0067] The computational cost of local attention W-MSA is shown in Equation (7):

[0068]

[0069] Where M is the window size of local attention, which is set to 7 in this invention. Compared with formula (6), it can be found that the complexity of W-MSA is proportional to the image size and is reduced to linear complexity.

[0070] The computational cost of the location-dependent local attention PWSA proposed in this invention is shown in Equation (8):

[0071]

[0072] Where k is the size of the local window. Compared with W-MSA, location-dependent local attention does not increase the computational cost of the model, while obtaining feature representations with higher location dependence.

[0073] The computational cost of sparse global grid attention is shown in Equation (9):

[0074]

[0075] Where G is the size of the grid. Grid attention has a computational cost that is linearly related to the image size, and is a sparse global attention mechanism.

[0076] The proposed decomposed attention mechanism is obtained by concatenating position-improved local attention and grid attention. Ignoring constant terms k and G, the decomposed attention is the sum of the computational costs of local and global attention, which also has linear complexity. Compared with W-MSA, it can have a global receptive field with only an increase in linear computation, and also has multi-scale characteristics, resulting in better recognition performance.

[0077] Introduction to MS-PVT:

[0078] An improvement to the PVT image classification method is proposed, incorporating multi-scale feature fusion into image patches. This leads to the development of a multi-scale feature fusion image patch embedding layer (MSFF_PE), which enriches the multi-scale feature information within image patches and enhances their feature representation capabilities through a lightweight multi-scale feature fusion module. To address the lack of local information modeling in the encoder structure, a multi-scale local enhancement feedforward neural network layer (MSLE_FF) is proposed. This layer reconstructs the one-dimensional sequence output by the attention mechanism into a two-dimensional image for local information interaction and introduces distance importance to obtain weighted information about local features. Finally, these improvements are incorporated into a baseline model named MS-PVT.

[0079] MSFF_PE specifically refers to:

[0080] y1 = conv7(input)

[0081] y2 = MSFF(y1)

[0082] y3 = conv2(y2)

[0083] patch1, ..., patch n =flatten(y3)×E

[0084] in, This represents the input image MSFF_PE, conv k This indicates a convolution with kernel size k. MSFF represents the multi-scale feature fusion module imp_Inception(a). The stride of both conv7 and conv2 convolutions is set to 2. The MSFF module does not change the size of the input feature map, so the output after the image patch embedding layer... "Flatten" means stretching the spatial dimensions of the feature, i.e., length H and width W, resulting in n = H / 4 × W / 4 image patches. It is a fully connected layer, therefore the output is... This serves as the input to the attention layer. H, W, and C represent the height, width, and channel dimensions of the feature map of the input image, respectively, while D represents the dimension set for the hidden layer.

[0085] MSLE_FF specifically refers to:

[0086] x1 = FC(input”; θ1)

[0087] y'1' = DWconv3(x1)

[0088] y'2' = DWDilated3conv3(x1)

[0089] y'3'=GELU(x1+y'1'+y'2' / d)

[0090] output" = FC(y'3'; θ2)

[0091] Where "input" represents the input feature map of MSLE_FF, "output" represents the output of MSLE_FF, θ1 and θ2 represent the dropout parameters, FC represents a fully connected layer, and y i " represents the output of the i-th layer, DWDilated m conv n This represents dilated convolution with an expansion rate of d = m and a kernel of k = n.

[0092] Introduction to LightPVT:

[0093] LightPVT, or Lightweight Visual Transformer Classification Method, is based on an improved Transformer classification model. This improved model replaces the space reduction layer in the existing Transformer classification model's space reduction attention with a soft segmentation downsampling module. The computation process of the soft segmentation downsampling module is as follows:

[0094] Q i =XW i Q ,K i =XW i K V i =XW i V

[0095] K i =SSD(K) i ,R i ),V i =SSD(K) i ,R i )

[0096] V i =V i +LE(V i )

[0097]

[0098] SSD-SRA(X)=Concat(head0,…,head h W O

[0099] In the formula, SSD-SRA represents the soft segmentation downsampling module, SSD represents spatial reduction attention, LE represents the local enhancement layer, X represents the input feature, and W represents the input feature. i Q W i K W i V These are the initialization matrices corresponding to Q, K, and V of the i-th head, respectively. i K i V i This indicates that multiplying the input features by the corresponding matrix yields a feature map, R. i K represents the downsampling coefficient mentioned above. i V i After the feature map is reduced by the soft segmentation downsampling module, head i This represents the attention calculation result obtained by each attention head, where Softmax is the activation function, and dh Let W be the hidden layer dimension, SEAttn represent SE attention, and W be the hidden layer dimension. O This represents the linear projection layer that finally merges the multi-head attention.

[0100] The soft segmentation downsampling module uses depthwise separable convolution instead of ordinary convolution, and adds a channel fusion module after the concatenated attention. The calculation process is as follows:

[0101] Q i =XW i Q ,K i =XW i K V i =XW i V

[0102] K i =LightSSD(K i ,R i ),V i =LightSSD(K i ,R i )

[0103] V i =V i +LE(V i )

[0104]

[0105] LightSRA(X)=SEAttn(Concat(head0,…,head h W O )

[0106] LightSSD represents a soft segmentation downsampling module using depthwise separable convolution, LightSRA represents an improved lightweight spatial reduction attention, and SEAttn represents SE attention.

[0107] The LightSSD process involves dividing the input features into two branches along the channel dimension, with one branch being concatenated. One convolutional layer, and another branch with a stride of R. i Max pooling.

[0108] 5. Experimental Results and Analysis

[0109] The MS-PVT model and the proposed split-stream decomposition attention were experimentally validated on the Mini-ImageNet and CIFAR-10 datasets. Experiments were conducted using an A100 GPU, PyTorch 1.7.1, and Python version 3.7. We employed common training strategies for visual Transformers, using the same data augmentation and regularization techniques as DeiT to prevent overfitting, such as Mixup, RandAugment, and CutMix. The model was trained for 300 epochs using the AdamW optimizer with a weight decay of 0.05 and a learning rate of 5×10⁻⁶. -4 The Mini-ImageNet dataset has a batch size of 128, while the CIFAR-10 dataset has a batch size of 64.

[0110] Mini-ImageNet is a dataset created by the Google DeepMind team from the ImageNet dataset, extracting images from 100 categories. Each category contains 600 images, totaling 60,000 images. Because this dataset is designed for small sample sizes, its training set contains 64 categories, the validation set contains 16 categories, and the test set contains 20 categories. Therefore, preprocessing of the dataset is necessary. By collecting images according to categories and dividing them into training and test sets in an 8:2 ratio, a dataset suitable for image classification was obtained. Mini-ImageNet has 100 categories, covering a diverse range of categories from various animals, portraits, food, and landscapes. The training set contains 48,000 images, and the test set contains 12,000 images.

[0111] (1) Evaluation of the results of the diversion and decomposition of attention mechanism

[0112] To verify the effectiveness of the proposed method, the MS-PVT model was used as the baseline model. Meanwhile, a combination of local attention in Swing and grid attention in MaxViT was used as the comparative model for the proposed decomposition and split attention model, referred to as W-GridSA. The decomposition attention DSA and split decomposition attention SDSA were then validated. The Top-1 accuracy, Top-5 accuracy, precision, recall, F1 score, and number of model parameters for each model are shown in Tables 1 and 2.

[0113] Table 1 Performance metrics of the split-decomposition attention model on the Mini-ImageNet dataset.

[0114]

[0115] Table 2 Performance metrics of the split-decomposition attention model on the CIFAR-10 dataset.

[0116]

[0117] As shown in Tables 1 and 2, W-GridSA, DSA, and SDSA all outperform the original attention mechanism. This demonstrates the effectiveness of decomposing global attention into local attention and sparse global grid attention, reducing the complexity of attention to a linear relationship with image size while maintaining accuracy. Comparing W-GridSA and DSA attention reveals that, with the same number of parameters, introducing location-dependent local attention allows pixels to focus on their own local features, resulting in superior performance. Compared to MS-PVT, DSA improves Top-1 accuracy by 0.62% and 0.85% on the Mini-ImageNet and CIFAR-10 datasets, respectively. The SDSA model, which incorporates multiple branches, only improves performance by 0.12% and 0.16% compared to DSA. This may be because decomposing attention already effectively learns locality, thus limiting the effectiveness of finer-grained local and grid attention.

[0118] We conducted a weight heatmap visualization experiment on the visual Transformer model SDT using SDSA attention, such as... Figure 5 As shown, four object types—dogs, boats, jellyfish, and birds—were selected, and the output of the last attention layer in the first stage was visualized. The four rows in the figure represent dogs, boats, jellyfish, and birds, respectively, while the three columns represent the visualization results of the original image, the MS-PVT model, and the SDT model. The redder the color, the greater the weight, corresponding to the part the model focuses on; the lighter the color, the smaller the weight, corresponding to the part the model focuses on more coarsely. The figure shows that the SDT model focuses on the target better than the baseline model, and its performance in recognizing small targets is also improved. For example, the dog in the first row, the middle of the boat and the body of the jellyfish in the second row, and the two birds in the fourth row, all show improved performance. Although other weights are still assigned to the branches, the birds are redder, indicating that the network focuses more on the target itself. This demonstrates that the proposed method of decomposing global attention into local attention and sparse global grid attention has a better ability to model small targets and can largely preserve the local details of small targets.

[0119] (2) Performance comparison of mainstream methods

[0120] We used the Mini-ImageNet and CIFAR10 datasets to compare with mainstream methods in the field of image splitting. All models were trained from scratch without using pre-trained weights until convergence. All experimental settings were the same as in (1). The Top-1 accuracy, Top-5 accuracy, precision, recall, F1 score and number of model parameters for each model are shown in Tables 3 and 4.

[0121] Table 3 Performance comparison of mainstream methods on the Mini-ImageNet dataset

[0122]

[0123] Table 4 Performance comparison of mainstream methods on the CIFAR-10 dataset

[0124]

[0125] As shown in Tables 3 and 4, the Top-1 accuracy of ViT on the two datasets is 60.02% and 72.39%, respectively. This is significantly lower than its performance on large-scale datasets, reflecting the inability of visual Transformers to capture two-dimensional image attributes, resulting in poor performance on small-to-medium-scale datasets. Similar visual Transformer models to ViT include DeiT, TNT, and PVT. Models such as BiFormer-S, Shunted-S, and our proposed MS-PVT, which use overlapping convolutions to divide image patches, still achieve good performance on small-to-medium-scale datasets. Therefore, it can be seen that the performance of PVT is effectively improved after using the proposed image patch processing technique. The LightPVT method, based on a lightweight spatial reduction attention mechanism, has the fewest parameters among many models and outperforms most visual Transformer models, proving the effectiveness of the proposed lightweight spatial reduction attention mechanism. The SDT method based on the split attention mechanism improved the Top-1 accuracy of the baseline model by 6.34% and 3.93% on the two datasets, respectively. It can improve the detection performance of the model while reducing the number of parameters, and also achieves better accuracy compared with other visual Transformer and convolutional neural network models.

Claims

1. A visual Transformer classification method based on split attention decomposition, characterized in that, Includes the following steps: S1: Obtain several publicly labeled images as a training set, with one image serving as a training sample; S2: Construct and train an improved Transformer classification model. The improved Transformer classification model improves the attention mechanism of the existing Transformer classification model by changing the spatial reduction attention to split decomposition attention SDSA. The SDSA is composed of position-dependent local attention PWSA and sparse global grid attention GridSA concatenated, and a multi-branch structure is designed in PWSA and GridSA. The training samples are input into the improved Transformer classification model, passing through an image patch embedding layer, a split decomposition attention module, and a feedforward neural network to continuously update the feature map. Finally, the final predicted classification result is output through a linear layer. The loss between the true label and the predicted label of the training samples is calculated, and the gradient of the parameters of each layer of the model is calculated using backpropagation. The model parameters are adjusted according to the calculated gradient to minimize the loss function. The above steps are iterated until the loss function is minimized, at which point the trained Transformer classification model is obtained. S3: Input an image to be classified into the trained Transformer classification model. The trained Transformer classification model calculates the probability value of the image to be classified into each class and outputs the class corresponding to the highest probability value as the predicted class of the image to be classified.

2. The visual Transformer classification method based on split attention as described in claim 1, characterized in that, In step S2, the process of feeding the features output from the image patch embedding layer into SDSA and calculating the feature map corresponding to each training sample is as follows: Among them, input features First, it undergoes location-dependent local attention PWSA. and These represent the window sizes used by the two attention heads, and h represents the number of attention heads. This represents the linear projection layer that finally merges multi-head attention. This represents the results of local attention calculations from multiple heads, followed by residual connections. As input to the sparse global grid attention GridSA, the grid size of the two branches in the grid attention is... and , This represents the aggregation of global attention results from multiple heads, followed by residual connections, and then... Input into a feedforward neural network with multi-scale local augmentation In this context, Output represents the final output feature of the attention module.

3. The visual Transformer classification method based on split attention as described in claim 2, characterized in that, The PWSA processing procedure is as follows: Where X represents the input feature. , , Let Q, K, and V be the initialization matrices corresponding to the i-th head, respectively. , , This means that multiplying the input features by the corresponding matrix yields a feature map. This represents features aggregated within a k×k window along the channel dimension, updated via a Reshape operation. , , feature, This represents the attention calculation result obtained by each attention head, where Softmax is the activation function. For the hidden layer dimension, PWSA represents location-dependent local attention. This represents the linear projection layer that finally merges the multi-head attention.

4. The visual Transformer classification method based on split attention decomposition as described in claim 3, characterized in that, The processing procedure for GridSA is as follows: in, This means dividing the Q, K, and V feature maps into G×G image blocks. This indicates that grid attention is being performed.