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

torchvision.models 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.
Should i implement it myself? Or, Does PyTorch offer pretrained CNN with CIFAR-10?

1 Like

We dont offer pre-trained resnet with cifar. You might have to train one yourself.

Maybe NIN with CIFAR? :3

Ahh. I saw your edits though, thanks :slight_smile:

Here’s code for a network known to do well on CIFAR, although they don’t include a pretrained model file https://github.com/xternalz/WideResNet-pytorch

2 Likes

Oh okay! I’ll see if I can train it. Thanks again!

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)

1 Like

There’s this https://github.com/ritchieng/the-incredible-pytorch (Chainer keeps a semi-official one, but it probably makes more sense to leave it to the community)

2 Likes

Hmm yeah I guess. Thanks for the repo :slight_smile:

Hi, I uploaded resnet-v3 models in https://github.com/prlz77/ResNeXt.pytorch, however they are not the full-sized ones, which you can train yourself with this code too :slight_smile:

Sorry for the dumb question, but how do you load a .pytorch file. Is it the same extension as .pth?

This doesn’t seem to work:

net = torch.load(‘model.pytorch’)

I think this is the way: http://stackoverflow.com/questions/42703500/best-way-to-save-a-trained-model-in-pytroch

What would be TheModelClass for your model?

@jekbradbury

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:

model = wrn.WideResNet(layers, 10)
model = model.cuda()
checkpoint = torch.load(‘runs/WideResNet-28-10/checkpoint.pth.tar’)
model.load_state_dict(checkpoint[‘state_dict’])

but getting:

RuntimeError: sizes do not match at /data/users/soumith/miniconda2/conda-bld/pytorch-0.1.7_1485444530918/work/torch/lib/THC/THCTensorCopy.cu:31

@Ismail_Elezi Did you solve your problem? I also got the same when I tried to resume to train a network.

Yes, I managed to load ResNets that I trained on CIFAR datasets. The code for that is:

model = wrn.WideResNet(depth=number_of_layers, num_classes=100, widen_factor=4)
checkpoint = torch.load(‘runs/WideResNet-28-10/cifar_10.pth.tar’)
model.load_state_dict(checkpoint[‘state_dict’])
model = model.cuda()

The parameters for the model and for the net you are loading should agree.

For what is worth, the accuracy I got was:

Cifar-10: 0.9548
Cifar-100: 0.7868​

with these hyperparameters:

layers: 40 convs
learning rate: 0.1
momentum: nesterov with 0.9 param
regularization: Tikhonov with 5e-4 param
widen_factor: 4
batch size: 128
number of epochs: 200

Would be interesting to see what happens if I use some more advanced optimizer like Adam.

Anyway, in case you don’t have time to train them, I can upload the models today, during the afternoon.

I just read your question! Nice to know you managed :slight_smile:

Hi,

Then on which dataset all the models are pretrained?

they’re all pre-trained on Imagenet-12

Thank you very much. Its helpfulu