torchvision.models.resnet和torch.hub.load的不同之处是什么?
有两种使用Pytorch重新系统的方法。
方法1:
import torch
model = torch.hub.load('pytorch/vision:v0.10.0', 'resnet50', pretrained=True)
model.eval()
方法2:
import torch
net = models.resnet50(pretrained=True)
它们是否加载相同的模型。如果不是,有什么区别?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您以这种方式加载模型,则唯一的区别是层的数量,因为您正在加载
resnet18
使用 torch hub 和resnet50
带有模型(因此,也是预验证的权重)。它们的行为不同,您可以在Torch Hub 还可以让您在存储库中发布预估计的模型,但是由于您是从
'pytorch/vision加载它的:v0.10.0.0'
(它是从相同的存储库模型正在加载神经网络),之间应没有区别:
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 andresnet50
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:and