python 在非Eager Execution模式下,可以使用make_one_shot_iterator()迭代数据集
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 在非Eager Execution模式下,可以使用make_one_shot_iterator()迭代数据集相关的知识,希望对你有一定的参考价值。
import numpy as np
import tensorflow as tf
data_np = np.random.randint(0, 100, (100, 5))
dataset = tf.data.Dataset.from_tensor_slices((data_np)).shuffle(100).batch(20)
iterator = dataset.make_one_shot_iterator()
next_batch = iterator.get_next()
sess = tf.Session()
while True:
try:
print(sess.run(next_batch))
except tf.errors.OutOfRangeError:
break
以上是关于python 在非Eager Execution模式下,可以使用make_one_shot_iterator()迭代数据集的主要内容,如果未能解决你的问题,请参考以下文章