X is [n,2] matric which compose x and t. I am using Pytorch to compute differential of u(x,t) wrt to X to get du/dt and du/dx and du/dxx. Here is my piece of code
X.requires_grad = True
p = mlp(X)
grads, = torch.autograd.grad(p, X, grad_outputs=p.data.new(p.shape).fill_(1),create_graph=True, only_inputs=True)
grads1, = torch.autograd.grad(grads, X,  grad_outputs=grads.data.new(grads.shape).fill_(1), create_graph=True, only_inputs=True)
dpdx, dpdt = grads[:,0], grads[:,1]
dpdxx = grads1[:,0]
I am not getting satisfactory result. I think something is wrong when i am calculating 2 differential. can anyone help me?