Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to complex numbers #49

Open
GiggleLiu opened this issue Apr 11, 2017 · 1 comment
Open

Support to complex numbers #49

GiggleLiu opened this issue Apr 11, 2017 · 1 comment

Comments

@GiggleLiu
Copy link

GiggleLiu commented Apr 11, 2017

Optimization schemes with complex numbers are widely used in physics, and recently, machine learning.

I strongly suggest to add the support to complex numbers for optimization engines like RmsProp et. al.

We just need a few lines of change and several tests.

E.g. climin/rmsprop.py line 165-167

            self.moving_mean_squared = (
                self.decay * self.moving_mean_squared
                + (1 - self.decay) * gradient ** 2) 
            --> + (1 - self.decay) * np.abs(gradient) ** 2)

A single line of change would make it applicable for complex numbers.

The same is true for Adam and Adadelta.

On the other side, GradientDescent works well already without any change.

Maybe a bit effort is needed for Rprop, I have no clue yet how to make it compatible with complex numbers due to the ill defined sign function for complex numbers.

@GiggleLiu
Copy link
Author

GiggleLiu commented Apr 13, 2017

A possible solusion to Rprop that works well in my own test:

file: climin/rprop.py, line 129-135

            gradprod = gradient_m1 * self.gradient   
        --> gradprod = gradient_m1.conj() * self.gradient 

            self.changes[gradprod > 0] *= self.step_grow
            self.changes[gradprod < 0] *= self.step_shrink
            self.changes = ma.clip(self.changes, self.min_step, self.max_step)

            step = -self.changes * ma.sign(self.gradient) 
        --> to step = -self.changes * np.exp(np.angle(self.gradient))

About Pull Request

I feel sad to noticed that gnumpy do not support complex numbers yet, so I will not create a pr now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant