I want to run python program using pytorch with my own dataset.I come across with the error: Traceback (most recent call last): File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py", line 345, in fire.Fire(demo) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py", line 138, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py", line 468, in _Fire target=component.name) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py", line 672, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py", line 323, in demo n_epochs=n_epochs, batch_size=batch_size, seed=seed) File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py", line 202, in train n_epochs=n_epochs, File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py", line 83, in train_epoch output = model(input) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py", line 555, in call result = self.forward(*input, **kwargs) File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\models\densenet.py", line 151, in forward features = self.features(x) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py", line 555, in call result = self.forward(*input, **kwargs) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\container.py", line 100, in forward input = module(input) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py", line 555, in call result = self.forward(*input, **kwargs) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\container.py", line 100, in forward input = module(input) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py", line 555, in call result = self.forward(*input, **kwargs) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\pooling.py", line 557, in forward self.padding, self.ceil_mode, self.count_include_pad, self.divisor_override) RuntimeError: Given input size: (150x1x1). Calculated output size: (150x0x0). Output size is too small Please guide me how to sove this problem.Thanks in advance!
Asked
Active
Viewed 182 times
1 Answers
0
Please check the input size of the image. It has to be exactly the same as specified in the model. You can use padding if the image is smaller.

Ajai
- 1,049
- 1
- 11
- 23
-
Thank you very much!The input size is:torch.Size([1, 3, 3, 158]) – thaingi May 06 '20 at 07:46
-
Can't say anything without knowing your model. Keep in mind that, When you pass the input down the model, the sizes get smaller and smaller especially with max pooling. So if you input a small image, the output gets very low dimension in the middle, making it impossible to go down the rest of the model. – Ajai May 06 '20 at 09:38
-
Thanks!Please answer how to use padding. – thaingi May 06 '20 at 09:58
-
That's a seperate question. Search before asking. Eg: https://stackoverflow.com/questions/43391205/add-padding-to-images-to-get-them-into-the-same-shape – Ajai May 06 '20 at 10:04
-
Thanks you very much! – thaingi May 06 '20 at 10:20