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

errors when use model.train() #19

Closed
CachCheng opened this issue Mar 27, 2020 · 2 comments
Closed

errors when use model.train() #19

CachCheng opened this issue Mar 27, 2020 · 2 comments

Comments

@CachCheng
Copy link

Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1741, in
main()
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/CNN/IndexNet-master/algorithm/demo.py", line 36, in
detector.train()
File "/Users/CNN/IndexNet-master/algorithm/train/train.py", line 100, in train
outputs = self.net(image).squeeze().cpu().data.numpy()
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 140, in forward
return self.module(*inputs, **kwargs)
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/Users/CNN/IndexNet-master/algorithm/network/hlmobilenetv2.py", line 1134, in forward
l = self.dconv_pp(l7) # 160x10x10
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/Users/CNN/IndexNet-master/algorithm/network/hlaspp.py", line 139, in forward
x5 = self.global_avg_pool(x)
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/modules/container.py", line 92, in forward
input = module(input)
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 83, in forward
exponential_average_factor, self.eps)
File "/Users/anaconda3/lib/python3.7/site-packages/torch/nn/functional.py", line 1693, 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])

@poppinace
Copy link
Owner

Hi, this error is due to the batch size is set to be 1. Increase the batch size and try again:)

@CachCheng
Copy link
Author

Can you provide the train loss function? Thanks!

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