## 3 Method
### Convolutional Neural Network Structure  
The neural network model used here (Figure 2) classifies musical instruments using spectrogram inputs. It consists of three residual blocks with 32, 64, and 128 filters, respectively, each followed by MaxPooling to reduce dimensions. Attention mechanisms are applied at multiple stages: Early Attention after the first block, Mid Attention after the second, and Late Attention after the third, along with Channel and Coordinate Attention to emphasize critical features. The output is flattened, passed through a dense layer with 512 units and ReLU activation, followed by a 40% dropout layer, and finally, a sigmoid activation layer for multi-label classification. The model uses binary cross-entropy loss, Adam optimizer, and accuracy as the metric.  
The combined use of Coordinate [7] and Channel Attention [37] mechanisms enable a more flexible, targeted, and thorough analysis of the spectrogram inputs. By adjusting focus along both spatial and channel dimensions, the model can learn hierarchical representations that capture combined spectrogram features of musical instruments with greater specificity. This multi-stage attention application supports improved generalization, even in challenging and noisy audio conditions. This architecture effectively combines residual  
Figure 1: (**a**) From top to bottom: Log-Mel Spectrogram shows frequency (Hz) over time, where brighter regions represent higher intensity in decibels (dB). Chroma Features capture pitch class profiles (C, C#, D, D#, etc.), with “#” indicating a sharp note in musical notation. Spectral Contrast represents the difference in intensity between spectral peaks and valleys across frequency bands (e.g., 6400+ Hz to 200–400 Hz), providing complementary information to the Log-Mel Spectrogram. Tonnetz encodes harmonic relationships such as tonic, minor third, major third, perfect fifth, minor seventh, and major seventh, which represent musical intervals over time. (**b**) Combined Spectrogram Features (all same size), (**c**) Combined Spectrogram Features (CST—1/4 Size), (**d**) Combined Spectrogram Features (CST—Half Size), and (**e**) Combined Spectrogram Features (CST—3/4 Size) illustrate normalized feature values scaled between 0 and 1, where brighter colors indicate values closer to 1, and darker colors indicate values closer to 0. This normalization ensures consistent visualization despite differences in the original scales (e.g., frequency reaching 8192 Hz in Log-Mel, compared to the Tonnetz scale with a maximum value of 6 (Major Seventh)).  
connections, attention mechanisms, and dense layers to achieve robust feature extraction and classification performance for musical instrument recognition tasks.  
We trained the CNN model for up to 500 epochs with a batch size of 32, using early stopping with a patience of 100 epochs to prevent overfitting and retain the best model weights. A learning rate reduction was applied with a patience of 50 epochs and a decay factor of 0.1 to fine-tune the learning process. Training also incorporated sample weights to address imbalances in the dataset. Detailed parameters are listed in Data Availability Statement (DAS) Section.