質問内容
Python初学者です。
ゼロから作るDeepLearnig(P73)で現在勉強をしているのですが、HTTP Error 403: Forbiddenというエラーが発生して前に進めない状況です。
HTTP Error 403: Forbiddenがウェブサイトが閲覧禁止になっている状態というところまでは理解しました。
dataset.mnist内にあるURLにアクセスが出来ないために、データを取得できないという解釈でよろしいでしょうか。
また、解決方法がございましたら、お手数おかけいたしますがご教授頂ければ幸いです。
dataset/mnist.py内にあるURL
http://yann.lecun.com/exdb/mnist/
入力コード
import sys, os
sys.path.append(os.pardir)
from dataset.mnist import load_mnist
(x_train, t_train), (x_test, t_test) = load_mnist(flatten = True, normalize = False)
発生している問題・エラーメッセージ
HTTPError Traceback (most recent call last)
<ipython-input-4-a1f33dcdd7aa> in <module>
----> 1 (x_train, t_train), (x_test, t_test) = load_mnist(flatten = True, normalize = False)
~/Desktop/deep-learning-from-scratch-master/dataset/mnist.py in load_mnist(normalize, flatten, one_hot_label)
104 """
105 if not os.path.exists(save_file):
--> 106 init_mnist()
107
108 with open(save_file, 'rb') as f:
~/Desktop/deep-learning-from-scratch-master/dataset/mnist.py in init_mnist()
73
74 def init_mnist():
---> 75 download_mnist()
76 dataset = _convert_numpy()
77 print("Creating pickle file ...")
~/Desktop/deep-learning-from-scratch-master/dataset/mnist.py in download_mnist()
40 def download_mnist():
41 for v in key_file.values():
---> 42 _download(v)
43
44 def _load_label(file_name):
~/Desktop/deep-learning-from-scratch-master/dataset/mnist.py in _download(file_name)
35
36 print("Downloading " + file_name + " ... ")
---> 37 urllib.request.urlretrieve(url_base + file_name, file_path)
38 print("Done")
39
/opt/anaconda3/lib/python3.8/urllib/request.py in urlretrieve(url, filename, reporthook, data)
245 url_type, path = _splittype(url)
246
--> 247 with contextlib.closing(urlopen(url, data)) as fp:
248 headers = fp.info()
249
/opt/anaconda3/lib/python3.8/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
224 def install_opener(opener):
/opt/anaconda3/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout)
529 for processor in self.process_response.get(protocol, []):
530 meth = getattr(processor, meth_name)
--> 531 response = meth(req, response)
532
533 return response
/opt/anaconda3/lib/python3.8/urllib/request.py in http_response(self, request, response)
638 # request was successfully received, understood, and accepted.
639 if not (200 <= code < 300):
--> 640 response = self.parent.error(
641 'http', request, response, code, msg, hdrs)
642
/opt/anaconda3/lib/python3.8/urllib/request.py in error(self, proto, *args)
567 if http_err:
568 args = (dict, 'default', 'http_error_default') + orig_args
--> 569 return self._call_chain(*args)
570
571 # XXX probably also want an abstract factory that knows when it makes
/opt/anaconda3/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
500 for handler in handlers:
501 func = getattr(handler, meth_name)
--> 502 result = func(*args)
503 if result is not None:
504 return result
/opt/anaconda3/lib/python3.8/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
647 class HTTPDefaultErrorHandler(BaseHandler):
648 def http_error_default(self, req, fp, code, msg, hdrs):
--> 649 raise HTTPError(req.full_url, code, msg, hdrs, fp)
650
651 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 403: Forbidden
補足情報(FW/ツールのバージョンなど)
作業はJupyterLab2.2.6で行っております。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/03/09 09:15