Seeking a clarification here. If I need to compute the gradient of rotation matrix with respect to theta, should I swap inputs and outputs in torch.autograd?
torch.autograd.grad(outputs=theta, inputs=rot_mat, grad_outputs=torch.ones_like(theta), create_graph=True)
PS:
I just tried differentiating a normal rotation matrix of shape [2, 3] w.r.t theta, and I end up with a single value again. If I swap inputs and outputs as I have listed above, I end up with an error One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior. Setting allowed unused = True returns a gradient None.