Skip to content

Instantly share code, notes, and snippets.

@jrevels
Created October 22, 2018 11:43
Show Gist options
  • Save jrevels/c71a96345c59b5c96ff75850ce4f1e1b to your computer and use it in GitHub Desktop.
Save jrevels/c71a96345c59b5c96ff75850ce4f1e1b to your computer and use it in GitHub Desktop.
using ReverseDiff, ForwardDiff
x, v = rand(3), rand(3)
tp = ReverseDiff.InstructionTape()
tx = ReverseDiff.track(x, tp)
ty = cumprod(tx)
ReverseDiff.increment_deriv!(ty, v)
ReverseDiff.reverse_pass!(tp)
isapprox(ReverseDiff.deriv(tx)', (v' * ForwardDiff.jacobian(cumprod, x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment