Python 在tensorflow中逐行读取文本时的无限循环
我试图从教程中的tensorflow生成的数据集中读取5行,但是我被堆积在一个无限循环中 这是读取数据集的for循环Python 在tensorflow中逐行读取文本时的无限循环,python,tensorflow,for-loop,Python,Tensorflow,For Loop,我试图从教程中的tensorflow生成的数据集中读取5行,但是我被堆积在一个无限循环中 这是读取数据集的for循环 for ex in all_labeled_data.take(5): print(ex) 这是无限重复的结果: (<tf.Tensor 'IteratorGetNext_1:0' shape=() dtype=string>, <tf.Tensor 'IteratorGetNext_1:1' shape=() dtype=int64>)
for ex in all_labeled_data.take(5):
print(ex)
这是无限重复的结果:
(<tf.Tensor 'IteratorGetNext_1:0' shape=() dtype=string>, <tf.Tensor 'IteratorGetNext_1:1' shape=() dtype=int64>)
(<tf.Tensor 'IteratorGetNext_2:0' shape=() dtype=string>, <tf.Tensor 'IteratorGetNext_2:1' shape=() dtype=int64>)
(<tf.Tensor 'IteratorGetNext_3:0' shape=() dtype=string>, <tf.Tensor 'IteratorGetNext_3:1' shape=() dtype=int64>)
....
(<tf.Tensor 'IteratorGetNext_3:0' shape=() dtype=string>, <tf.Tensor 'IteratorGetNext_3:1' shape=() dtype=int64>)
(,)
(, )
(, )
....
(, )
你能告诉我怎么了吗?我使用的是Tensorflow版本1.14.0
感谢使用最新版本的Tensorflow v2.0,它可以正常工作。这是因为列表中没有删除已执行的操作吗?所以这个名单永远不会缩小?请你再清楚一点好吗?