# [Pytorch]Hello, I'd like to ask you about data preprocessing of cifar-10

In the pre-processing of data, we need to convert the data, converting the 0-255 RGB image to [0,1], and then to [-1,1],
Code is

``````transform = transforms.Compose(
[transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
])
``````

I can understand.ToTensor() converts data to [0,1], but I don’t know how Normalize converts data to [-1,1]. Although I know that input[channel] = (input[channel] - mean[channel])/STD [channel]

But I still don’t know how to get to [-1,1]
Thanks.

I know something about Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)) .
The first (0.5, 0.5, 0.5) is the mean of R G B.
The second is the std of R G B .
0.5 is a roughly digit.
The general statistics given on pytorch

mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225])

ToTensor ->[-1,1]
Normalize -> [0,1]

ToTensor gives you [0,1], then (x - 0.5) / 0.5 gives you [-1,1]