# Detecting Selected Instruments in the Sound Signal
## 5 Used Architectures and Experimental Results
### Dense Neural Networks  
The first type of model constructed during the research was a dense neural network, the simplified diagram of which is shown in Figure 1. The created _MFCCs_ input data, which is matrix \(128\times 13\) at the beginning, needs to be flattened into one-dimensional data, which gives a vector of 1664 values (\(128\times 13\)). Such a vector of input data is processed by four consecutive layers, for which the weights of individual neurons will be set during the learning process. The last layer uses the activation function _softmax_, which causes the values of all outputs to sum to one. In practice, each output neuron symbolizes one of eight instruments, and their values indicate the probability of a given instrument appearing in the recording, determined by the model. The final decision takes the form of the index of the neuron with the highest value, i.e., the highest probability. Figure 1: Dense network diagram. This network architecture is marked as Model ANN1. The trained model correctly assigned 63% of the samples in the test set. This result is relatively satisfactory, but during training, the model very quickly achieved high accuracy and low error for the training data, but it failed to achieve similar results in relation to the validation data. Such dependence is a typical symptom of _overfitting_. One way to counteract overfitting is the so-called _drop-out_[41]. Therefore, drop-out layers were added in the second experiment, and the _drop-out rate_ value was selected through testing. Too small values caused the overfitting phenomenon, and too high values caused the network not to develop any patterns. The assessment of whether _overfitting_ was eliminated was based on the analysis of the change in accuracy and value of the loss function during training and validation. The results are described in Table 2.  
The optimal value turned out to be a drop-out rate of 0.1, for which the accuracy of the network with respect to the test data was 65%, and F1-score was 63%. This network architecture is marked as Model ANN2 in Table 3.  
At this point, it is necessary to consider how the overall accuracy is distributed among individual classes, i.e., instruments. The confusion matrix is included in Figure 2. Analyzing this matrix, we can see that clarinet samples are incorrectly recognized, mainly as piano and violin; electric guitar samples are 90% correctly recognized; female voice samples are correctly recognized in 84%; flute samples are only in 34% correctly recognized, but 22% and 39% of samples are incorrectly recognized, mainly as piano and violin; piano samples are 99% correctly recognized; tenor saxophone samples are incorrectly recognized mainly as electric guitar but also as piano and violin; trumpet samples are incorrectly recognized mainly as violin; violin samples are in 88% correctly recognized. In summary, we can say that the model rarely indicates clarinet, saxophone, and trumpet. The highest effectiveness was recorded for singing, electric guitar, piano, and violin. The model shows good sensitivity for these classes, but only for female singing can good precision be noted. The reasons for this state were seen in the so-called _dying ReLU_. \begin{table}
\begin{tabular}{c c c c c c} \hline
**Drop-Out Rate** & **Overfitting** & **Accuracy** & **Sensitivity** & **Precision** & **F1-Score** \\ \hline
0.05 & Yes & 0.62 & 0.60 & 0.61 & 0.60 \\ \hline
0.1 & No & 0.65 & **0.62** & **0.64** & **0.63** \\ \hline
0.2 & No & 0.60 & 0.60 & 0.61 & 0.60 \\ \hline
0.3 & No & 0.62 & 0.57 & 0.59 & 0.58 \\ \hline
0.4 & No & **0.66** & 0.50 & 0.49 & 0.49 \\ \hline
0.5 & No * & 0.48 & 0.12 & 0.01 & 0.02 \\ \hline
0.6 & No * & 0.22 & 0.12 & 0.01 & 0.02 \\ \hline \end{tabular} For each evaluation parameter, the best result obtained is presented in bold. * When the value of _drop-out rate_ was too high, the network weights became somewhat random because the network was not able to develop appropriate patterns. So this architecture did not even work for the training data.  
\end{table}