-
Notifications
You must be signed in to change notification settings - Fork 443
The "transpose trick" for quick zca approximation solving issue #55 #292
Comments
Hello, With ZCA whitening not being as popular as at the beginning of Deep learning, I don't think we should include this in Keras-prepro. I'm open to discussion :) |
Thanks for the answer, @Dref360 ! |
Hi @Dref360 , I found a way to make my method not just an approximation but exactly the same result as the current zca transformation and still to run quicker. I can also make it run without an additional user specified variable, with an if-clause the code can just determine what would be the quicker svd approach and calculate accordingly. It would look like this, just 5 new lines:
Let me know if you think it's valuable and I will make the changes to the keras pre-pro file and submit them. |
Hi, @Nestak2 |
@tranngocphu Hi, if I remember correctly |
I implemented the more or less known "transpose trick" for a fix of issue #55, my code is here. Is it alright? Do I have to include changes not only to keras-preprocessing/keras_preprocessing/image/image_data_generator.py, but also to keras/keras/preprocessing/image.py?
Summary
Included variable
zca_rotated
that allows the user to choose if the svd in the zca whitening should be calculated on the data rows=features (False) or on the columns=examples (True) and saves time when the smaller one is chosen. When False is selected it calculates zca_whitening in the usual way. In some cases it can solve the problem of never completing svd computation when the covariance matrix is too large by reducing the size of the matrix. The idea is explained with examples in issue #55 on github. The method is not an approximation, but it gives exactly the same result as the current method with the difference of saving time if the number of images < number of features. I needed only to make changes in a few lines of code, but for them to work I am not sure if I have to add changes to keras/keras/preprocessing/image.py like defining the new variablezca_rotated
there.Related Issues
#55, #8706 in keras-team/keras
PR Overview
I am not sure what is meant by "unit test", but below is the minimal code of the new implementation and it can be also seen here:
[ y] This PR requires to update the documentation [y/n] (make sure the docs are up-to-date)
I provided a description of the new variable
zca_rotated
, that might be included in the documentation:zca_rotated: Boolean. Denotes if in zca the svd should be calculated on the data rows=features (False) or on the columns=examples (True) and saves time when the smaller of the two is chosen. Presents an approximation to zca_whitening. Default is 'False".
[ y] This PR is backwards compatible [y/n]
The default is
zca_rotated=False
and in such a case there is no change to the current state, zca is calculated as of now[ n] This PR changes the current API [y/n] (all API changes need to be approved by fchollet)
I am not sure, but I think it doesn't change the API
The text was updated successfully, but these errors were encountered: