lululxvi / deepxde

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

AttributeError on auxiliary_var_fn obtaining residuals using PI-DeepONet #1590

Open PhilippBrendel opened 9 months ago

PhilippBrendel commented 9 months ago

Hi,

I am trying to get the residuals during/after training a DeepONet. Using the same approach that works in the "standard" PINN case

residuals = np.absolute(self.model.predict(x, callbacks=..., operator=self.pde))

yields the following Error:

File "/.../deepxde/model.py", line 883, in predict aux_vars = self.data.auxiliary_var_fn(x).astype(config.real(np)) AttributeError: 'PDEOperatorCartesianProd' object has no attribute 'auxiliary_var_fn'

As to be expected, e.g. from the 1D poisson tutorial , the code is trying to access PDEOperatorCartesianProd object instead of the TimePDE object with which the model would be initialized in a standard PINN example

Enforcing the correct underlying TimePDE object to be used here via a direct source code change does not work either as the attribute seems to be None.

File "/home/users/brendel/.local/lib/python3.9/site-packages/deepxde/model.py", line 884, in predict aux_vars = self.data.pde.auxiliary_var_fn(x).astype(config.real(np)) TypeError: 'NoneType' object is not callable

Is this a bug or can someone help me out here?

Best, Philipp

lululxvi commented 9 months ago

model.predict cannot work with PDEOperatorCartesianProd yet. It is not a bug, but needs more code implementation. You may use other numerical methods to get the error now.

PhilippBrendel commented 9 months ago

Dear @lululxvi, thank you for the clarification, I will check other options!

I have a slightly related question that you might be able to answer quickly:

Can PDEOperatorCartesianProd work with MIONetCartesianProd out-of-the-box or do I need to create my own version of it supporting MIONet? I tried to use it that way but it's giving me shape errors on standard boundary conditions.

So far I have only found this repo for data-driven approach with MIONet, but I want to train a physics-informed MIONet, see e.g. this work.

Best, Philipp

lululxvi commented 8 months ago

Can PDEOperatorCartesianProd work with MIONetCartesianProd out-of-the-box?

No. You need to implement your version.