lululxvi / hpinn

hPINN: Physics-informed neural networks with hard constraints
Apache License 2.0
109 stars 35 forks source link

Does Pytorch BackEnd Support Augmented Lagrangian #8

Open ppandit95 opened 2 months ago

ppandit95 commented 2 months ago

Dear Dr. Lu Lu

I was trying to run DeepXDE with Pytorch backend and implemented Augmented Lagrangian Method which I had earlier successfully implemented with tensorflow backend and upon running the pytorch code I m getting the following error message as - ` Using backend: pytorch Other supported backends: tensorflow.compat.v1, tensorflow, jax, paddle. paddle supports more examples now and is recommended. Set the default float type to float64

Iteration 0:mu = 1,1,1

Compiling model... 'compile' took 1.367433 s

Training model...

Traceback (most recent call last): File "/export/home/pushkar/DeepXDE/WorkSpace/Ternary_Diffusion/Ternary_Diffusion.py", line 251, in losshistory, train_state = model.train(iterations=1000,callbacks=[variable,checkpointer],model_save_path=os.path.join(dir_name,subdir_name,subsubdir_name,model_name)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/utils/internal.py", line 22, in wrapper result = f(*args, **kwargs) ^^^^^^^^^^^^^^^^^^ File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/model.py", line 636, in train self._test() File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/model.py", line 825, in _test ) = self._outputs_losses( ^^^^^^^^^^^^^^^^^^^^^ File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/model.py", line 546, in _outputs_losses outs = outputs_losses(inputs, targets, auxiliary_vars) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/model.py", line 320, in outputs_losses_train return outputs_losses( ^^^^^^^^^^^^^^^ File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/model.py", line 308, in outputs_losses losses = lossesfn(targets, outputs, loss_fn, inputs, self, aux=aux) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/data/data.py", line 13, in losses_train return self.losses(targets, outputs, loss_fn, inputs, model, aux=aux) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/data/pde.py", line 170, in losses loss_fn[i](bkd.zeros_like(error), error) for i, error in enumerate(error_f) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/export/home/pushkar/.conda/envs/DeepXDE/lib/python3.12/site-packages/deepxde/losses.py", line 37, in zero return tf.constant(0, dtype=config.real(tf)) ^^^^^^^^^^^ AttributeError: 'function' object has no attribute 'constant'

` Is this because of pytorch backend or something else , any headers in this regard will prove beneficial .

Many Thanks Pushkar