Search code examples
pythontensorflowtensorflow-datasetstfrecord

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


I try to Importing Data

I try to load a tfrecords dataset that I created. But I always get this Error.

Here is the code:

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)

But tf.data... should exist? Thank you


Solution

  • You might be running an older version of tensorflow. Try updating it to 1.4, which has the data API.