Jacobian gradient matrix between two images

Hallo,

I have two images and i want to calculate the gradient for each pixel in one image according to each pixel in another image , so i want to calculate the jacobian matrix by Pytorch, can you give me plese any function or code to help me.
Thanks

Hi,

You can find a Jacobian function in this gist: https://gist.github.com/apaszke/226abdf867c4e9d6698bd198f3b45fb7
Note that it will be very slow if you want to full jacobian for any medium/large image.

1 Like

Thank you very much…I know it is very slow…I want to alculate the gradient for each pixel in one image according to each pixel in another image so jacobian matrix is 256 256256*256

A back of the envelope check for this means that just the Jacobian matrix will be 17GB.
I’m not sure what your usecase is but it might be tricky.