没有名为examples.tutorial . mist的模块



我首先开始使用tensorflow,我正在阅读初学者教程。

在窗口,所以我使用Oracle VM VirtualBox,我安装pip virtualenv通过https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#virtualenv-installation

,我通过编译"import tensorflow by tf"检查了tensorflow工作良好,没有错误。

但是,在教程中,我有错误的教程代码

没有名为examples.tutorials的模块。mnist,

at " from tensorflow.examples.tutorials.mnist import input_data ".

我不知道为什么会有这样的错误…这不是下载MNIST数据的代码吗?

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
import tensorflow as tf
x = tf.placeholder(tf.float32, [None, 784])
W = tf.Variable(tf.zeros([784,10])) # weight
b = tf.Variable(tf.zeros([10])) # bias
y = tf.nn.softmax(tf.matmul(x, W) + b)

我也有同样的问题,但我是在Windows上天真地运行它(Tensor Flow for Windows于2016年11月发布)。对我来说,问题是我试图使用错误的Python版本来运行它。

我已经安装了Python v3.5张量流除了Python 2.7(用于其他工作)使用pylauncer。在windows上运行Tensor Flow需要Python 3.5。我的默认设置是Python 2.7,所以当我试图运行它时,我会得到由于使用错误的Python版本运行它而导致的错误。为了强制它使用Python 3,我运行命令py -3 tf_tutorial.py而不是python tf_tutorial.py

不确定这是否对你有帮助。但是希望有这个问题的人能发现这个有用。

最新更新