Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pytorch 错误403:尝试在Google colab中加载预先训练的模型时禁止_Pytorch_Google Colaboratory - Fatal编程技术网

Pytorch 错误403:尝试在Google colab中加载预先训练的模型时禁止

Pytorch 错误403:尝试在Google colab中加载预先训练的模型时禁止,pytorch,google-colaboratory,Pytorch,Google Colaboratory,下面是我在GoogleColab笔记本中加载预先训练好的模型的代码 # 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 im

下面是我在GoogleColab笔记本中加载预先训练好的模型的代码

# 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
下载:https://download.pytorch.org/models/resnet152-b121ed2d.pth“到/root/.cache/torch/checkpoints/resnet152-b121ed2d.pth
---------------------------------------------------------------------------
HTTPError回溯(最近一次调用上次)
在()
---->1模型=模型。resnet152(预训练=真)
2个特征中的数量=2048
3打印(模型)
9帧
/http_error_default(self、req、fp、code、msg、hdrs)中的usr/lib/python3.6/urllib/request.py
648类HTTPDefaultErrorHandler(BaseHandler):
649 def http_错误_默认值(self、req、fp、code、msg、hdrs):
-->650 raise HTTPError(请求完整url、代码、消息、hdrs、fp)
651
652类HTTPRedirectHandler(BaseHandler):
HTTPError:HTTP错误403:禁止
我尝试过以各种其他方式加载模型,启动一个新笔记本,以及
!杀死-9-1


我是Google Colab的新手,不确定这里到底是什么问题!提前感谢

看起来这是很多人的问题,现在已经解决了

请共享一个复制问题的独立笔记本。(HTTP 403可能是模块包下面的托管服务的配置问题。在这种情况下,我猜是pytorch。)@BobSmith我更新了我的问题,以包括所有的代码,直到错误和错误消息今天面临相同的问题时,昨天相同的代码正在工作…这里出现了一个问题: