Skip to content

Instantly share code, notes, and snippets.

@krishvishal
Created August 11, 2020 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save krishvishal/3f3ea2e7bffa47eb29530bfffe275a8f to your computer and use it in GitHub Desktop.
Save krishvishal/3f3ea2e7bffa47eb29530bfffe275a8f to your computer and use it in GitHub Desktop.
This file has a function f(x) and I use ReverseDiff to calculate gradient of that function. If ReveseDiff is really the problem, this shouldn't run successfully.
using ReverseDiff
f(x) = maximum(x;dims=1)
if abspath(PROGRAM_FILE) == @__FILE__
x = rand(3, 3)
println(x)
println(ReverseDiff.gradient(sum∘f, x))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment