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
Error in trying to use for the first time #1
Comments
The "size mismatch" error looks like its coming from the final classification layer. Did you set the |
Hi, Yes, I have set the num_classes. I managed to have a training working with my images and resnet (adapting the resnet to the size of my images as described in pytorch/vision#155). I will keep looking, Thanks, Christophe |
My other guess is that its a pooling issue. The default settings (3 pooling blocks) will reduce a 32x32 image into 1x1 feature maps by the last layer. An 80x80 image might instead be reduced to 3x3 feature maps, which cannot directly be fed into the classifier without further pooling (or increasing the size of the layer). |
By trying different values, I found that setting the avgpool_size to 10 solves the problem. Thanks for the assistance, Christophe |
@chmaz Hi, I haven't seen this issue until now. If you are going to test different size of images, I would recommend you using AdaptiveAvgPool2d or AdaptiveMaxPool2d instead of manually setting up the avgpooling size. I guess this would be much more convenient for you. :D |
Hello,
I am a beginner in python and pyTorch and am trying to use your densenet efficient implementation on a different dataset than CIFAR (images are 80 pixels wide, instead of 32). I use a windows 10 laptop with the experimental pyTorch port on Windows by peterjc123 (see pytorch/pytorch#494).
I have incorporated your DenseNetEfficient model in a training script adapted from andreasveit's densenet implementation for pyTorch and replaced the CIFAR datasets loaders with datasets ImageFolder as follows:
train_loader = torch.utils.data.DataLoader(
datasets.CIFAR10('../data', train=True, download=True,
transform=transform_train),
When launching the training script; I get a cryptic error (for me):
Traceback (most recent call last):
File "train.py", line 312, in
main()
File "train.py", line 153, in main
train(train_loader, model, criterion, optimizer, epoch)
File "train.py", line 185, in train
output = model(input_var)
File "D:\deepLearning\Anaconda\lib\site-packages\torch\nn\modules\module.py", line 206, in call
result = self.forward(*input, **kwargs)
File "D:\deepLearning\densenet\densenetEfficient.py", line 213, in forward
out = self.classifier(out)
File "D:\deepLearning\Anaconda\lib\site-packages\torch\nn\modules\module.py", line 206, in call
result = self.forward(*input, **kwargs)
File "D:\deepLearning\Anaconda\lib\site-packages\torch\nn\modules\linear.py", line 54, in forward
return self.backend.Linear.apply(input, self.weight, self.bias)
File "D:\deepLearning\Anaconda\lib\site-packages\torch\nn_functions\linear.py", line 12, in forward
output.addmm(0, 1, input, weight.t())
RuntimeError: size mismatch at d:\downloads\pytorch-master-1\torch\lib\thc\generic/THCTensorMathBlas.cu:243
I am surely doing something wrong but searched a lot and did not find anything,
Any recommendation would be welcome,
Thanks a lot,
Christophe
The text was updated successfully, but these errors were encountered: