TensorFlow 1.4文檔提供了演示Dataset.from_generator的用法的代碼。當我運行的代碼,我得到一個InvalidArgumentError:0-th value returned by pyfunc_0 is int32, but expects int64
。調用TensorFlow的Dataset.from_generator方法
我使用Python 3.6.1。這裏的代碼:
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]))
任何想法?