Is there pretrained CNN (e.g. ResNet) for CIFAR-10 or CIFAR-100?

yunjey: <p><code>torchvision.models</code> contains several pretrained CNNs (e.g AlexNet, VGG, ResNet). However, it seems that when input image size is small such as CIFAR-10, the above model can not be used.<br>
Should i implement it myself? Or, Does PyTorch offer pretrained CNN with CIFAR-10?</p>

smth: <p>We dont offer pre-trained resnet with cifar. You might have to train one yourself.</p>

skrish13: <p>Maybe NIN with CIFAR? :3</p>

skrish13: <p>Ahh. I saw your edits though, thanks <img src="//discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=5" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

jekbradbury: <p>Here’s code for a network known to do well on CIFAR, although they don’t include a pretrained model file <a href="https://github.com/xternalz/WideResNet-pytorch" rel="nofollow noopener">https://github.com/xternalz/WideResNet-pytorch</a></p>

skrish13: <p>Oh okay! I’ll see if I can train it. Thanks again!</p>

skrish13: <p>Didn’t we have a repo of links to PyTorch implementation of various papers? (Or I’m confusing that with Chainer’s similar repo :S)</p>

jekbradbury: <p>There’s this <a href="https://github.com/ritchieng/the-incredible-pytorch" rel="nofollow noopener">https://github.com/ritchieng/the-incredible-pytorch</a> (Chainer keeps a semi-official one, but it probably makes more sense to leave it to the community)</p>

skrish13: <p>Hmm yeah I guess. Thanks for the repo <img src="//discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=5" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

prlz77: <p>Hi, I uploaded resnet-v3 models in <a href="https://github.com/prlz77/ResNeXt.pytorch" rel="nofollow noopener">https://github.com/prlz77/ResNeXt.pytorch</a>, however they are not the full-sized ones, which you can train yourself with this code too <img src="//discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=5" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

Ismail_Elezi: <p>Sorry for the dumb question, but how do you load a .pytorch file. Is it the same extension as .pth?</p>
<p>This doesn’t seem to work:</p>
<blockquote>
<p>net = torch.load(‘model.pytorch’)</p>
</blockquote>

prlz77: <p>I think this is the way: <a href="http://stackoverflow.com/questions/42703500/best-way-to-save-a-trained-model-in-pytroch" rel="nofollow noopener">http://stackoverflow.com/questions/42703500/best-way-to-save-a-trained-model-in-pytroch</a></p>

Ismail_Elezi: <p>What would be TheModelClass for your model?</p>

Ismail_Elezi: <p><a class="mention" href="/u/jekbradbury">@jekbradbury</a></p>
<p>Did you manage to train/load the model successfully? I managed to train it, but I am having a sizes do not match error, when I am trying to load it. I am trying to load it with the following code:</p>
<blockquote>
<p>model = wrn.WideResNet(layers, 10)<br>
model = model.cuda()<br>
checkpoint = torch.load(‘runs/WideResNet-28-10/checkpoint.pth.tar’)<br>
model.load_state_dict(checkpoint[‘state_dict’])</p>
</blockquote>
<p>but getting:</p>
<blockquote>
<p>RuntimeError: sizes do not match at /data/users/soumith/miniconda2/conda-bld/pytorch-0.1.7_1485444530918/work/torch/lib/THC/THCTensorCopy.cu:31</p>
</blockquote>

karlTUM: <p><a class="mention" href="/u/ismail_elezi">@Ismail_Elezi</a>  Did you solve your problem? I also got the same when I tried to resume to train a network.</p>

Ismail_Elezi: <p>Yes, I managed to load ResNets that I trained on CIFAR datasets. The code for that is:</p>
<blockquote>
<p>model = wrn.WideResNet(depth=number_of_layers, num_classes=100, widen_factor=4)<br>
checkpoint = torch.load(‘runs/WideResNet-28-10/cifar_10.pth.tar’)<br>
model.load_state_dict(checkpoint[‘state_dict’])<br>
model = model.cuda()</p>
</blockquote>
<p>The parameters for the model and for the net you are loading should agree.</p>
<p>For what is worth, the accuracy I got was:</p>
<blockquote>
<p>Cifar-10:     0.9548<br>
Cifar-100:   0.7868​</p>
</blockquote>
<p>with these hyperparameters:</p>
<blockquote>
<p>layers: 40 convs<br>
learning rate: 0.1<br>
momentum: nesterov with 0.9 param<br>
regularization: Tikhonov with 5e-4 param<br>
widen_factor: 4<br>
batch size: 128<br>
number of epochs: 200</p>
</blockquote>
<p>Would be interesting to see what happens if I use some more advanced optimizer like Adam.</p>
<p>Anyway, in case you don’t have time to train them, I can upload the models today, during the afternoon.</p>

prlz77: <p>I just read your question! Nice to know you managed <img src="//discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=5" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

raaj043: <p>Hi,</p>
<p>Then on which dataset all the models are pretrained?</p>

smth: <p>they’re all pre-trained on Imagenet-12</p>

raaj043: <p>Thank you very much. Its helpfulu</p>