簡體   English   中英

在 PyTorch 中加載 resnet50 prettriated model

[英]Loading resnet50 prettrianed model in PyTorch

我想使用 resnet50 預訓練 model 使用 PyTorch 並且我正在使用以下代碼來加載它:

    import torch
    model = torch.hub.load("pytorch/vision", "resnet50", weights="IMAGENET1K_V2")

雖然我升級了 torchvision 但我收到以下錯誤:

任何想法?

根據最新定義,我們現在使用 torchvision 庫加載模型,您可以嘗試使用:

from torchvision.models import resnet50, ResNet50_Weights

# Old weights with accuracy 76.130%
model1 = resnet50(weights=ResNet50_Weights.IMAGENET1K_V1)

# New weights with accuracy 80.858%
model2 = resnet50(weights=ResNet50_Weights.IMAGENET1K_V2)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM