pytorch / examples

A set of examples around pytorch in Vision, Text, Reinforcement Learning, etc.
https://pytorch.org/examples
BSD 3-Clause "New" or "Revised" License
22.41k stars 9.53k forks source link

InceptionV3 cannot work! #362

Open happsky opened 6 years ago

happsky commented 6 years ago

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'

karandwivedi42 commented 6 years ago

Are you using pytorch 0.4?

import torch
print(torch.__version__)
happsky commented 6 years ago

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

karandwivedi42 commented 6 years ago

Yes

happsky commented 6 years ago

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

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(trainloader, 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'

sannykim commented 6 years ago

@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.

youngwanLEE commented 5 years ago

I came across same problem, too.

Can not I train Inception_v3 model with 224x224 size?

Is there only Increasing input size solution?

deepali-c commented 5 years ago

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'