## 3 Network Model Design
### Feature Extraction Layer
#### 3.2.2 Transformer Model Structure  
In the process of modulation recognition, capturing global features can avoid the interference of local noise and further improve the accuracy of classification. However, the single ResNet model structure needs to continuously stack convolutional layers to extract global features, which significantly increases the number of parameters in the entire network. The Transformer can establish long-distance dependencies through multi-head self-attention. While effectively capturing global features, it can also effectively reduce the number of network parameters. The structure of the Transformer model is shown in Figure 5.  
The yellow part in Figure 5 represents the calculation of the linear projection of the input sequence. \(l\) represents the number of heads \(h\). For the \(i\)-th head \(h_{i}\), its query matrix \(Q_{i}\), key matrix \(K_{i}\), and value matrix \(V_{i}\) can be expressed as:  
\[Q_{i}=XW_{i}^{Q},K_{i}=XW_{i}^{K},V_{i}=XW_{i}^{V} \tag{12}\]  
where \(X\in R^{n\times d}\) is the input sequence, \(n\) is the sequence length, and \(d\) is the feature dimension; \(W_{i}^{Q}\in R^{d\times d_{h}}\), \(W_{i}^{K}\in R^{d\times d_{h}}\), and \(W_{i}^{V}\in R^{d\times d_{v}}\) are the network parameters for the  
Figure 4: The model structure of ResNet.  
i-th head, with \(d_{k}\) denoting the feature dimension of \(Q\) and \(K\), and \(d_{v}\) denoting the feature dimension of \(V\).  
\[\begin{array}{rl}head_{i}&=\text{Attention}(Q_{i},K_{i},V_{i})\\ &=\text{Softmax}(\text{Scale}(Q_{i},K_{i}))V_{i}\\ &=\text{Softmax}(\frac{Q_{i}K_{i}^{T}}{\sqrt{d_{k}}})V_{i}\end{array} \tag{13}\]  
The blue part in Figure 5 represents the multi-head concatenation operation. The output \(head_{1},head_{2},\dots,head_{l}\) of the head \(l\) is concatenated along the feature dimension to obtain the head matrix \(Head\) as:  
\[Head=[head_{1},\dotshead_{l}] \tag{14}\]  
The red part in Figure 5 represents performing a linear projection on \(Head\) to obtain the output of the multi-head self-attention \(MultiHead(Q,K,V)\) as:  
\[\text{MultiHead}(Q,K,V)=[head_{1},\dotshead_{l}]W^{o} \tag{15}\]  
where \(W^{o}\in R^{ld_{x}\times d_{k}}\) is a network parameter used to ensure that the final output dimension matches the original input dimension while integrating information from different heads.  
The \"Mean\" in the gray part of Figure 5 indicates taking the mean of the output along the time dimension; \"LayerNorm\" indicates performing layer normalization on the output. The output of the multi-head self-attention \(\text{MultiHead}(Q,K,V)\) has a corresponding feature vector at each time step. However, in subsequent processing, only a single feature vector  
Figure 5: The model structure of Transformer.  
representing the entire sequence is needed. Therefore, it is also necessary to take the average value of MultiHead\((Q,K,V)\) in the time dimension to improve computational efficiency. Finally, to enhance the model's performance and training stability, layer normalization is performed on the averaged sequence to obtain the final output of the Transformer model structure.