keras-team / keras-preprocessing

Utilities for working with image data, text data, and sequence data.
Other
1.02k stars 444 forks source link

Rescale with featurewise normalization bug fix #257

Closed hadipash closed 4 years ago

hadipash commented 4 years ago

Summary

Featurewise centering, normalization and ZCA whitening work incorrectly with the rescale parameter. This PR fixes the bug.

Related Issues

100

PR Overview

hadipash commented 4 years ago

Thanks @rragundez for your help! Few comments on the latest commit. I followed your suggestions on enhancing test cases but in the case of featurewise_std_normalization it's impossible to achieve 1e-6 precision because on the lines 722 and 967 of image_data_generator.py X is divided by the standard deviation + 1e-6 (x /= (self.std + 1e-6)), so the precision is smaller. Therefore, I set the level to 1e-5.

Additionally, I added dtype argument for iterators initialization so that data can be treated as other types rather than only float32 (as explained above).

Finally, I introduced a better test case for ZCA whitening (also explained above).