Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解決方法:MNISTデータがHTTP Error 403: Forbiddenで読み込めない #81

Open
matsuda-tkm opened this issue May 11, 2024 · 1 comment

Comments

@matsuda-tkm
Copy link

matsuda-tkm commented May 11, 2024

実行環境

  • OS:macOS Sonoma 14.4.1
  • Python:3.12.3
  • パッケージ管理:Poetry (version 1.8.2)
  • 入っているライブラリ(poetry showの結果)
    • contourpy 1.2.1
    • cycler 0.12.1
    • fonttools 4.51.0
    • kiwisolver 1.4.5
    • matplotlib 3.8.4
    • numpy 1.26.4
    • packaging 24.0
    • pillow 10.3.0
    • pyparsing 3.1.2
    • python-dateutil 2.9.0.post0
    • six 1.16.0

問題の事象

ch03/neuralnet_mnist.pyを実行したところ、以下のようにurllib.error.HTTPError: HTTP Error 403: Forbiddenというエラーが発生し、MNISTデータをダウンロードできない。
また、ブラウザからダウンロード先のリンクへアクセスしても403 Forbiddenとなっている。

Downloading train-images-idx3-ubyte.gz ... 
Traceback (most recent call last):
  File "/Users/takumi/github/deep-learning-from-scratch/ch03/neuralnet_mnist.py", line 35, in <module>
    x, t = get_data()
           ^^^^^^^^^^
  File "/Users/takumi/github/deep-learning-from-scratch/ch03/neuralnet_mnist.py", line 11, in get_data
    (x_train, t_train), (x_test, t_test) = load_mnist(normalize=True, flatten=True, one_hot_label=False)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/takumi/github/deep-learning-from-scratch/ch03/../dataset/mnist.py", line 111, in load_mnist
    init_mnist()
  File "/Users/takumi/github/deep-learning-from-scratch/ch03/../dataset/mnist.py", line 80, in init_mnist
    download_mnist()
  File "/Users/takumi/github/deep-learning-from-scratch/ch03/../dataset/mnist.py", line 47, in download_mnist
    _download(v)
  File "/Users/takumi/github/deep-learning-from-scratch/ch03/../dataset/mnist.py", line 40, in _download
    response = urllib.request.urlopen(request).read()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 630, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

解決方法

url_base = 'http://yann.lecun.com/exdb/mnist/'
  • 変更後
url_base = 'https://storage.googleapis.com/cvdf-datasets/mnist/'

解決にあたって参考にしたもの

@koki0702 お手数おかけしますが修正お願いいたします。

@koki0702
Copy link
Collaborator

本家URLが403になっていたので、ミラーサイトに変更しました。
(PyTorchのコードを参考にしました)

497a4ac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants