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

Flag derivative WRT map itself as not implemented in chain rule #198

Merged
merged 1 commit into from
Dec 15, 2022

Conversation

gaurav-arya
Copy link
Contributor

@gaurav-arya gaurav-arya commented Dec 15, 2022

There are definitely scenarios where there ought to be a gradient WRT some parameters of the linear map, so this PR marks its gradient as not implemented rather than as NoTangent() to try to avoid correctness issues. Here's an example:

function f(p)
           A = LinearMap([p])
           return sum(A * [p])
end
# function is a fancy p^2, so gradient should be 2p

Annoyingly, this doesn't actually fix anything yet, at least for Zygote, because Zygote treats NotImplemented's just like zeros (FluxML/Zygote.jl#1204). But it still seems like the right thing to do.

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Base: 99.47% // Head: 99.47% // No change to project coverage 👍

Coverage data is based on head (466f71a) compared to base (50f5bf9).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #198   +/-   ##
=======================================
  Coverage   99.47%   99.47%           
=======================================
  Files          19       19           
  Lines        1526     1526           
=======================================
  Hits         1518     1518           
  Misses          8        8           
Impacted Files Coverage Δ
src/LinearMaps.jl 100.00% <ø> (ø)
src/chainrules.jl 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dkarrasch
Copy link
Member

I'm not familiar with the chain rules stuff, but I trust that this is correct. Seems to be closer to the actual fact that the product in itself is differentiable w.r.t. map (in contrast to NoTangent()), but it's just not implemented.

@dkarrasch dkarrasch merged commit 6d5c4d6 into JuliaLinearAlgebra:master Dec 15, 2022
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.

2 participants