Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the different for torchvision.models.resnet and torch.hub.load?

There are two method for using resnet of pytorch.

methods 1:

import torch
model = torch.hub.load('pytorch/vision:v0.10.0', 'resnet50', pretrained=True)
model.eval()

methods 2:

import torch    
net = models.resnet50(pretrained=True)

Are they load the same model. If not what is the difference?

like image 916
tidy Avatar asked Nov 04 '25 10:11

tidy


1 Answers

The only difference that there is between your models if you load them in that way it's the number of layers, since you're loading resnet18 with Torch Hub and resnet50 with Models (thus, also the pretrained weights). They behave differently, you can see more about that in this paper.

Torch Hub also lets you publish pretrained models in your repository, but since you're loading it from 'pytorch/vision:v0.10.0' (which is the same repository from which Models is loading the neural networks), there should be no difference between:

model = torch.hub.load('pytorch/vision', 'resnet18', pretrained=True)

and

model = models.resnet18(pretrained=True)
like image 173
Mhackiori Avatar answered Nov 07 '25 14:11

Mhackiori



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!