2017-02-24 177 views
0
import tensorflow as tf 
import tensorflow.examples.tutorials.mnist.input_data as input_data 
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) 

我剛開始使用tensorflow,當我嘗試導入mnist數據集時,出現以下錯誤。在tensorflow中獲取mnist導入錯誤

Traceback (most recent call last): 
    File "tensorflow.py", line 1, in <module> 
    import tensorflow as tf 
    File "/home/shivam/study/deep learning/tensorflow.py", line 2, in <module> 
    import tensorflow.examples.tutorials.mnist.input_data as input_data 
ImportError: No module named examples.tutorials.mnist.input_data 

我已經檢查了蟒路徑並確認該數據集MNIST在Python路徑(/usr/local/lib/python2.7/dist-packages)中的一個存在。

['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages'] 

我甚至嘗試過這種方法,建議here但我又得到一個導入錯誤。

Traceback (most recent call last): 
    File "tensorflow.py", line 1, in <module> 
    import tensorflow as tf 
    File "/home/shivam/study/deep learning/tensorflow.py", line 2, in <module> 
    import input_data 
    File "/home/shivam/study/deep learning/input_data.py", line 29, in <module> 
    from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets 
ImportError: No module named contrib.learn.python.learn.datasets.mnist 

回答

3

不要打電話給你的文件tensorflow.py,稱之爲別的。例如my_experiment1.py。這應該解決它!