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

Dimension error #189

Open
yuhua666 opened this issue Dec 8, 2022 · 2 comments
Open

Dimension error #189

yuhua666 opened this issue Dec 8, 2022 · 2 comments

Comments

@yuhua666
Copy link

yuhua666 commented Dec 8, 2022

encoder_dim = encoder_out.size(3)
Dimension out of range (expected to be in range of [-2, 1], but got 3)

@Leo-Thomas
Copy link

Sorry to bother you with something off topic. Have you been able to download the dataset from the links provided? I've been trying to download it for days but it doesn't work

@AndreiMoraru123
Copy link

AndreiMoraru123 commented Jan 21, 2023

encoder_dim = encoder_out.size(3) Dimension out of range (expected to be in range of [-2, 1], but got 3)

@yuhua666 , I am assuming you are not training in batches, this is why you are lacking that dimension. Your output features probably look like this:

encoder_dim = torch.rand(196, 2048)  # (num_pixels, dimensionality)
encoder_dim.size(3)  # This will result in your error. 

[-2, 1] means you can only call sizes from -2 to 1. 0 and 1 would be the first two sizes, and -1 and -2 would also be those two, but taken in reverse order (E.g. encoder_dim.size(-1) = 2048; encoder_dim.size(-2) = 196).

What you need right there in your search function is an encoder like this:

encoder_dim = torch.rand(10, 14, 14, 2048)  # (batch_size,  width, height, dimensionality)
encoder_dim.size(3)  # Now this will return your 2048 (number of filters)

If your GPU cannot hold multiple batches, you can just send it in one batch just to fill that dimension.

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