python - Tensorflow 属性错误 : 'DataSet' object has no attribute 'image'

标签 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'

我该如何解决这个问题?

最佳答案

MNIST DataSet 对象(已实现 here )没有 image 属性,但它有 an images property .以下更改应该可以解决问题:

data = mnist.train.images

关于python - Tensorflow 属性错误 : 'DataSet' object has no attribute 'image' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41352991/

相关文章:

python - 测量在 Tensorflow 中将数据从 RAM 移动到 GPU 内存所需的时间

opencv - 如何将边界框导出为.jpg

python - Django ImageField upload_to 路径

python - 使用 python 在已打开的对话框中选择一个文件

python - ImportError : No module named skimage, 已经安装了 scikit-image

python - 未知错误/崩溃 - 带 GPU 的 TensorFlow LSTM(第一个纪元开始后无输出)

python - 使用 Scapy 将 DNS 数据包转换为字符串

Python 井字游戏错误 : TypeError: 'function' object is not subscriptable

python - tf.nn.depthwise_conv2d 太慢了。正常吗?

machine-learning - tensorflow 的逻辑回归不起作用