Lesson 3 : normalize the image

Got some questions

1 : how do we calculate the mean?

pseudo codes: mean is the average of all of the image

for img in imagenet_imgs:
  (b,g,r) = img[:3];
  mean.b += b.mean(); // add all of the pixels of b channels and divide it by pixels size of b channel
  mean.g += g.mean();
  mean.r += r.mean();
mean /= len(imagenet_imgs);

or pseudo codes: mean is the mean of single image

(b,g,r) = img[:3];
mean.b = b.mean();
mean.g = g.mean();
mean.r = r.mean();

I think the mean mentioned by lesson 3 is the first case–mean is the average of all of the image
When we training, we do it like following codes?

for img in batches:
  img -= mean
  img/=255

2 : Anybody ever tried to ignore the mean of the image?

3 : Lesson 3 said animation are very different compare with real world photo, if I want to train some animation
classifier, I better find out the mean by myself?

4 : Could we subtract the mean of the image as following?

for img in batches:
      //rather than subtract the mean of all datasets, subtract the mean of each image
      img -= img.mean();
      img/=255

Yes that’s right. [quote=“tham, post:1, topic:3637”]
When we training, we do it like following codes?
[/quote]
You would generally just use keras’ preprocessing to handle it.[quote=“tham, post:1, topic:3637”]
Lesson 3 said animation are very different compare with real world photo, if I want to train some animation
classifier, I better find out the mean by myself?
[/quote]

Yes.

1 Like

If I want to handle it by myself?Is this procedure make sense?

Thanks for your helps.