Why do we add "Normalize.from_stats" in our DataBlock for the Biwi image regression problem?

In the video for Lesson 6, Jeremy says that we normalize the data that the pre-trained model used (i.e. we subtract the mean and divide by the standard deviation of the data used on the pre-trained model, i.e. ImageNet). I’m unclear on what this means, or why we’d do it.

I think I have an understanding of what normalization is (ensuring that it conforms to a normal distribution, with the bulk of the data falling in the middle of a bell-shaped curve), but I’m unclear on what exactly we’re normalizing in the case of the Biwi image regression problem.

EDIT: also, Jeremy says that the normalization is “done automatically now”. Is he saying that we can assume that the normalization will be handled for us as part of the batch transforms which are executed?

And if so, where does this happen? I don’t see a call to Normalize.from_stats anywhere inside the code for the DataBlock class.

So when I posted this, I had yet to start reading Chapter 7. Now that I have, I see that the chapter talks about normalization specifically with regard to computer vision problems. Having read that section, I’m guessing that we’re normalizing the pixel values of the images in our input library so that they have a mean of 0 and a standard deviation of 1?

You’re extremely close! Normally if we didn’t have a pretrained model, yes we would do this. But since we have a pretrained resnet backbone (trained on ImageNet), we need to normalize our data based on what the model was trained on. As a result we use the mean and std of the ImageNet dataset, or imagenet_stats

1 Like

Thanks @muellerzr . So you’re saying we normalize the distribution of the pixels of our Biwi image set to conform to the distribution of the ImageNet image set?

If that’s what you mean, I guess I’m still unclear on what the purpose is. What’s the risk if we don’t do this?

1 Like

Generally normalize help our Model to train faster and better for images or Tabular_Data

1 Like

As @Hicham said, it helps us train faster, so rather than having it get used to our data (which can take some time), instead we just adjust our data to what its already been trained with, speeding up the process

2 Likes

Great, makes sense. Thanks very much @Hicham and @muellerzr !

1 Like