tensorflow AttributeError: 'module' object has no attribute 'data'

tensorflow AttributeError: 'module' object has no attribute 'data'

我尝试Importing Data

我尝试加载我创建的 tfrecords 数据集。但我总是得到这个错误。

代码如下:

import tensorflow as tf

EPOCHS = 10
BATCH_SIZE = 32

train_filename = ['rain.tfrecords']
dataset = tf.data.TFRecordDataset(train_filename)
#dataset = dataset.map(...)
dataset = dataset.repeat(EPOCHS)
dataset = dataset.batch(BATCH_SIZE)

iterator = dataset.make_one_shot_iterator()

next_images, next_labels = iterator.get_next()

loss = tf.add(1,next_labels)

with tf.Session() as sess:
    tf.global_variables_initializer().run()
    for step in xrange(10):
        curr_loss= sess.run(loss)

但是tf.data...应该存在? 谢谢

您可能 运行 旧版本的 tensorflow。尝试将其更新为 1.4,其中包含数据 API.