read_data_sets已被弃用,将在未来版本中移除。更新指南如下:

4
这是我的代码。
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot = True)

当我运行它时,我收到以下警告,我正在使用在线环境Google Colab来运行它。

WARNING:tensorflow:From <ipython-input-2-0d6f173b16c0>:6: 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.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist- 
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.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist- 
packages/tensorflow/contrib/learn/python/learn/datasets/base.py:252: 
_internal_retry.<locals>.wrap.<locals>.wrapped_fn (from 
tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will 
be removed in a future version.
Instructions for updating:
Please use urllib or similar directly.
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist- 
packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:262: 
extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is 
deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist- 
packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:267: 
extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is 
deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-labels-idx1-ubyte.gz

任何帮助都将不胜感激。


问题到底是什么?它包括更新您的代码的说明。 - C.Nivs
它字面上说:“请使用tf.data来实现此功能。” - Rushabh Mehta
请查看以下问题的答案:https://stackoverflow.com/questions/51480927/how-to-download-mnist-in-tensorflow-v1-9 - Chapin
2个回答

0

现在推荐的方法似乎是使用keras:

from tensorflow import keras


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

-2
请使用以下代码
import tensorflow as tf
#Sets the threshold for what messages will be logged.
old_v = tf.logging.get_verbosity()
# able to set the logging verbosity to either DEBUG, INFO, WARN, ERROR, or FATAL. Here its ERROR
tf.logging.set_verbosity(tf.logging.ERROR)
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot = True)
#in the end
tf.logging.set_verbosity(old_v)

2
通常而言,解释一个解决方案而不仅仅是发布一些匿名代码行更好。您可以阅读《如何撰写高质量答案》和《解释完全基于代码的答案》。 - Anh Pham
4
你是认真的吗?!你真的认为隐藏警告是最好的解决方案吗?!哦天啊... - slawiko
1
通常警告信息都是有原因存在的!不要仅仅将其隐藏起来! - Chapin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接