I have a function composedimg=compose(img,diff) with img : h x w x d and diff : 3 x h x w x d. The output of my function is h x w x d. I would like to compute the derivative of this function compose w.r.t img. However, when i use I tried something like this
torch.autograd.grad(outputs=composedimg,inputs=img)
, it says "grad can be implicitly created only for scalar outputs".
Do you have any ideas how i can do this please ?