enumerate(loader)  will give you something like batch_idx, (data, target) back so it is likely you are passing the batch_idx in place of the image. examples/main.py at 01539f9eada34aef67ae7b3d674f30634c35f468 · pytorch/examples · GitHub