我正在尝试通过 Tensorflow 获取 MNIST 数据集,如下所示。
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets("data/MNIST/", one_hot=True)
如标题所示,我在 Anaconda (Linux) 上安装了 Tensorflow,软件包版本为 tensorflow 1.8.0 (引用:https://anaconda.org/anaconda/tensorflow)
但以下是错误消息:
from tensorflow.examples.tutorials.mnist import input_data
ModuleNotFoundError: No module named 'tensorflow.examples'; 'tensorflow' is not a package
是否是因为tensorflow版本太旧而无法下载MNIST?
我还找到了相关问题:Cannot get MNIST database through Anaconda/jupyter 不过这是通过sklearn下载MNIST,Anaconda上可以通过tensorflow下载吗?
最佳答案
上述错误的两个可能原因:
- 您的文件名为 tensorflow.py,正如 xdurch0 所指出的
- 同一目录中还有另一个 python 文件,名为 tensorflow.py。如果存在,只需将其删除即可。
关于python - 无法在 Anaconda 上通过 Tensorflow 获取 MNIST 数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51340100/