# Improving Convolutional Neural Networks' Accuracy in Noisy Environments Using k-Nearest Neighbors
## 3 Experiments
Furthermore, results reported in the rest of the datasets reflect a similar behavior: hybrid approaches achieve better results than the CNN + softmax, which also degrades generally faster as the noise is increased. Although differences are not especially remarkable with and without the \(\ell_{2}\) norm, it can be seen that the former is less sensitive to noise. An interesting remark is that higher values of \(k\) are needed in the hybrid approach, even without the presence of induced noise. This might indicate that neural codes are somehow noisy in the closest neighborhood (when \(k\) is low), although this condition can be mitigated considering more neighbors during classification. This means that the proposed technique can benefit from large amounts of annotated data. In this sense, we observe that the \(\ell_{2}\) usually needs a lower value of the parameter \(k\), which indicates that this normalization leads to a higher robustness of the neural codes. Figure 3 shows the impact on the average \(F_{1}\) when using different values of \(k\). As can be seen, the inclusion of kNN is more beneficial when the noise is higher. In addition, the value of \(k\) for outperforming the softmax depends on the amount of noise. The higher the noise, the higher \(k\) should be, but in all cases, this is a relatively small value (lower than 15). Therefore, the value of \(k\) is not so decisive to improve the results of the base CNN + softmax as long as it has been increased enough to surpass the elbow of the curve. As a general conclusion, the proposed approach consistently outperforms the CNN + softmax even with low noise levels. The accuracy improvement is especially remarkable with challenging datasets such as CIFAR. In addition, it is observed that adding the \(\ell_{2}\) norm consistently improves the accuracy with respect to using the raw neural codes, both with or without noise. On the other hand, no unequivocal conclusions can be drawn with very high levels of noise, as in some cases, the hybrid approach outperforms the CNN (such as in CIFAR100), whereas in others (such as CIFAR10), that is not the case. However, there is a trend towards greater robustness to noise from the classical scheme (CNN + softmax) than from the hybrid schemes, contrary to what could be expected because of the use of kNN. A possible explanation is that training a network with noisy labels forces it to map the features onto an incorrect position of the neural space, making kNN misclassify them. That is, label noise might generate noise at the feature level, which prevents a correct kNN classification. The softmax, however, seems to palliate this phenomenon better because a lower degradation is observed as the induced noise is increased. Figure 3: Average \(F_{1}\) (%) accuracy (\(y\)-axis) over all datasets with respect to the value of \(k\) (\(x\)-axis) at different noise levels. The addition of a kNN stage slightly increases the computational cost, but given the success of recent fast kNN methods [32; 33; 34], it might be more efficient than increasing the number of parameters of the CNN in order to achieve similar results as those obtained with a simpler CNN plus a kNN classifier. For instance, using the approach proposed in [34], a query on a dataset of five million prototypes with a 128-dimensional feature vector (the size of the Neural Code (NC) considered in this work) takes around 0.1 ms.