Tensorflow AttributeError:'DataSet'对象没有属性'image'

Mat*_*t D 3 python tensorflow

我正在尝试第一次使用Tensorflow

这是我从教程中获得的代码:

import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
learn = tf.contrib.learn
tf.logging.set_verbosity(tf.logging.ERROR)

mnist = learn.datasets.load_dataset('mnist')
data = mnist.train.image //THIS IS WHERE THE ERROR OCCURS
labels = np.asarray(mnist.train.labels, dtype=np.int32)
test_data = mnist.test.images
test_labels = np.asarray(mnist.test.labels, dtype = np.int32)
Run Code Online (Sandbox Code Playgroud)

我在上面指定的行收到此错误 AttributeError: 'DataSet' object has no attribute 'image'

我该如何解决?

mrr*_*rry 6

该MNIST DataSet对象(实现此处)不具有image产权,但它确实有一个images属性。以下更改应可解决问题:

data = mnist.train.images
Run Code Online (Sandbox Code Playgroud)