## 2 Materials and Methods
### Methods
#### 2.2.2 Attention Module  
Convolutional neural networks (CNNs) have shown excellent performance in extracting features from grid data. However, traditional CNNs treat all feature maps in each channel equally, disregarding the important differences among them. This approach fails to account for the varying densities of information contained in each channel. Additionally, the traditional pooling operation assumes equal importance for all spatial locations in the matrix, which may compromise model accuracy and efficiency by neglecting the importance of spatial differences.  
Figure 4: RF-SNSCNN-CA model technology flow chart.  
To address these limitations, the attention mechanism is introduced. It assigns different weights to different pieces of information, emphasizing important information with larger weights and de-emphasizing unimportant information with smaller weights [21]. By incorporating the attention module into the CNN architecture, the model can capture more comprehensive and targeted information in a more sensible manner, leading to improved accuracy and efficiency.  
In this study, the importance of driving factors is captured using channel attention through the neighborhood effect, while the variability of neighborhood influence is captured using spatial attention. This integration of attention mechanisms enables the model to effectively capture and utilize information, as illustrated in Figure 5.  
Its calculation formula is shown as  
\[F^{\prime} =M_{c}(F)\otimes F \tag{1}\] \[F^{\prime\prime} =M_{\text{s}}\left(F^{\prime}\right)\otimes F^{\prime} \tag{2}\]  
where \(F\) is the input data of size C \(\times\) H \(\times\) W, i.e., C channels with each channel data of size H \(\times\) W, which in this paper represents the neighborhood size of 51 \(\times\) 51.  
CBAM first aggregates the spatial information of the feature map using the average pooling operation and the maximum pooling operation to generate two different spatial context descriptors: \(F_{avg}^{c}\) and \(F_{max}^{c}\), which represent the average pooling feature and the maximum pooling feature, respectively. The two descriptors are then passed to the weight sharing network to generate the channel attention matrix \(M_{c}(F)\). Element-level summation is used to merge the output feature vectors. As shown, the channel attention is calculated as  
\[M_{c}(F)=\sigma(\text{MLP}(\text{AvgPool}(F))+\text{MLP}(\text{MaxPool}(F))) \tag{3}\]  
where \(\sigma\) is the sigmoid function. The intermediate data of \(F^{\prime}\), which is also of size C \(\times\) H \(\times\) W, is generated after channel emphasis by the channel attention layer.  
To compute the spatial attention, the average pooling and maximum pooling operations are first applied along the channel axis, and they are concatenated to generate a valid feature descriptor. On the connected feature descriptors, a convolutional layer is applied to generate a spatial attention matrix \(M_{\text{S}}(F)\). This matrix emphasizes or suppresses the spatial locations by assigning weights. The spatial attention is calculated as  
\[M_{\text{S}}(F)=\sigma\left(f^{\gamma\times\gamma}([AvgPool(F); MaxPool(F)])\right) \tag{4}\]  
Figure 5: Channel attention and spatial attention mechanism.  
where \(\sigma\) is a sigmoid function and \(f^{7\times 7}\) denotes a convolution operation with a convolution kernel size of \(7\times 7\).