Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在tensorflow中逐行读取文本时的无限循环_Python_Tensorflow_For Loop - Fatal编程技术网

Python 在tensorflow中逐行读取文本时的无限循环

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>)

我试图从教程中的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>)
(<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,它可以正常工作。

这是因为列表中没有删除已执行的操作吗?所以这个名单永远不会缩小?请你再清楚一点好吗?