Calculating Jacobian with respect to certain outputs only #8820
Answered
by
jakevdp
Justin-Tan
asked this question in
Q&A
-
Hi, is it possible to calculate the Jacobian of a function with respect to certain outputs only? e.g. for def my_func(x,y,z):
return x**2,y**2,z**2 I'd like to find the Jacobian of the first output only, with respect to the function's input arguments. |
Beta Was this translation helpful? Give feedback.
Answered by
jakevdp
Dec 6, 2021
Replies: 1 comment 2 replies
-
I think the recommended way to do this would be something like my_func_jac = jax.jacobian(lambda x, y, z: my_func(x, y, z)[0]) If you |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Justin-Tan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the recommended way to do this would be something like
If you
jit
-compile the function, the XLA compiler will do dead code elimination to ensure that unused results are not computed.