SAKCL: a deep neural network test data selection method based on self-attention and K-means clustering
Abstract
DNNs, similar to traditional software systems, may exhibit defects that can lead to serious consequences, especially in safety-critical scenarios. As a result, the ability to detect such defects reliably has become increasingly important, where the quality of the test dataset plays a central role. In this work, we introduce a test data selection method which combines a self-attention mechanism with K-means clustering (i.e., SAKCL) in a coordinated manner. The self-attention component assigns different levels of importance to feature dimensions, helping highlight informative patterns within samples while reducing the effect of redundant information. Based on these refined features, K-means clustering is applied to organize the data and capture structural relationships across samples. Through this process, the selected test cases achieve a better balance between fault detection capability and diversity. Experiments conducted on four benchmark datasets (MNIST, CIFAR-10, Fashion-MNIST, and SVHN) and multiple DNN architectures (LeNet-1/5, ResNet-20, and VGG-16) show that SAKCL consistently performs better than existing methods. On average, it increases the proportion of error-revealing test cases (FDR) by more than 12%, improves diversity-related metrics (KMNC) by over 6.5%, and leads to a retraining accuracy improvement (ΔAcc) of + 3.319% compared with baseline approaches. Statistical analysis further supports the reliability of these improvements (p < 0.01, Cliff's δ > 0.8). Overall, the proposed method provides a practical and scalable solution for selecting effective test data in DNN quality assurance.
Fields of Study & Subjects
Advanced Decision-Making Techniques
Software Testing and Debugging Techniques
Publication details
- Journal / source
- Scientific Reports
- Publisher
- Springer Science and Business Media LLC
- Volume
- 16
- Issue
- 1
- Publication date
- 13 June 2026
- Language
- EN