Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 699 Bytes

chainrules.md

File metadata and controls

18 lines (14 loc) · 699 Bytes

ChainRulesCore Integration

The WeightedIndex infrastructure has issues working with autodiff libraries. Autodiff is facilitate by integration with ChainRulesCore. A custom rrule is defined such that

y, itp_pullback = rrule(itp, 1)

itp_pullback takes a perturbation on y and returns how it effects each x dimension. Since Interpolations already has a gradient function, pullback reuses it by scaling it by Δy.

This enables integration with autodiff libraries like Zygote, enabling

x = 1:10
y = sin.(x)
itp = interpolate(y, BSpline(Linear()))
Zygote.gradient(itp, 2)
#([-0.7681774187658145],)