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

时间:2016-12-27 22:30:17

标签: 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)

我在上面AttributeError: 'DataSet' object has no attribute 'image'

指定的行中收到此错误

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:4)

MNIST DataSet对象(已实施here)没有image属性,但确实有an images property。以下更改应解决问题:

data = mnist.train.images