gpt4 book ai didi

python - 没有名为 examples.tutorials.mnist 的模块

转载 作者:太空狗 更新时间:2023-10-29 11:21:30 25 4
gpt4 key购买 nike

我首先开始使用 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 是否正常工作,没有错误。

但是,在教程期间,我在教程代码中出错

no module named examples.tutorials.mnist,

在“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 2.7(用于其他工作)之外,我还使用 pylauncer 安装了用于 Tensor Flow 的 Python v3.5。 .在 Windows 上运行 Tensor Flow 需要 Python 3.5。我默认使用 Python 2.7,因此当我尝试运行它时,会出现错误,这是因为它使用错误版本的 python 运行它。为了强制它使用 Python 3,我运行了命令 py -3 tf_tutorial.py 而不是 python tf_tutorial.py

不确定这是否对您有帮助。但希望有此问题的人觉得这很有用。

关于python - 没有名为 examples.tutorials.mnist 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39809467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com