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

real is not implemented for tensors with non-complex dtypes #225

Open
PengleiGao opened this issue Mar 8, 2023 · 2 comments
Open

real is not implemented for tensors with non-complex dtypes #225

PengleiGao opened this issue Mar 8, 2023 · 2 comments

Comments

@PengleiGao
Copy link

Hi, the dtype of the input is float32. there is no real of the input.
the problem raises here "t = t.real.to(y.abs().dtype)"
How to solve this problem?
1678256119272

@DrKarlWu
Copy link

DrKarlWu commented Apr 2, 2023

这个的主要原因是因为t应该是是一个复数张量(最少二维),但是在神经常微分方程,t一般是个实数张量(一维),所以只需要把这个t变成二维复数张量即可,虚部当然是一个0了。

 if t.numel() == 1:
     mid = [t.item(),0.0]
     t = torch.tensor(mid)
 t = torch.view_as_complex(t)
 t = t.real.to(y.abs().dtype)

@rtqichen
Copy link
Owner

rtqichen commented Apr 6, 2023

You should upgrade your PyTorch. The more recent versions (I think versions >= 1.6?) have .real implemented for non-complex tensor types. In the meantime, I'll work on a fix for the older PyTorch versions.

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

No branches or pull requests

3 participants