【发布时间】:2020-05-27 13:56:23
【问题描述】:
这是我在 Google Colab 笔记本中加载预训练模型的代码L
# Import resources
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import time
import json
import copy
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import PIL
from PIL import Image
from collections import OrderedDict
import torch
from torch import nn, optim, cuda
from torch.optim import lr_scheduler
from torch.autograd import Variable
import torchvision
from torchvision import datasets, models, transforms
from torch.utils.data.sampler import SubsetRandomSampler
import torch.nn as nn
import torch.nn.functional as F
import os
device = torch.device("cuda" if torch.cuda.is_available()
else "cpu")
print(device)
model = models.resnet152(pretrained=True)
num_in_features = 2048
print(model)
我之前已经成功运行过这条线,但是现在我得到了错误:
Downloading: "https://download.pytorch.org/models/resnet152-b121ed2d.pth" to /root/.cache/torch/checkpoints/resnet152-b121ed2d.pth
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
<ipython-input-13-361fc480b515> in <module>()
----> 1 model = models.resnet152(pretrained=True)
2 num_in_features = 2048
3 print(model)
9 frames
/usr/lib/python3.6/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
648 class HTTPDefaultErrorHandler(BaseHandler):
649 def http_error_default(self, req, fp, code, msg, hdrs):
--> 650 raise HTTPError(req.full_url, code, msg, hdrs, fp)
651
652 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 403: Forbidden
我尝试过以其他各种方式加载模型,启动一个新笔记本,!kill -9 -1
我是 Google Colab 的新手,不确定问题出在哪里!提前致谢
【问题讨论】:
-
请分享一个能够重现问题的独立笔记本。 (HTTP 403 可能是模块包底层托管服务的配置问题。在这种情况下,我猜是 pytorch。)
-
@BobSmith 我更新了我的问题以包含所有代码,直到出现错误和错误消息
-
今天遇到同样的问题,昨天同样的代码还在工作......
标签: pytorch google-colaboratory