## 3 Proposed FFA-BiGRU Method
### Multi-Level Spatial Feature Learning
#### 3.1.1 Channel-Spatial Attention  
Since the log Mel-spectrogram of music is a pictorial representation, we believe that different spatial regions have varying degrees of importance for emotion classification. Meanwhile, different feature maps from the CNN-based spatial feature learning module also play distinct roles in emotion recognition. Therefore, the group architecture subnet employs channel-spatial attention to obtain importance at both the channel and spatial levels, as shown in Figure 2. The channel-spatial attention weights are calculated as follows.  
Channel Attention (CA) Channel attention is mainly used to expand the representation ability of the spatial feature learning module by assigning different weights to each feature map. This allows it to learn the importance of each channel adaptively, thereby better capturing the emotion information. The realization of the CA block is shown in Figure 2. First, the input feature maps \(x\) with dimension \(H\times W\times C\) are fed into a global average pooling layer to squeeze the global spatial information into a channel descriptor \(z\in\mathbb{R}^{C}\), and the \(c\)-th element of \(z\) is given as:  
\[z_{c}=F_{gp}(x_{c})=\frac{1}{H\times W}{\sum}_{i=1}^{H}{\sum}_{j=1}^{W}x_{c}(i,j), \tag{1}\]  
where \(x_{c}\) refers to the \(c\)-th channel feature map of \(x\), and \(x_{c}(i,j)\) represents the value of \(x_{c}\) at the position \((i,j)\). \(F_{gp}(\cdot)\) denotes the global pooling function. After global average pooling, the feature shape changes from \(H\times W\times C\) to \(1\times 1\times C\).  
Figure 2: Channel-spatial attention mechanism. The input feature maps are first scaled by channel attention weights and then by spatial attention weights. The filter size of Conv layers in both the CA and SA blocks is \(1\times 1\).  
Next, to obtain the channel attention weights, the average pooled feature maps are then fed into two convolutional layers, followed by a ReLU activation function and a sigmoid activation function, respectively. The channel attention weights are finally given by:  
\[s_{CA}=\sigma(Conv(\delta(Conv(z)))), \tag{2}\]  
where \(\sigma(\cdot)\) represents the sigmoid function, and \(\delta(\cdot)\) denotes the ReLU function. Both Conv layers utilize a 1 \(\times\) 1 convolution, with kernel numbers \(C^{{}^{\prime}}\) and \(C\), respectively. For each basic block, the two Conv layers in its channel attention module have the filter numbers \(C^{{}^{\prime}}=8\) and \(C=64\), respectively.  
Finally, the output of the CA block is obtained by scaling the input feature maps \(x\) with the attention weight vector \(s_{CA}\) as follows:  
\[x_{CA}=s_{CA}\otimes x, \tag{3}\]  
where \(\otimes\) denotes element-wise multiplication, and the attention values are broadcast along the spatial dimension during multiplication.  
Spatial Attention (SA) Considering that different regions of the music audio features may have different importance for emotion classification, the output from the CA block is subsequently fed into a spatial attention (SA) block. This allows the network to focus more on the important regions.  
As shown in Figure 2, the SA weight is computed by feeding the output \(x_{CA}\) of the CA block into two convolutional layers. The first layer is followed by a ReLU activation function, and the second is followed by a sigmoid activation function, respectively. Both convolutional layers use 1 \(\times\) 1 convolution filters with the filter numbers \(\hat{C}=8\) and 1, respectively. Therefore, the dimension of the SA weight is \(H\times W\times 1\). The SA weight is given by:  
\[s_{SA}=\sigma(Conv(\delta(Conv(x_{CA})))), \tag{4}\]  
Finally, the output of the SA block is obtained by scaling the input feature maps \(x_{CA}\) with the attention weight vector \(s_{SA}\) as follows:  
\[x_{SA}=s_{SA}\otimes x_{CA}, \tag{5}\]  
where \(\otimes\) also denotes element-wise multiplication, and the SA weight values are broadcast along the channel dimension during this multiplication.