1前提・実現したいこと
『ゼロから作るDeep Learning』でのMNISTデータセットのダウンロードをしたいです。
エラーが出てしまい、うまくダウンロードできないので解決策を教えていただきたいです。
2発生している問題・エラーメッセージ
問題…参考書以外に、qiitaの記事などでもmnistのダウンロードを試みましたが、"load_mnist"の部分でエラーになることが多いです。どこを直せばいいのでしょうか?(友人は同様にコードを実行し、特に問題がなかったため、ファイルの保存方法などに問題がある可能性もあると考えています。)
エラーメッセージ…
NameError Traceback (most recent call last)
<ipython-input-5-a1439d36bcb1> in <module>
14
15 #それぞれのデータの形状を出力
---> 16 print(x_train.shape)
17 print(y_train.shape)
18 print(x_test.shape)
NameError: name 'x_train' is not defined
3該当のソースコード
python
1# coding: utf-8 2import sys, os 3#sys.path.append(os.pardir)# 親ディレクトリのファイルをインポートするための設定 4sys.path.append('C:/Users/souta/Downloads/deep-learning-from-scratch-master/deep-learning-from-scratch-master') 5import numpy as np 6import pickle 7from dataset.mnist import load_mnist 8from common.functions import sigmoid, softmax 9def get_data(): 10 (x_train, t_train), (x_test, t_test) = load_mnist(normalize=True, flatten=True, one_hot_label=False) 11 return x_test, t_test 12#それぞれのデータの形状を出力 13print(x_train.shape) 14print(y_train.shape) 15print(x_test.shape) 16print(y_test.shape)
4自分で調べたことや試したこと
他のサイトや、http://yann.lecun.com/exdb/mnist/などからもダウンロードを試みましたが、ダウンロードしたのちに画像の表示などで問題が発生してしまうことが多いです。
5使っているツールのバージョンなど補足情報
Jupyter Notebookを使っています。
一応Google Colaboratoryも使いましたが、同様のエラーが出ました。
最新版だと思います。
回答1件
あなたの回答
tips
プレビュー