将TFDS数据集转换为tensorflow.examples.tutorials.mnist

时间:2020-01-02 23:00:21

标签: python windows tensorflow mnist

以前我在

上出错

from tensorflow.examples.tutorials.mnist import input_data,因为它不再是tensorflow 2.0的一部分

this帖子中建议我将其替换为

import tensorflow_datasets as tfds
input_data = tfds.load(name="mnist", split=tfds.Split.TRAIN)

但是现在我得到了错误:

Traceback (most recent call last):
  File "GAN.py", line 79, in <module>
    mnist = input_data.read_data_sets('../../MNIST_data', one_hot=True)
AttributeError: '_OptionsDataset' object has no attribute 'read_data_sets'

如何将input_data转换为正确的格式以便能够使用read_data_sets

1 个答案:

答案 0 :(得分:0)

由于TF2.0的库已更改,因此其功能也已更改。因此,read_data_sets不是必需的并且可以运行。input_data已经是由imagelabel的字典组成的数据集。您可以像访问

image, label = input_data["image"], input_data["label"]

阅读here了解更多信息。