Skip to content

Commit d2d33d7

Browse files
Noah Stierfchollet
authored andcommitted
Fix samplewise normalization in ImageDataGenerator (keras-team#8209)
* Fix samplewise normalization in ImageDataGenerator Normalize pixels uniformly by the image mean and std * dont specify axes for samplewise image normalization
1 parent 5ca4f74 commit d2d33d7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

keras/preprocessing/image.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,10 @@ def standardize(self, x):
524524
x = self.preprocessing_function(x)
525525
if self.rescale:
526526
x *= self.rescale
527-
# x is a single image, so it doesn't have image number at index 0
528-
img_channel_axis = self.channel_axis - 1
529527
if self.samplewise_center:
530-
x -= np.mean(x, axis=img_channel_axis, keepdims=True)
528+
x -= np.mean(x, keepdims=True)
531529
if self.samplewise_std_normalization:
532-
x /= (np.std(x, axis=img_channel_axis, keepdims=True) + 1e-7)
530+
x /= np.std(x, keepdims=True) + 1e-7
533531

534532
if self.featurewise_center:
535533
if self.mean is not None:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy