0
votes

I'm starting to work on the classification of images dataset, as many tutorials I followed; it starts by normalizing the data (train and test data)

My question is: if I want to normalize the data by shifting and scaling it with a factor of 0.5

What does this mean 'the factor of something x'?

I know that it will be used within .Normalize():

transform_train = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize(),
])

transform_test = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize(),
])

But I'm a little bit confused about the meaning shift and scale (maybe it's like resize?) by the factor of X

Thanks.

1

1 Answers

1
votes

Shifting and scaling refers to the color space. What you do is you subtract the mean (shifting to the mean of the pixel values of the whole dataset to 0) and divide by the standard deviation (scaling the pixel values to [0, 1].

It has nothing to do with modifying the size of the image or the like.

In numy you would do something like:

mean, std = np.mean(image), np.std(image)
image = image - mean
image = image / std

Note: You wouldn't want to normalize the data bz just 0.5 but by its mean and standard deviation.