Skip to content

Conversation

@devmotion
Copy link
Contributor

This PR adds a derivative for logabsgamma (basically a copy of JuliaDiff/ForwardDiff.jl#585 for Tracker). The derivative cannot be defined in DiffRules since the function returns a tuple.

Currently:

julia> Tracker.gradient(x -> logabsgamma(x)[1], rand())
ERROR: MethodError: no method matching _logabsgamma(::Tracker.TrackedReal{Float64})
...

julia> Tracker.gradient(x -> logabsgamma(x)[2], rand())
ERROR: MethodError: no method matching _logabsgamma(::Tracker.TrackedReal{Float64})
...

With this PR:

julia> Tracker.gradient(x -> logabsgamma(x)[1], rand())
(-1.808248603306234 (tracked),)

julia> Tracker.gradient(x -> logabsgamma(x)[2], rand())
(0.0 (tracked),)

Copy link
Member

@mcabbott mcabbott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. Test failure on v1 is kron as in #125

@devmotion
Copy link
Contributor Author

Bump 🙂

@mcabbott
Copy link
Member

Ah I assumed you had merge rights here, sorry.

@mcabbott mcabbott merged commit 0e99755 into FluxML:master May 13, 2023
@devmotion devmotion deleted the dw/logabsgamma branch May 13, 2023 15:15
@devmotion
Copy link
Contributor Author

Thank you!

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