Sparse Gradient using Zygote & Optim

If you know which four parameters are non-zero, then pass them as arguments to an anonymous function and assign them to the correct places in your gradient vector. If you don’t know, then is your function actually differentiable?

Otherwise you might look at SparseDiffTools.jl.

2 Likes