我已經(jīng)從 yann.lecun.com 下載了 MNIST 訓練圖像和標簽并解壓了它們。我正在嘗試使用此代碼加載它們-from mlxtend.data import loadlocal_mnistfeatures,labels = loadlocal_mnist( images_path='/python/mnist-files/train-images-idx3-ubyte', labels_path='/python/mnist-files/train-labels-idx1-ubyte')但是,我收到此錯誤 -Traceback (most recent call last): File "generateClassifier.py", line 12, in <module> labels_path='/python/mnist-files/train-labels-idx1-ubyte') File "/home/inglorion/.local/lib/python3.6/site- packages/mlxtend/data/local_mnist.py", line 36, in loadlocal_mnist with open(labels_path, 'rb') as lbpath:FileNotFoundError: [Errno 2] No such file or directory: '/python/mnist- files/train-labels-idx1-ubyte'該目錄確實存在,并且文件名是正確的。我怎樣才能解決這個問題?編輯:我試著用同樣的python-mnist套餐-from mnist import MNISTmndata = MNIST('/python/mnist-files')features,labels = mndata.load_training()我遇到了類似的錯誤-Traceback (most recent call last): File "generateClassifier.py", line 11, in <module> features,labels = mndata.load_training() File "/home/inglorion/.local/lib/python3.6/site-packages/mnist/loader.py", line 126, in load_training os.path.join(self.path, self.train_lbl_fname)) File "/home/inglorion/.local/lib/python3.6/site-packages/mnist/loader.py", line 247, in load with self.opener(path_lbl, 'rb') as file: File "/home/inglorion/.local/lib/python3.6/site-packages/mnist/loader.py", line 239, in opener return open(path_fn, *args, **kwargs)FileNotFoundError: [Errno 2] No such file or directory: '/python/mnist- files/train-labels-idx1-ubyte'錯誤似乎只與訓練標簽文件有關;我嘗試重新下載該文件,但這并沒有解決它。編輯 2:根據(jù)要求,這里是輸出ls -l /python/mnist-files-total 46156-rw-r--r-- 1 inglorion inglorion 47040016 Jul 21 2000 train-images-idx3- ubyte-rw-r--r-- 1 inglorion inglorion 60008 Jul 21 2000 train-labels-idx1- ubyte-rw-r--r-- 1 inglorion inglorion 147970 Feb 8 22:43 wget-log-rw-r--r-- 1 inglorion inglorion 682 Feb 9 14:40 wget-log.1
3 回答

蝴蝶不菲
TA貢獻1810條經(jīng)驗 獲得超4個贊
對我來說,它有助于將文件重命名為train-images.idx3-ubyte
而不是train-images-idx3-ubyte
(-
之后images
更改為 a .
)。

UYOU
TA貢獻1878條經(jīng)驗 獲得超4個贊
a /和~之間有區(qū)別。默認情況下,
os.dir('/')
將在'/'. 我猜你的文件 python 就在'~'你的主目錄中。
你可以試試這個:
from os.path import expanduser
home = expanduser("~")+'/python/mnist-files'
mndata = MNIST(home)
features,labels = mndata.load_training()
如果有幫助,請告訴我。

慕娘9325324
TA貢獻1783條經(jīng)驗 獲得超4個贊
您可以嘗試使用此代碼。
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
我已經(jīng)執(zhí)行了代碼,它工作正常!!希望你會發(fā)現(xiàn)它有幫助。
添加回答
舉報
0/150
提交
取消