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

ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1]) #103

Open
zzzzzz-ddddd opened this issue Mar 28, 2022 · 1 comment

Comments

@zzzzzz-ddddd
Copy link

When I run train.py file reported an error, and then modified the drop in the dataloader_ Last is true Running again is the same error. Do not know why? Thank you for your answers.(python=3.8 pytorch=1.4.0 cudatoolkit=10.2)
give the result as follows

epochs: 0%| | 0/10 [00:01<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 203, in
main()
File "train.py", line 157, in main
train_model(
File "/home/ubuntu/zdq/CaDDN/tools/train_utils/train_utils.py", line 86, in train_model
accumulated_iter = train_one_epoch(
File "/home/ubuntu/zdq/CaDDN/tools/train_utils/train_utils.py", line 38, in train_one_epoch
loss, tb_dict, disp_dict = model_func(model, batch)
File "/home/ubuntu/zdq/CaDDN/pcdet/models/init.py", line 39, in model_func
ret_dict, tb_dict, disp_dict = model(batch_dict)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/ubuntu/zdq/CaDDN/pcdet/models/detectors/caddn.py", line 11, in forward
batch_dict = cur_module(batch_dict)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/ubuntu/zdq/CaDDN/pcdet/models/backbones_3d/ffe/depth_ffe.py", line 51, in forward
ddn_result = self.ddn(images)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/ubuntu/zdq/CaDDN/pcdet/models/backbones_3d/ffe/ddn/ddn_template.py", line 114, in forward
x = self.model.classifier(x)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/container.py", line 100, in forward
input = module(input)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torchvision/models/segmentation/deeplabv3.py", line 92, in forward
res.append(conv(x))
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torchvision/models/segmentation/deeplabv3.py", line 61, in forward
x = mod(x)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/modules/batchnorm.py", line 104, in forward
return F.batch_norm(
File "/home/ubuntu/anaconda3/envs/caddn/lib/python3.8/site-packages/torch/nn/functional.py", line 1666, in batch_norm
raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size))
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1])

@thom966
Copy link

thom966 commented Apr 25, 2022

This is because batch norm expects more than 1 batch size. Change your batch size in the .yaml file.

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

2 participants