Skip to content

AttributeError: 'torch.return_types.max' object has no attribute 'shape'" #8040

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

Closed
KumoLiu opened this issue Aug 22, 2024 · 0 comments · Fixed by #8041
Closed

AttributeError: 'torch.return_types.max' object has no attribute 'shape'" #8040

KumoLiu opened this issue Aug 22, 2024 · 0 comments · Fixed by #8041

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 22, 2024

import torch
from monai.transforms.utils_pytorch_numpy_unification import max

a = torch.rand(6, 8, 3)
b = max(a, dim=1)
print(type(b), (isinstance(b, tuple)))
print(b.shape)

Return:

<class 'torch.return_types.max'> True
{
	"name": "AttributeError",
	"message": "'torch.return_types.max' object has no attribute 'shape'",
	"stack": "---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[8], line 7
      5 b = max(a, dim=1)
      6 print(type(b), (isinstance(b, tuple)))
----> 7 print(b.shape)

AttributeError: 'torch.return_types.max' object has no attribute 'shape'"
}
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Aug 22, 2024
Signed-off-by: YunLiu <[email protected]>
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 a pull request may close this issue.

1 participant