lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.58k stars 732 forks source link

Is it possible to compute the gradients after the functions approximation? #575

Open praksharma opened 2 years ago

praksharma commented 2 years ago

After doing a function approximation is it possible to compute gradients using the trained network.

Here is what I am trying to do.

my_data = genfromtxt('dataset.train')
x = my_data[:,0] 
y = my_data[:,1] 
x_np = torch.from_numpy(x)
y_np = torch.from_numpy(y)

<Something to connect them with the neural network graph.>  

dde.grad.hessian(y_np, x_np, i=0, j=0)

Can anyone help me to connect this gradient to the neural network graph?

lululxvi commented 2 years ago

See https://deepxde.readthedocs.io/en/latest/demos/pinn_forward/poisson.1d.dirichlet.html