# Low-Order Spherical Harmonic HRTF Restoration Using a Neural Network Approach
## 3 Machine Learning HRTF Restoration
### Baseline Model
The MSE loss performs worse in the test data but slightly better in the training and validation data. L1 loss, also known as mean absolute error (MAE), is given by the following equation:  
\[\text{L1 Loss}=\sum_{i=1}^{n}\left|y_{\text{label}}-y_{\text{predicted}}\right| \tag{10}\]  
MAE showed key improvements with the SADIE Subject 20 dataset and slight improvements with the Bernschutz KU100 test data. One reason L1 loss out-performs MSE loss might be that L1 loss is usually less sensitive to outliers, such as those in the case here, wherein there are HRTFs from different databases. Smooth L1 loss is a combination of L1 loss and MSE loss expressed with the following equation:  
\[\text{Smooth L1 Loss}=\left\{ \begin{array}{ll}0.5(y_{\text{label}}-y_{ \text{predicted}})^{2},&\text{if }|y_{\text{label}}-y_{\text{predicted}}|<1\\ |y_{\text{label}}-y_{\text{predicted}}|-0.5,&\text{otherwise}\end{array} \right. \tag{11}\]  
For an error below 1, Smooth L1 loss performs as the MSE loss function; and for above 1 it performs as L1 loss. Compared to L1 loss, this method has a continuous derivative at zero so it provides a smoother gradient when the error gets smaller than 1. The result of Smooth L1 loss further improved the SADIE 20 dataset but there was a trade-off with the Bernschutz dataset. Considering the real world application, it is more practical to optimise for unforeseen HRTF measurements of different human subjects instead of different measurement methods with the same artificial head model. The same principle holds in the further optimisation techniques in the upcoming tests. Therefore, the models in this paper use Smooth L1 loss as the loss function. Note that these loss functions only compare the difference between the model output and target. Whilst they can indicate a model's performance to some extent, they may not represent human perceptual response, although they are easier to back-propagate than perceptual models. Nonetheless, the proposed model from this paper is further evaluated with perceptual models in Section 4. \begin{table}
\begin{tabular}{l l l l l l l} \hline \hline \multicolumn{6}{c}{**MSE With Different Loss Functions (Lower the Better)**} \\ \hline \hline
**Model** & **Overall Mean** & **Training** & **Validation** & **SADIE 20** & **Bernschutz** & **Test Mean** \\ \hline Baseline (MSE loss) & 44.97 & 27.38 & 29.43 & 58.14 & 64.92 & 61.53 \\ \hline Baseline (L1 loss) & 44.04 & 28.16 & 30.14 & 53.66 & 64.18 & 58.92 \\ \hline Baseline (Smooth L1 loss) & 44.46 & 28.17 & 30.17 & 52.34 & 67.17 & 59.75 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Comparison between different loss functions demonstrating that Smooth L1 loss performs the best in SADIE II test data. The baseline model was trained for 500 epochs with a batch size of 8. A small batch size was used since prior research showed that a larger batch size may produce worse performance [57, 58]. Figures 7 and 8 show the MSE changes during the training. The blue and orange lines are the training and validation results respectively. The green and red lines are the test sets of Subject 20 from SADIE II database and Bernschutz KU100 measurements accordingly. The results show that the training and validation results trend downwards while the two test sets flatten out after the first 20 epochs. This indicates that the models over-fit the training data. Over-fitting is normal in this case considering the limited number of HRTF datasets in the training data (230 in total). Figure 6: Baseline model, smaller model (smaller model removes the layers highlighted in yellow) and proposed model (proposed model uses drop out in some NN layers, shown in red, amongst other techniques discussed in Section 3.3.4). The effects of data augmentation are shown in Table 6, where it can be seen that there are some drawbacks with the training and validation data, and a minor drawback with the SADIE Subject 20 test data. However, the extra data provided a significant improvement with the Bernschutz interpolation.