Pytorch model zoo

Just working through the lesson1-pets notebook, which involves using resnet34, resnet50, and resnet18, all downloaded from the PyTorch site. There is mention of a model zoo on the PyTorch site, but the docs seem opaque on which models are available and how to access them.

Where can one find documentation for the models that are available and how to load them?

You should check out the fastai docs, where they have provided a link for the available pytorch models, and also extended that list.
For usage, if we are talking about an application related to vision, you can pass the desired model to a ConvLearner as a parameter: models.resnet18, models.densenet169 etc. as shown in the first lesson with models.resnet50/models.resnet34.


Thanks kindly, Ilona.

It’s powerful to have easy access to so many models…

It is, indeed!

And we’ll add more in the future :wink:


@sgugger, @jeremy

Hey look what this guys are doing. :slight_smile:


Yup we know Remi well :slight_smile:


I am trying to use densenet in with create_cnn() but it gives me error how can i Use densnet in for transfer learning –
I get the following error in default pipeline-
arch = models.densenet169

AttributeError: module '' has no attribute 'densenet169'

DenseNet isn’t available by default in the fastai library, so I believe you’ll need to import it from torchvision.models:

from torchvision.models import densenet161
1 Like

I figure it out how to use torchvision model but when go for the pretrainedmodels pytorch cadene libaray I can’t use the nasnetamobile or pnasnet can you help me with this.

Can u please tell us how you have done that?

I have been playing with Cifar10 dataset for the last week or so with fastai-V1.
Remi’s pretrained models Squeeze-n-Excitation (se_resnet50) and fastai V1. I got my new year’s gift.
Accuracy 0.9627
Cifar10-se_resnet.pdf (850.4 KB)


Just one thing about passing models.densenetxxx, I got the following warning (cc @sgugger):

I think that’s an issue for torchvision.

Regarding densenet models, they seem to really suck up GPU memory relative to resnets. Does anyone else notice this?

Yes. Jeremy talks about that in Lesson 7 here. The timestamp I’ve given begins his discussion of it, and he gets to exactly why that is about 2mins in.

1 Like

Thanks for sharing. Would anyone happen to know which dataset the densenets were trained on initially?