poppinace / indexnet_matting

(ICCV'19) Indices Matter: Learning to Index for Deep Image Matting
Other
389 stars 90 forks source link

errors when use model.train() #19

Closed CachCheng closed 4 years ago

CachCheng commented 4 years ago

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 commented 4 years ago

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

CachCheng commented 4 years ago

Can you provide the train loss function? Thanks!