Your testloader might only be loading one image and one label at once.
If you want to read multiple images and labels at once, you need to modify the testloader class. If you want to read one image and one label at once.And labels and images record all labels and images that have been read.You may try
images = torch.cat(images, data[0])
labels = torch.cat(labels, data[1])

instead of “images, labels = data”