# Any way to get the mixed derivative wrt all (many) variables?

 \partial^n f(x_0, .., x_n)
-----------------------------
\partial x_0 .. \partial x_n


Any suggestions? Do you think it is even possible in pytorch?

As a nd tensor? No, I don’t think it is generally possible. Although it is possible to do second-order derivative in most cases!

No, the result is scalar, it is not gradient or hessian, it is just a function R^n -> R and we take derivatives wrt each variable one after another, like

grad_wtr_x_n( .. grad_wrt_x_0(f(x_0,..,x_n) .. ) - result is also a scalar function of (x_0..x_n)

each grad_x_i(…) is a scalar function.

Just taking gradients wrt single input one after another in a loop seems like a terrible idea, though I should test it first.

Oh I see. Thanks for the explanation.

It still isn’t generally supported except for n <= 2. Double backwards mostly works, but their result might not be currently differentiable.

Got it, thank you very much for a rapid response!