mapostig:

Moreover, the image values to feed the network were between (0, 255) and they should be between (-1, 1) (isn’t it?)


Usually you would normalize the input images to have a zero mean and a unit variance via transforms.Normalize, which is beneficial for the training.
The data type is float32 by default, which would explain the byte dtype error.



 mapostig:

when I cast the images to FloatTensors as you suggested, the error was the NaN loss.


That’s not good. Could you post your complete code (if possible), so that I could take a look, please?