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

[WIP] Use ChainRules #291

Closed
wants to merge 3 commits into from
Closed

Conversation

oxinabox
Copy link
Member

@oxinabox oxinabox commented Aug 9, 2019

my plan is
Step 1) Change Zygote to check for chainrules before doing its normal stuff,
and adapt the stuff it gets back from chainrules to play nice with Zygotes expectations

Step 2) adapt ChainRules and Zygote, so their expectations are more inline with each other and integrate more deeply.

This likely includes adding a macro that is basically @adjoint to ChainRules.
I think @adjoint function f, y, Δ->-yd is
the same as ChainRules’s: rrule(::typeof(f),...) = (y, Rule(Δ->yd))
And that that should really have a similar connivence macro

This PR is Step 1.

Major limitations blocking this:
ChainRules does not know how to differentiate WRT the function itself, which matters for closures.

I know this imprinciple works as
without this branch:

Zygote.gradient(abs, 0) == (1,)

With this branch

Zygote.gradient(abs, 0) == (0,)

The matching PR for Nabla is:
invenia/Nabla.jl#178

@oxinabox oxinabox mentioned this pull request Oct 7, 2019
@oxinabox oxinabox closed this Oct 7, 2019
@oxinabox oxinabox deleted the ox/chainrules_step1 branch April 23, 2020 09:21
bors bot added a commit that referenced this pull request May 28, 2020
366: Add ChainRules r=oxinabox a=oxinabox

This replaces #291

The bits from that OP that still matter

Step 1) Change Zygote to check for chainrules before doing its normal stuff,
and adapt the stuff it gets back from chainrules to play nice with Zygote's expectations

Step 2) adapt Zygote more deeply, so it can take full advantage of thunks etc.


This PR is Step 1.

<s> TODO: workout why this seems to segfault for me. </s>


Co-authored-by: Lyndon White <lyndon.white@invenialabs.co.uk>
Co-authored-by: Mike J Innes <mike.j.innes@gmail.com>
Co-authored-by: Lyndon White <oxinabox@ucc.asn.au>
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

1 participant