## 3 Methodology
### Pretraining Phase
#### 3.2.2 ResNet-Transformer Hybrid Encoder  
In this paper, a multi-scale spatiotemporal feature fusion encoder is designed, which can jointly capture local and global features of radio frequency signals through alternating stacking of ResNet and Transformer modules. Specifically, for a one-dimensional (1D) raw signal of length \(L\), the model first undergoes 1D convolution, BatchNorm (BN), ReLU activation, and max pooling for embedding to obtain feature vectors. Subsequently, the use of ResNet modules and Transformer modules extracts more robust RFFs from the input feature vectors. Finally, an Adaptive Average Pooling (AdaptiveAvgPool) is applied to compress the temporal dimension to a fixed length, followed by a flatten operation that transforms the resulting tensor into a 1D feature vector. This produces a feature vector of dimension \(1\times d\), which is then passed into a nonlinear projection head to map the high-dimensional features into a lower-dimensional contrastive space. Additionally, it uses only the I part of the raw I/Q signal as input, avoiding the extra signal preprocessing step, making it easier to achieve end-to-end training and recognition. Figure 3 shows the specific architecture of the encoder. The proposed hybrid encoder stacks three ResNet modules and two Transformer modules to hierarchically extract discriminative RFFs, capturing both local features and global temporal dependencies. The three ResNet modules consist of [2, 4, 2] basic residual units, respectively. Each basic residual unit contains two 1D convolutional layers with \(7\times 1\) kernels, followed by BN and ReLU activation. Skip connections are incorporated to mitigate gradient vanishing, while adaptive downsampling is applied in the first unit of each module via a \(1\times 1\) convolutional layer when the stride or channel dimension changes. After the second and third ResNet modules, Transformer modules with positional encoding and multihead self-attention mechanisms are, respectively, inserted to model long-range interactions in the time domain. The following details the positional encoding and multihead self-attention mechanisms. Positional encoding: To inject positional information into the Transformer architecture, the absolute position coding defined by the sine function is adopted in this paper. For a given position \(pos\in[0,T-1]\) and dimension \(i\in[0,d_{model}-1]\), the encoding is computed as:  
\[PE_{(pos,2i)}=\sin(\frac{pos}{10000^{2i/d_{model}}}) \tag{7}\]  
\[PE_{(pos,2i+1)}=\cos(\frac{pos}{10000^{2i/d_{model}}}) \tag{8}\]  
where \(d_{model}\) denotes the feature dimension, \(T\) is the sequence length. This encoding is added element-wise to the reshaped ResNet output \(\mathbf{h}_{reshape}\in\mathbb{R}^{T\times B\times d_{model}}\) before feeding into the Transformer:  
\[\mathbf{h}_{pos}=\mathbf{h}_{reshape}+\mathbf{PE}(pos) \tag{9}\]  
where \(\mathbf{PE}(pos)\in\mathbb{R}^{T\times d_{model}}\), \(B\) is the batch size, and it is broadcast to \(T\times B\times d_{model}\) along the batch dimension to enable element-wise addition with \(\mathbf{h}_{reshape}\). Multihead Self-Attention: The implementation of the multihead attention mechanism is divided into three steps:  
1. Linear Projections: Initialize the weight matrices \(\mathbf{W}^{Q},\mathbf{W}^{K},\mathbf{W}^{V}\), and then calculate the \(\mathbf{Q},\mathbf{K},\mathbf{V}\) of each head, respectively, \[\mathbf{Q}=\mathbf{h}_{pos}\mathbf{W}^{Q},\quad\mathbf{K}=\mathbf{h}_{pos} \mathbf{W}^{K},\quad\mathbf{V}=\mathbf{h}_{pos}\mathbf{W}^{V}\] (10)  
Figure 3: The architecture of the proposed hybrid encoder. where \(\mathbf{W}^{Q},\mathbf{W}^{K}\in\mathbb{R}^{d_{model}\times d_{k}}\), \(\mathbf{W}^{V}\in\mathbb{R}^{d_{model}\times d_{v}}\), with \(d_{k}=d_{v}=d_{model}/n_{heads}\);
2.