How to separate the Jacobian based on effectively? #28312
Unanswered
mathliuqiang
asked this question in
Q&A
Replies: 1 comment
-
With |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have constructed an MLP network function with a structure of [2, 8, 2], meaning the output dimension is 2.
I am using
jax.jacobian
to compute the derivative with respect to the parameters.The output is
However, I want to separate the resulting Jacobian based on the output dimension. Specifically, I need to extract the derivatives for each of the two outputs individually, i.e.,$\frac{\partial \mathop{output}_1}{\partial \theta_i}$ and $\frac{\partial \mathop{output}_2}{\partial \theta_i}$ , ideally representing them as two separate Pytrees (or vectors), where each Pytree contains the gradients for one output element with respect to all parameters. How can I achieve this?
Beta Was this translation helpful? Give feedback.
All reactions