in the code snippet that you are providing, you are normalizing the image on the CPU then converting it to a CUDA tensor. While in the line of code that you have provided in your comment



 nuhpiskin:

code (torch.cuda.floattensor(image)/255-0.5)/0.5


you are converting to CUDA tensor and then doing the normalization on the GPU which is obviously faster.