我正在使用启用了 Eager 模式的 TF 1.8。
我无法在 mapfunc 中打印示例。当我从 mapfunc 中运行 tf.executing_eagerly() 时,我得到“False”
import os
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
tfe = tf.contrib.eager
tf.enable_eager_execution()
x = tf.random_uniform([16,10], -10, 0, tf.int64)
print(x)
DS = tf.data.Dataset.from_tensor_slices((x))
def mapfunc(ex, con):
import pdb; pdb.set_trace()
new_ex = ex + con
print(new_ex)
return new_ex
DS = DS.map(lambda x: mapfunc(x, [7]))
DS = DS.make_one_shot_iterator()
print(DS.next())
print(new_ex) 输出:
Tensor("add:0", shape=(10,), dtype=int64)
在 mapfunc 之外,它工作正常。但在其中,传递的示例没有值,也没有 .numpy() 属性。