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

Error running with CUB #19

Open
vunh opened this issue Nov 4, 2020 · 3 comments
Open

Error running with CUB #19

vunh opened this issue Nov 4, 2020 · 3 comments

Comments

@vunh
Copy link

vunh commented Nov 4, 2020

Hi,

I am running with CUB with the following command:
python3 main.py --dataset_root dataset --config config/5way_1shot_resnet12_cub-200.py --num_gpu 1 --mode train

And I got this error
File "main.py", line 579, in
main()
File "main.py", line 570, in main
trainer.train()
File "main.py", line 105, in train
last_layer_data, second_last_layer_data = backbone_two_stage_initialization(all_data, self.enc_module)
File "/data/add_disk0/vhnguyen/cvpr21/DPGN/utils.py", line 197, in backbone_two_stage_initialization
encoded_result = encoder(data.squeeze(1))
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/data/add_disk0/vhnguyen/cvpr21/DPGN/backbone.py", line 101, in forward
x = self.avgpool(x)
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/pooling.py", line 595, in forward
self.padding, self.ceil_mode, self.count_include_pad, self.divisor_override)
RuntimeError: Given input size: (512x6x6). Calculated output size: (512x0x0). Output size is too small

Could you please let me know how to fix this?

Thank you very much.

@tiber2013
Copy link

Hi,

I am running with CUB with the following command:
python3 main.py --dataset_root dataset --config config/5way_1shot_resnet12_cub-200.py --num_gpu 1 --mode train

And I got this error
File "main.py", line 579, in
main()
File "main.py", line 570, in main
trainer.train()
File "main.py", line 105, in train
last_layer_data, second_last_layer_data = backbone_two_stage_initialization(all_data, self.enc_module)
File "/data/add_disk0/vhnguyen/cvpr21/DPGN/utils.py", line 197, in backbone_two_stage_initialization
encoded_result = encoder(data.squeeze(1))
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/data/add_disk0/vhnguyen/cvpr21/DPGN/backbone.py", line 101, in forward
x = self.avgpool(x)
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/pooling.py", line 595, in forward
self.padding, self.ceil_mode, self.count_include_pad, self.divisor_override)
RuntimeError: Given input size: (512x6x6). Calculated output size: (512x0x0). Output size is too small

Could you please let me know how to fix this?

Thank you very much.

I meet the same question, too.

@tiber2013
Copy link

Hi,

I am running with CUB with the following command:
python3 main.py --dataset_root dataset --config config/5way_1shot_resnet12_cub-200.py --num_gpu 1 --mode train

And I got this error
File "main.py", line 579, in
main()
File "main.py", line 570, in main
trainer.train()
File "main.py", line 105, in train
last_layer_data, second_last_layer_data = backbone_two_stage_initialization(all_data, self.enc_module)
File "/data/add_disk0/vhnguyen/cvpr21/DPGN/utils.py", line 197, in backbone_two_stage_initialization
encoded_result = encoder(data.squeeze(1))
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/data/add_disk0/vhnguyen/cvpr21/DPGN/backbone.py", line 101, in forward
x = self.avgpool(x)
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/pooling.py", line 595, in forward
self.padding, self.ceil_mode, self.count_include_pad, self.divisor_override)
RuntimeError: Given input size: (512x6x6). Calculated output size: (512x0x0). Output size is too small

Could you please let me know how to fix this?

Thank you very much.

I fixed this by rolling back pytorch version to 1.1.0

@zilunzhang
Copy link
Collaborator

zilunzhang commented Dec 21, 2020

Hi,

I am running with CUB with the following command:
python3 main.py --dataset_root dataset --config config/5way_1shot_resnet12_cub-200.py --num_gpu 1 --mode train

And I got this error
File "main.py", line 579, in
main()
File "main.py", line 570, in main
trainer.train()
File "main.py", line 105, in train
last_layer_data, second_last_layer_data = backbone_two_stage_initialization(all_data, self.enc_module)
File "/data/add_disk0/vhnguyen/cvpr21/DPGN/utils.py", line 197, in backbone_two_stage_initialization
encoded_result = encoder(data.squeeze(1))
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/data/add_disk0/vhnguyen/cvpr21/DPGN/backbone.py", line 101, in forward
x = self.avgpool(x)
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/vhnguyen/anaconda2/envs/py36_torch1_7/lib/python3.6/site-packages/torch/nn/modules/pooling.py", line 595, in forward
self.padding, self.ceil_mode, self.count_include_pad, self.divisor_override)
RuntimeError: Given input size: (512x6x6). Calculated output size: (512x0x0). Output size is too small

Could you please let me know how to fix this?

Thank you very much.

Hi, we developed the model based on PyTorch 1.1.

In PyTorch 1.1, PyTorch seems to catch the exception where AvgPool2d size > remaining feature map size and fixed the exception automatically (That's the reason we didn't notice this bug).

In some other PyTorch version, PyTorch does not catch the exception.

You could solve the error by changing the PyTorch version to 1.1 or changing the size of AvgPool2d to 6.

Best,

DPGN teams

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