[FIXED] Calling TensorFlow's Dataset.from_generator method


The TensorFlow 1.4 documentation provides code that demonstrates the usage of Dataset.from_generator. When I run the code, I get an InvalidArgumentError:0-th value returned by pyfunc_0 is int32, but expects int64.

I’m using Python 3.6.1. Here’s the code:

def gen():
    for i in itertools.count(1):
    yield (i, [1] * i)

ds = tf.data.Dataset.from_generator(gen, (tf.int64, tf.int64), 
    (tf.TensorShape([]), tf.TensorShape([None])))
value = ds.make_one_shot_iterator().get_next()

with tf.Session() as sess:
    sess.run(value)  # (1, array([1]))
    sess.run(value)  # (2, array([1, 1]))

Any ideas?


This is a known issue with TensorFlow 1.4.0rc0 when running on Windows. The bug has been fixed in the nightly build of TensorFlow and cherry-picked into the next release candidate of TensorFlow 1.4.0, which is now available.

In the meantime, there are a few options:

  1. Install the nightly build, using pip install tf-nightly. Note that this will contain some features not available in the 1.4 branch, and has not been subject to as much testing as the release branch.

  2. Build the 1.4 branch from source.

  3. Wait for the 1.4.0rc1 release candidate to be published. EDIT: This release is now available from PyPI using pip install tensorflow==1.4.0rc1.

Answered By – mrry

Answer Checked By – Timothy Miller (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published