## 3 The Proposed MMGAT Methods
### The Structure of the Proposed MMGAT  
Since different musical pieces have varying lengths, the corresponding feature matrices will have a different number of rows. This results in the instance correlation graphs having a variable number of nodes for each piece of music. To address this issue, we employ an attention mechanism as the primary feature extractor in MMGAT.  
Focusing solely on the similarity of instrument features at smaller scales leads to more precise differentiation, which can effectively identify different instruments within the same family. However, this may also result in misidentification due to the varying characteristics of the same instrument across different pitches and qualities. Conversely, if the focus is only on larger scales, this can reduce misidentification issues associated with different pitches of the same instrument, but it may make it harder to distinguish between different instruments within the same family. To address this challenge, MMGAT incorporates multiple attention scales, allowing attention features to be computed at various levels. As a result, a multi-scale self-attention layer is employed to extract features. This layer consists of three key components: a similarity function, attention coefficients, and multi-scale attention features. The similarity function, in particular, uses a hybrid measure to assess the similarity between pairs of node features, evaluating how closely two input vectors resemble one another.  
\[Sim(z_{a},z_{b})=[Cosine(z_{a},z_{b}),L1(z_{a},z_{b})] \tag{3}\] \[where,Cosine(z_{a},z_{b})=\frac{z_{a}z_{b}}{||z_{a}||,||z_{b}||}= \frac{\sum_{i=1}^{n}z_{a}z_{b}}{\sqrt{\sum_{i=1}^{n}(z_{a})^{2}}\times\sqrt{ \sum_{i=1}^{n}(z_{b})^{2}}},\] \[L1(z_{a},z_{b})=\sum_{i}|z_{ai}-z_{b}|\]  
where \(i\) is the \(i\)-th component of the input, and \(z_{a}\) and \(z_{b}\) are two input features of music. In order to capture diverse levels of influence arising from node similarity and customize this influence for the instrument recognition task, this paper designs cosine similarity as follows:  
\[Sim_{ij\in adj\_1} =NN\big{(}Hz_{i},Hz_{j}\big{)} \tag{4}\] \[=ReLU\big{(}W\times\big{[}\text{Cosine}\big{(}Hz_{i},Hz_{j}\big{)},L1\big{(}Hz_{i},Hz_{j}\big{)}\big{]}\big{)}\]  
where the parameters \(W\) and \(H\) are the used weights, \(z_{i}\) is the \(i\)-th input vector, \(z_{j}\) is thus the \(j\)-th feature vector, adj_1 is a scale of attention, and \(NN\)() is a neural network consisting of a single layer that employs the ReLU function to alleviate the gradient diminishing of cosine similarity. Building upon this similarity, we design the attention coefficient in the following manner:  
\[\alpha_{ij\in adj\_1}=\text{softmax}\big{(}Sim_{ij\in adj\_1}\big{)}=\frac{ \exp\Big{(}Sim_{ij\in adj\_1}\Big{)}}{\sum_{i}\exp\Big{(}Sim_{ij\in adj\_1} \Big{)}} \tag{5}\]  
where \(\alpha_{ij}\) is the attention coefficient in the scale of adj_1. According to these regional attention coefficients, the extracted attention feature \(h_{i}\) of the current audio segment i is calculated as  
\[h_{i}=ReLU\Big{(}NN\Big{(}\sum_{j}\alpha_{ij\in adj\_1}*z_{j}\Big{)}\Big{)} \tag{6}\]  
Our objective is to embed attention features based on the designed similarity function. By utilizing these extracted features, we incorporate a multi-head attention mechanism to form a multi-head attention block as follows:  
\[h_{i}=ReLU\Bigg{(}NN\Bigg{(}\sum_{j}\alpha_{ij\in adj\_1}*z_{j}\Bigg{)}\Bigg{)} \tag{7}\]After computing the attention features for a neighborhood adj_1 at a small scale, we then calculate attention features for two larger neighborhood scales. Specifically, this study examines three distinct scales: 1, 2, and 3.