I have a tensor of shape (number_of rays, number_of_points_per_ray, 3), let’s call it input
. input
is passed through a model and some processing (all of this is differentiable), let’s call this process inference
. Finally, we get output = inference(input)
, which has a shape of (number_of_rays, number_of_points_per_ray, 300), where each “ray” in the output only depends on the same ray of the input. e.g. output[i]
only depends on input[i]
. This means that for each set of 3 elements on the input the output has 300 elements, so I would expect to get a gradient with the same shape as the output
As explained at https://discuss.pytorch.org/t/need-help-computing-gradient-of-the-output-with-respect-to-the-input/150950/5 , I tried grads=torch.autograd.grad (outputs = output, inputs = input, grad_outputs = None)
but the output I am getting is of shape (number_of rays, number_of_points_per_ray, 3) , which is the same as the input and not the same as the output.
Any clue what may I be doing wrong? Thanks in advance