examples icon indicating copy to clipboard operation
examples copied to clipboard

InceptionV3 cannot work!

Open happsky opened this issue 6 years ago • 8 comments

python main.py -a inception_v3 ./imagenet/cat2dog --batch-size 16 --print-freq 1 --pretrained; => using pre-trained model 'inception_v3' Traceback (most recent call last): File "main.py", line 314, in main() File "main.py", line 157, in main train(train_loader, model, criterion, optimizer, epoch) File "main.py", line 189, in train target = target.cuda(non_blocking=True) TypeError: _cuda() got an unexpected keyword argument 'non_blocking'

happsky avatar May 27 '18 21:05 happsky

Are you using pytorch 0.4?

import torch
print(torch.__version__)

karandwivedi42 avatar May 27 '18 21:05 karandwivedi42

My version is 0.3.0.post4, should I update to 0.4?

happsky avatar May 27 '18 22:05 happsky

Yes

karandwivedi42 avatar May 27 '18 23:05 karandwivedi42

After updating. export CUDA_VISIBLE_DEVICES=0; python main.py -a inception_v3 ./cat2dog --batch-size 16 --print-freq 1 --pretrained; => using pre-trained model 'inception_v3' Traceback (most recent call last): File "main.py", line 313, in main() File "main.py", line 157, in main train(train_loader, model, criterion, optimizer, epoch) File "main.py", line 192, in train output = model(input) File "/home/hao/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "/home/hao/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 112, in forward return self.module(*inputs[0], **kwargs[0]) File "/home/hao/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "/home/hao/anaconda3/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/models/inception.py", line 109, in forward File "/home/hao/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "/home/hao/anaconda3/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/models/inception.py", line 308, in forward File "/home/hao/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "/home/hao/anaconda3/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/models/inception.py", line 325, in forward File "/home/hao/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "/home/hao/anaconda3/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 301, in forward self.padding, self.dilation, self.groups) RuntimeError: Expected tensor for argument #1 'input' to have the same dimension as tensor for 'result'; but 4 does not equal 2 (while checking arguments for cudnn_convolution)

happsky avatar May 27 '18 23:05 happsky

export CUDA_VISIBLE_DEVICES=0; python main.py -a inception_v3 ./cat2dog --batch-size 16 --print-freq 1 --pretrained; => using pre-trained model 'inception_v3' torch.Size([16, 3, 299, 299]) Traceback (most recent call last): File "main.py", line 324, in main() File "main.py", line 164, in main train(train_loader, model, criterion, optimizer, epoch) File "main.py", line 207, in train prec1, prec5 = accuracy(output, target, topk=(1, 5)) File "main.py", line 312, in accuracy _, pred = output.topk(maxk, 1, True, True) AttributeError: 'tuple' object has no attribute 'topk'

happsky avatar May 28 '18 00:05 happsky

@happsky see issue 4884. Increasing input size or adapting the network architecture seems to fix this as Kernel size in later layers can get too large for the corresponding feature map.

0xsanny avatar Jun 07 '18 08:06 0xsanny

I came across same problem, too.

Can not I train Inception_v3 model with 224x224 size?

Is there only Increasing input size solution?

youngwanLEE avatar Nov 09 '18 12:11 youngwanLEE

I observed the following error while executing the inception v3 sample:

RuntimeError: Calculated padded input size per channel: (3 x 3). Kernel size: (5 x 5). Kernel size can't be greater than actual input size

Then I came across the PR - https://github.com/pytorch/examples/pull/268 and tried to use the fix, but doesn't work for me.

I get the following error:

    return type(out)(map(gather_map, zip(*outputs)))
TypeError: __new__() missing 1 required positional argument: 'aux_logits'

deepali-c avatar Sep 11 '19 12:09 deepali-c