## 3 Materials and Methods
### Framework of Locally Activated Gated Network  
Figure 3 illustrates the framework of our proposed LGNet and its comparison with the classic classification network. Our proposed LGNet shares the same front-end network backbone as the classic classification network. Classic classification network directly feeds the representations into the linear fully connected layer and outputs the predictions. Such a method is not good at dealing with data distributions with large intra-class differences.  
For our proposed LGNet, we feed the representations into the gated routing network to compute the routing score. Denote the batch size as n, input spectrograms as \(x_{i}\), and the corresponding label as \(y_{i}\) (\(i\) = 1, 2...n). The front-end network takes \(x_{i}\) as input and outputs the representations \(r_{i}\). We use a linear gated routing layer \(G(\cdot)\) to learn the latent characteristics contained in the representations, and then output the routing score \(s_{i}=G(r_{i})\). Next, the activation function transforms the routing scores into the routing probabilities \(p_{i}\), whose value represents the probability of being assigned to the corresponding MLP layer. Take a structure composed of two MLPs as an example, when \(p_{i}\) = (0.75, 0.25), the representation will be sent to the first MLP layer. The model computes routing probabilities for all representations and assigns them to the best-matched MLP layer based on \(p_{i}\). MLP layers finally make predictions on the samples assigned to them.  
Figure 3: The framework of our proposed LGNet and its comparison with baseline classification network. “FC” represents fully connected layer, while “spec” represents spectrograms. This figure takes a batch with batch size = 4 as an example, the models are fed four independent samples, and output their corresponding predictions.  
Additionally, in order to pursue the stability of the model, we fix the parameters of the gated routing network after training for several epochs so that they will no longer be updated. This prevents changes in the parameters of the gated routing network from causing the allocation strategy to remain unfixed. The overall training flow for LGNet is detailed in Algorithm 1.  
```
Data: training samples \(X\) and label \(Y\). Input: convolutional layers \(f(\cdot)\); gated routing network \(G(\cdot)\); MLP layers \(L(\cdot)\); number of MLP layers \(\mathcal{N}\); activation function \(\sigma(\cdot)\); max epochs \(E\); routing early stop epoch \(\tau\).
1 whileepoch<\(E\)do
2 sample batches \((x_{i},y_{i})\sim(X,Y)\).
3 forall\((x_{i},y_{i})\)do
4 obtain music representations \(r_{i}\gets f(x_{i})\).
5 compute routing scores \(s_{i}\gets G(r_{i})\).
6 obtain routing probs \(p_{i}\leftarrow\sigma(s_{i})\).
7 obtain activated MLP id \(Z_{i}\gets argmax_{i}(p_{i})\).
8 compute logits \(logits_{i}\gets L_{Z_{i}}(r_{i})\).
9 compute loss \(\mathcal{L}^{i}=Crossentropy(logits_{i},y_{i})\).
10 ifepoch<\(\tau\)do
11 update layers \(f(\cdot),G(\cdot),L(\cdot)\) with loss \(\sum_{i}\{\mathcal{L}^{i}\}\).
12
13 else
14 update layers \(f(\cdot),L(\cdot)\) with loss \(\sum_{i}\{\mathcal{L}^{i}\}\).
```  
**Algorithm 1**The overall training flow for LGNet.