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

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

Here is the link to repo that has pretrained ResNets for CIFAR10, and this models are lean-resnets discussed in original paper. If you directly apply ResNets from torchvision to train your own net, you’ll get something that is not in original paper, because torchvision’s nets are for ImageNet, not CIFAR10

I also searched for pretrained Pytorch models on CIFAR-10 but I could not find any repo that share weights so I made one:

19

6 Likes

Thanks for that question! It is really confusing first if one is new to ML and tries to find an explanation on which datasets pretrained models are fit on.