You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hence my goal is to compute (efficiently) the Jacobian matrix of a model with respect to it's parameters.
Let's take the simple example of a single (unbiased) linear unit with $1$ input and $n$ output. If we denote the model as a function $U$ of it's parameters $w_0,...,w_n$ and input $x$, we have $U(w_0,...,w_n, x) = (w_0 \times x,...,w_n \times x)$. Hence the jacobian will be :
My solution for the moment is to set i-th component of the output.grad to 1, the rest to 0 and hence retrieve the i-th line of the jacobian matrix in weight.grad after running linear.grad() (where linear is the kernel computing the linear unit). I'll put the code down bellow.
However this seems pretty unefficient to me, and i wonder if there isn't a way to do it much faster. Indeed even though i have no idea on how does kernel.grad works internally, i'm pretty confident that it does compute the jacobian matrix at some point, before doing a vector-matrix mutiplication (with the output.grad most certainly). If I'm not mistaken on that point, i'll just need to retrieve that matrix before the vector multiplication, but I have no idea on how to do it (or even certain that i'm not mistaken on that point).
If anyone can help me on that, or just have some info on the interal of kernel.grad it would be much appreciated.
Here is the code on the example of a (unbiased) linear unit :
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone.
I'm trying to implement Neural Galerkin scheme in taichi (https://arxiv.org/pdf/2203.01360).
Hence my goal is to compute (efficiently) the Jacobian matrix of a model with respect to it's parameters.
Let's take the simple example of a single (unbiased) linear unit with$1$ input and $n$ output. If we denote the model as a function $U$ of it's parameters $w_0,...,w_n$ and input $x$ , we have $U(w_0,...,w_n, x) = (w_0 \times x,...,w_n \times x)$ . Hence the jacobian will be :
My solution for the moment is to set i-th component of the
output.gradto 1, the rest to 0 and hence retrieve the i-th line of the jacobian matrix inweight.gradafter runninglinear.grad()(where linear is the kernel computing the linear unit). I'll put the code down bellow.However this seems pretty unefficient to me, and i wonder if there isn't a way to do it much faster. Indeed even though i have no idea on how does
kernel.gradworks internally, i'm pretty confident that it does compute the jacobian matrix at some point, before doing a vector-matrix mutiplication (with theoutput.gradmost certainly). If I'm not mistaken on that point, i'll just need to retrieve that matrix before the vector multiplication, but I have no idea on how to do it (or even certain that i'm not mistaken on that point).If anyone can help me on that, or just have some info on the interal of
kernel.gradit would be much appreciated.Here is the code on the example of a (unbiased) linear unit :
Beta Was this translation helpful? Give feedback.
All reactions