deepxde icon indicating copy to clipboard operation
deepxde copied to clipboard

Calculating the NN output in "losses" function of PDE class

Open tsarikahin opened this issue 1 year ago • 3 comments

Dear Lu Lu,

I have one question regarding calculating NN output during the loss calculation of the PDE class. I am reformulating PDE class so that I can pursue calculations based on elements, not collocation points (PINNs based on weak formulation, Variational PINNs). To achieve that, I decided to make a loop for each element, which requires output of NN for that provided element. As shown below, outputs term contains the NN for the input, basically (train_x_all). However, I would like to obtain NN output for any given placeholder, not the prediction of course since we still build losses. How can I achieve that? I just need to calculate NN output based on updated network. I tried couple of things but I could not obtain that.

def losses(self, targets, outputs, loss_fn, inputs, model, aux=None):
.
.
.

tsarikahin avatar Nov 14 '23 17:11 tsarikahin

@lululxvi

For instance, model argument in losses function has already net. But I could not see that how can I calculate NN output from there.

tsarikahin avatar Nov 14 '23 17:11 tsarikahin

For instance, for torch as backend, there is forward function in fnn module. What about tensorflow.compat_v1?

tsarikahin avatar Nov 14 '23 18:11 tsarikahin

Hey I think the forward pass for fnn with Tensorflow 1.x is here.

praksharma avatar Nov 27 '23 12:11 praksharma