Hello,
I have a neural network function x(t) which accepts a scalar t and returns a scalar x. I have 5000 time points t_1, …, t_m and would like to compute the nth order derivatives of x with respect to t at these different time points.
Currently, I am using the naive approach of computing the nth derivative wrt. t at each t_i sample point separately as described here: python - Higher order gradients in pytorch - Stack Overflow 2
but this is prohibitively slow!
I have looked into potential ways of making torch.autograd.grad accept batches of input points (t_1, …, t_m) but with no success. It seems like this functionality is not implemented but I was hoping there is a better approach than computing the nth derivative with respect to each sample in a for loop.
Thank you!