gpt4 book ai didi

python - 来自 tensorflow /模型的警告 : Please use alternatives such as official/mnist/dataset. py

转载 作者:IT老高 更新时间:2023-10-28 21:18:11 29 4
gpt4 key购买 nike

我正在使用 Tensorflow 做一个简单的教程,我刚刚安装了它应该更新它,首先我使用以下代码加载 mnist 数据:

import numpy as np
import os
from tensorflow.examples.tutorials.mnist import input_data
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
train_data = mnist.train.images # Returns np.array
train_labels = np.asarray(mnist.train.labels, dtype=np.int32)
eval_data = mnist.test.images # Returns np.array
eval_labels = np.asarray(mnist.test.labels, dtype=np.int32)

但是当我运行它时,我收到以下警告:

WARNING:tensorflow:From C:\Users\user\PycharmProjects\TensorFlowRNN\venv\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use the retry module or similar alternatives.
WARNING:tensorflow:From C:/Users/user/PycharmProjects/TensorFlowRNN/sample.py:5: 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 C:\Users\user\PycharmProjects\TensorFlowRNN\venv\lib\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.
WARNING:tensorflow:From C:\Users\user\PycharmProjects\TensorFlowRNN\venv\lib\site-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 MNIST_data/train-images-idx3-ubyte.gz
WARNING:tensorflow:From C:\Users\user\PycharmProjects\TensorFlowRNN\venv\lib\site-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 MNIST_data/train-labels-idx1-ubyte.gz
WARNING:tensorflow:From C:\Users\user\PycharmProjects\TensorFlowRNN\venv\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:110: dense_to_one_hot (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.one_hot on tensors.
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
WARNING:tensorflow:From C:\Users\user\PycharmProjects\TensorFlowRNN\venv\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:290: DataSet.__init__ (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.

我使用了 os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 这行应该避免收到警告并尝试了其他替代方法来获得 mnist,但是总是出现相同的警告,有人可以帮忙吗我想知道这是怎么回事吗?

PD:我在 Windows 10 中使用 Python 3.6,以防万一。

最佳答案

tensorflow.examples.tutorials 现已弃用,建议使用 tensorflow.keras.datasets 如下:

import tensorflow as tf
mnist = tf.keras.datasets.mnist
(X_train, y_train), (X_test, y_test) = mnist.load_data()

https://www.tensorflow.org/api_docs/python/tf/keras/datasets/mnist/load_data

关于python - 来自 tensorflow /模型的警告 : Please use alternatives such as official/mnist/dataset. py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49901806/

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