# Evaluating Convolutional Neural Networks and Vision Transformers for Baby Cry Sound Analysis
## 4 Discussion  
The findings agree with our assumptions and the previous findings of other research [43] that the modified architecture for the ViT model allows a more accurate pattern recognition for such a relatively modest-size dataset like donate-a-cry, even after applying the augmentation techniques. As reported in the results, the original Vision Transformer architecture performed worse than both models based on convolutional neural networks when applied to donate-a-cry datasets. Employing shift patch tokenization (SPT) and locality self-attention (LSA) techniques significantly enhanced the performance of ViT. SPT effectively incorporates spatial information into visual tokens through multiple transformations, while the LSA mechanism increases the local attention through softmax with learnable parameters. These changes allowed the model to capture finer-grained details within the spectrograms and focus on local dependencies. They separately augment the locality's inductive bias of ViTs to acquire knowledge from limited-scale datasets without any prior training. \begin{table}
\begin{tabular}{l c c c c} \hline \hline  & **CNN** & **Multi-CNN** & **ViT** & **ViT-SPT-LSA** \\ \hline Class 1—belly pain & 96\% & **100\%** & 84\% & 97.8\% \\ Class 2—burping & **100\%** & **100\%** & **100\%** & 95.4\% \\ Class 3—discomfort & 90\% & 87.5\% & 93.7\% & **97.9\%** \\ Class 4—hungry & 97\% & 94\% & 97.4\% & **100\%** \\ Class 5—tired & **100\%** & **100\%** & 83.3\% & **100\%** \\
**Overall** & 95.9\% & 96.3\% & 94\% & **98.33\%** \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The accuracy of 5 classes and their overall accuracy for the four models. \begin{table}
\begin{tabular}{l c c c c} \hline \hline
**Class** & **Precision** & **Recall** & **F1 Score** & **Support** \\ \hline Class 1—belly pain & **1.00** & 0.98 & **0.99** & 47 \\ Class 2—burping & **1.00** & 0.98 & **0.99** & 44 \\ Class 3—discomfort & 0.98 & 0.96 & 0.97 & 49 \\ Class 4—hungry & 0.98 & **1.00** & **0.99** & **51** \\ Class 5—tired & 0.96 & **1.00** & 0.98 & 48 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Classification report for five classes for ViT-SPT-LSA. \begin{table}
\begin{tabular}{l c c c c} \hline \hline  & **Accuracy** & **F1 Score** & **Feature** & **Classifier** & **\# of Classes** \\ \hline [PERSON] et al. (2019) [23] & 81.7\% & 0.93 & Audio features & GMM & 5 \\ [PERSON] et al. (2021) [24] & - & 0.93 & SAI modeling & GMM-UBM & 4 \\ [PERSON] and [PERSON] (2022) [25] & 85.59\% & - & STFT & DNN & 4 \\ [PERSON] et al. (2021) [26] & 84\% & 0.80 & GTCC & Random Forest & 4 \\ [PERSON] (2022) [27] & 95.2\% & 0.94 & Scalogram & ResNet-18 & 5 \\
**ViT-SPT-LSA** & **98.33\%** & **0.98** & **Mel spectrogram** & **ViT** & 5 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparison with state-of-the-art models on donate-a–cry dataset. The confusion matrix in Figure 4 and Table 2 illustrates the performance of model ViT-SPT-LSA in classifying cry sounds across different classes during the last fold. Each row represents the actual cry class, while each column represents the predicted cry class. The numbers in the matrix indicate the count of cry instances classified into each class. It is important to note that while the models demonstrated high accuracy, there may be limitations and challenges associated with certain classes. The ViT-SPT-LSA model struggles with the recall of the discomfort class with a recall value of 0.96, which decreases the accuracy of the specific class compared to the other and the rest of the models in the same class. On the other hand, the model exhibits robust performance, particularly excelling in the belly pain and burping classes with strong precision, recall, and F1 scores ranging from 0.98 to 1. Additionally, Figures 5 and 6 provide insights into the performance, learning progress, and generalization ability of model _ViT-SPT-LSA_ in accurately classifying cry sounds. Figure 5 displays the training and testing accuracy curves for model _ViT-SPT-LSA_ during the training process.