Skip to content

Conversation

@ChrisRackauckas
Copy link
Member

Fixes #98

@CarloLucibello
Copy link
Member

needs a test and a mention in the docs

Co-authored-by: Carlo Lucibello <carlo.lucibello@gmail.com>
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.

This would be good to have, but shouldn't it behave like gradient and return a 1-tuple for one argument? Then the extension to several arguments need not break anything.

@cossio
Copy link
Contributor

cossio commented Sep 15, 2020

Bump? Would be nice to have.

@MasonProtter
Copy link
Contributor

If we split out OneHotVector from Flux.jl, we could have this simpler implementation that's sometimes more performant and has less weird edge cases:

using Flux: OneHotVector

"""
jacobian(f,x)
Construct the Jacobian of `f` where `x` is a real-valued array
and `f(x)` is also a real-valued array.
"""
function jacobian(f, x)
    y, ∂f = Zygote.pullback(f,x)
    n, m  = length(x), length(y)
    mapreduce(i -> ∂f(OneHotVector(i, m)), hcat, 1:m)
end

ChrisRackauckas and others added 2 commits September 15, 2020 18:31
Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com>
Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com>
Copy link
Member

@DhairyaLGandhi DhairyaLGandhi left a comment

Choose a reason for hiding this comment

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

Looks good, but needs tests

@DhairyaLGandhi
Copy link
Member

Also probably something that should hook into the forward mode

@ChrisRackauckas
Copy link
Member Author

Forward mode Jacobian should be kept as a separate call: which one is better depends on the application so both are required. What this should really connect to is SparseDiffTools for sparse Jacobians, but what will happen there is that SparseDiffTools will have a... more intense version that handles all of that extra machinery.

@DhairyaLGandhi
Copy link
Member

This is due to it detecting sparsity patterns I assume?

Co-authored-by: Mason Protter <mason.protter@icloud.com>
@ChrisRackauckas
Copy link
Member Author

This is due to it detecting sparsity patterns I assume?

Well this could be made to accept a color vector even without SparseDiffTools.

Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com>
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.

Jacobian and Hessian

6 participants