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

Setting a 2D tensor to RandomAffine() after instantiation got other error message against error message #8861

Open
hyperkai opened this issue Jan 16, 2025 · 0 comments

Comments

@hyperkai
Copy link

hyperkai commented Jan 16, 2025

🐛 Describe the bug

Setting a 1D tensor to RandomAffine() after instantiation got the error message as shown below:

import torch
from torchvision.transforms.v2 import RandomAffine

my_tensor = torch.tensor([0]) # 1D

ra = RandomAffine(degrees=0)

ra(my_tensor) # Error

TypeError: Input tensor should have at least two dimensions, but got 1

But, setting a 2D tensor to RandomAffine() after instantiation got other error message against the above error message as shown below:

import torch
from torchvision.transforms.v2 import RandomAffine

my_tensor = torch.tensor([[0, 1, 2]]) # 2D tensor

ra = RandomAffine(degrees=0)

ra(my_tensor) # Error

ValueError: not enough values to unpack (expected 3, got 2)

In addition, setting a 3D tensor to RandomAffine() after instantiation works as shown below:

import torch
from torchvision.transforms.v2 import RandomAffine

my_tensor = torch.tensor([[[0, 1, 2]]]) # 3D tensor

ra = RandomAffine(degrees=0)

ra(my_tensor)
# tensor([[[0, 1, 2]]])

Versions

import torchvision

torchvision.__version__ # '0.20.1'
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

1 participant