Skip to content

TF Datasets only working in Eager Execution #233

Description

@mostafaelhoushi

Short description
According to the TF Datasets Overview, "TensorFlow Datasets is compatible with both TensorFlow Eager mode and Graph mode."
However when I tried to run take(1) function on the dataset - while using Graph mode - I get this error:

RuntimeError: dataset.__iter__() is only supported when eager execution is enabled.

Environment information

  • Operating System: -Ubuntu SMP Tue Oct 2 17:16:02 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Python version: 3.5.2
  • tensorflow-datasets/tfds-nightly version: tensorflow-datasets 1.0.1
  • tensorflow/tensorflow-gpu/tf-nightly/tf-nightly-gpu version: tensorflow 1.13.1

Reproduction instructions
The code below is copied and pasted from https://www.tensorflow.org/datasets/overview

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf

import tensorflow_datasets as tfds

mnist_train = tfds.load(name="mnist", split=tfds.Split.TRAIN)
assert isinstance(mnist_train, tf.data.Dataset)
mnist_train

mnist_example, = mnist_train.take(1)
image, label = mnist_example["image"], mnist_example["label"]

plt.imshow(image.numpy()[:, :, 0].astype(np.float32), cmap=plt.get_cmap("gray"))
print("Label: %d" % label.numpy())

Link to logs
If applicable, <link to gist with logs, stack trace>

Expected behavior
I expect to get the results as shown in this tutorial:
https://www.tensorflow.org/datasets/overview

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions