Samplewise vs featurewise centering

Could someone please explain:

  1. The differnece between samplewise centering adn featurewise centering, and is one of them happening accross channels or for the entore sample?
  2. In the programming assignment, why are we using sampewise for training and featurewise for validation and test? arent we supposed to use the same values across?
  3. Ideally, do we normalzie each image with its own mean and std, or do we normalize train, valid and test set with training sets’ mean and std?
  4. Why isn’t densenet’s preprocess_input() being used here?

@Mubsi Hi, I saw you replied to an older post made by me, that I had accidently deleted right after asking it. Could you please post you reply here? Sorry about the confusion!

Having the same question, would appreciate some help with this. Many thanks! @Mubsi @nakamura @canxkoz @andres920310

Hello @Jairaj_Mathur and @Wanqing_Shao
Thanks a lot for bringing this question up. I will try to do my best at answering the first question and provide related links for you. I have a tutorial recommendation for you so that you can better understand the answers to your question 2 and 3. If you still have questions pleas feel free to ask further after reading my reply.

  1. The difference between sample wise centering and feature wise centering, and is one of them happening across channels or for the entire sample?

Sample wise centering: Lets say you have three channels, you have to calculate the mean of three pixels over all channels. If you have one channel the mean is the pixel value itself and this means that the std is going to be 0. For this reason, while implementing sample wise centering it would be ideal to flatten the image per channel and calculate the mean and then subtract the mean from the respective channel.

Feature wise centering: Feature wise center transforms the image to 0 mean. This is implemented on the entire dataset.

My recommended reading resources for in depth use cases:
Keras Docs

For Question 2 and 3 please check this tutorial on Normalization, centering and standardizing image pixels in Keras. I think completing this tutorial can help you reach the answers on your own.

Overall, thanks a lot for bringing these questions up and please keep asking questions as a follow up. I am hoping that you will be able to reach answers after completing the tutorial which I recommended to you. This tutorial will also help you narrow down your questions. Thanks for contributing to our Discourse community and I hope that I was able to help you.