Normalization image pixel between 0 and 255 in MNIST as it has 3 channels R, G, and B

Hi, I want to convert the grayscale of MNIST images to RGB as its values are between 0 and 255. How is it possible for PyTorch?

To create the RGB channels, you could either repeat the gray channel manually or use transforms.Grayscale(num_output_channels=3). I’m not sure if you want to yield tensors in the range [0, 255], but if so you could use transforms.Normalize(mean=0., std=(1/255., 1/255., 1/255.)) after applying transforms.ToTensor().

1 Like

Hi ptrblck, thank you so much.