2015-12-01 57 views
1

我試圖在Linux上運行tutorial。我安裝了gcc,cython,numpy,sixtensorflow初學者教程 - read_data_sets失敗

我可以導入數據,但似乎有某種問題解壓縮它。

任何人都可以幫忙嗎?


Python 2.7.3 (default, Jun 22 2015, 19:43:34) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import g3doc.tutorials.mnist.input_data as input_data 
>>> mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) 
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes. 
Extracting MNIST_data/train-images-idx3-ubyte.gz 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "g3doc/tutorials/mnist/input_data.py", line 175, in read_data_sets 
    train_images = extract_images(local_file) 
    File "g3doc/tutorials/mnist/input_data.py", line 60, in extract_images 
    buf = bytestream.read(rows * cols * num_images) 
    File "/usr/lib/python2.7/gzip.py", line 263, in read 
    chunk = self.extrabuf[offset: offset + size] 
TypeError: only integer scalar arrays can be converted to a scalar index 
>>> mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) 
Extracting MNIST_data/train-images-idx3-ubyte.gz 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "g3doc/tutorials/mnist/input_data.py", line 175, in read_data_sets 
    train_images = extract_images(local_file) 
    File "g3doc/tutorials/mnist/input_data.py", line 60, in extract_images 
    buf = bytestream.read(rows * cols * num_images) 
    File "/usr/lib/python2.7/gzip.py", line 263, in read 
    chunk = self.extrabuf\[offset: offset + size] 
TypeError: only integer scalar arrays can be converted to a scalar index 

+0

感謝提出這個問題 - 修正現在是上游:https://github.com/tensorflow/tensorflow/commit/a4806a3fba7c00bea3e7022477339b2d09539751 – mrry

+0

另見:[tflearn問題](https://github.com/tflearn/tflearn/issues/584) –

回答

7

這似乎與numpy的最新版本的問題。 A recent change將單元素數組視爲標量用於索引的目的是錯誤的。

我已經做了相關的變化上游TensorFlow代碼,但在此期間,您可以編輯this line in input_data.py(L45)爲以下(在該行的末尾添加[0]):

return numpy.frombuffer(bytestream.read(4), dtype=dt)[0] 
+0

感謝您的關注!但是當我攻擊L60時,我在62行上得到了類似的回溯,然後當我同樣攻擊L62時,我在gzip.py的L263中獲得了回溯。我應該從上游拉回來試試嗎? –

+0

是的 - 我們修正了'_read32()'返回一個int值而不是一個數組,它應該爲你解決問題。再次感謝報告! – mrry

+0

我更新了答案,以顯示正確的修復方法 - 爲後代 - 但從上游拉動可能仍然是要走的路。 – mrry