Hallo,

i try to make the gradient jacobian matrix calculation between two images faster, i want to apply difference approximation but i did not see any example about that.

Hallo,

i try to make the gradient jacobian matrix calculation between two images faster, i want to apply difference approximation but i did not see any example about that.

Hi,

Could you explain in more details what you mean by â€śgradient jacobian matrix calculation between two imagesâ€ť ?

I mean that i want to calculate the gradient for each pixel from output image according to each pixel from input image so we have as result (256*256*256*256) value

Well, just the output matrix is going to be very expensive as it will take 4GB. So working with it will require a machine with a lot of memory.

But to go back to you original question, there is nothing much better than repetitive call to `autograd.grad`

Iâ€™m afraid. As automatic differentiation only gives a row of the Jacobian at a time.

autograd.grad take alot of time maybe 2 dayes! for this reaseon i want to make this calulation for the matrix output faster

Iâ€™m afraid this is â€śexpectedâ€ť. autograd.grad only uses automatic differentiation. And automatic differentiation is not built to compute full Jacobians. It has to construct them row by row.

But since it;s so big in your case, it takes a very long time.

Note as well that even if you manage to compute the Jacobian matrix, since it will take 4GB just to store it, you definitely wonâ€™t be able to do any autograd with it. And you wonâ€™t be able to do much operations on it before running out of memory Iâ€™m afraid.

1 Like