Fix samplewise normalization in ImageDataGenerator
* Fix samplewise normalization in ImageDataGenerator
Normalize pixels uniformly by the image mean and std
* dont specify axes for samplewise image normalization
@@ -524,12 +524,10 @@ class ImageDataGenerator(object):
x = self.preprocessing_function(x)
if self.rescale:
x *= self.rescale
- # x is a single image, so it doesn't have image number at index 0
- img_channel_axis = self.channel_axis - 1
if self.samplewise_center:
- x -= np.mean(x, axis=img_channel_axis, keepdims=True)
+ x -= np.mean(x, keepdims=True)
if self.samplewise_std_normalization:
- x /= (np.std(x, axis=img_channel_axis, keepdims=True) + 1e-7)
+ x /= np.std(x, keepdims=True) + 1e-7
if self.featurewise_center:
if self.mean is not None:
