# Differentiating Jacobian-vector product for sliced score matching?

**URL:** <https://discourse.julialang.org/t/differentiating-jacobian-vector-product-for-sliced-score-matching/99746>\
**Category:** Machine Learning\
**Tags:** flux, zygote, ad\
**Created:** [June 1, 2023, 10:47pm UTC](https://discourse.julialang.org/t/differentiating-jacobian-vector-product-for-sliced-score-matching/99746 "2023-06-01T22:47:17Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Post date:** [June 29, 2023, 5:56pm UTC](https://discourse.julialang.org/t/differentiating-jacobian-vector-product-for-sliced-score-matching/99746/19 "2023-06-29T17:56:47Z")

</div>

Hello,

The term v^\top \nabla\_x f(x) v can be rewritten as a directional derivative \frac{\mathrm{d}}{\mathrm{d} \alpha}(v^\top f(x+\alpha v))\Big|\_{\alpha = 0}: we only need the derivative of the scalar function \alpha \mapsto v^\top f(x + \alpha v) for \alpha = 0.  
I don’t know how to implement it properly with Zygote though.

---

_[View the full topic](https://discourse.julialang.org/t/differentiating-jacobian-vector-product-for-sliced-score-matching/99746)._
