Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in PDEOperatorCartesianProd #1927

Closed
wants to merge 1 commit into from

Conversation

jkquigley
Copy link

Running operator examples with PyTorch backend throws an error shown below:

Using backend: pytorch
Other supported backends: tensorflow.compat.v1, tensorflow, jax, paddle.
paddle supports more examples now and is recommended.
Compiling model...
'compile' took 0.816340 s

Training model...

Traceback (most recent call last):
  File ".../deepxde/examples/operator/poisson_1d_pideeponet.py", line 61, in <module>
    model.train()
  File ".../deepxde/deepxde/utils/internal.py", line 22, in wrapper
    result = f(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^
  File ".../deepxde/deepxde/model.py", line 673, in train
    self._test(verbose=verbose)
  File ".../deepxde/deepxde/model.py", line 866, in _test
    ) = self._outputs_losses(
        ^^^^^^^^^^^^^^^^^^^^^
  File ".../deepxde/deepxde/model.py", line 579, in _outputs_losses
    outs = outputs_losses(inputs, targets, auxiliary_vars)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../deepxde/deepxde/model.py", line 325, in outputs_losses_train
    return outputs_losses(
           ^^^^^^^^^^^^^^^
  File ".../deepxde/deepxde/model.py", line 316, in outputs_losses
    losses = torch.stack(losses)
             ^^^^^^^^^^^^^^^^^^^
TypeError: expected Tensor as element 1 in argument 0, but got list

This change ensures that the losses variable is a compatible type for torch.stack.

@lululxvi
Copy link
Owner

lululxvi commented Jan 3, 2025

Fixed at #1925

@lululxvi lululxvi closed this Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants