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

Fix complex gradients #35

Merged
merged 1 commit into from
Nov 5, 2018
Merged

Fix complex gradients #35

merged 1 commit into from
Nov 5, 2018

Conversation

antoine-levitt
Copy link
Contributor

Ref #29

@MikeInnes
Copy link
Member

Thanks!

Do you think we could generally re-use the rules in DiffRules for this? (see e.g. the real.jl file for example usage).

@MikeInnes MikeInnes merged commit 4094401 into FluxML:master Nov 5, 2018
@antoine-levitt
Copy link
Contributor Author

I think it's in general true that any function defined in standard libs that is C -> C is holomorphic, and therefore can be differentiated using the same rules as in this PR. The single exception I can see is conj.

Then there are the C->R functions (abs, abs2, hypot, real, imag) that have to be special-cased, and the comparison-based (max, mod, etc.) that aren't defined for complex arguments.

If there's a reliable way of predicting whether a function is C->C, then that could be used. Otherwise it'll have to be manual.

@MikeInnes
Copy link
Member

I suppose that at the very least, we could just make a list of valid functions and look them up in DiffRules, rather than writing out the gradients again. Then at least adding new definitions would be very easy. Not urgent but just a thought for 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

Successfully merging this pull request may close these issues.

None yet

2 participants