如何在tensorFlow v1.9中下载mnist

时间:2018-07-23 14:14:50

标签: python tensorflow

我正在关注一个tensorFlow教程。 我已经在python 3.6中安装了tensorflow r1.9

我有休闲的进口:

from tensorflow.examples.tutorials.mnist import input_data

我以休闲方式使用它:

mnist = input_data.read_data_sets("mnist_data/", one_hot=True)

我得到了休闲警告/错误:

read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating: Please use alternatives such as official/mnist/dataset.py from tensorflow/models.

python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version. 

Instructions for updating:
Please write your own downloading logic.

在r1.9中使用mnist的正确方法是什么?

1 个答案:

答案 0 :(得分:5)

现在最好的方法是在tensorflow中使用keras模块:

from tensorflow import keras

mnist = tf.keras.datasets.mnist
(train_images, train_labels),(test_images, test_labels) = mnist.load_data()