【发布时间】:2018-07-31 15:26:01
【问题描述】:
我正在使用自定义 Estimator 逻辑重写我的代码,并且我需要启用 Eager Execution 以获得我需要的指标/预测。但是,由于某种原因,似乎没有启用 Eager Execution。为了重现,我可以使用位于https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/learn/iris.py 的示例和一些打印:
...
import tensorflow as tf
tf.enable_eager_execution()
...
def my_model(features, labels, mode):
print("IS EAGER? (my_model) - {}".format(tf.executing_eagerly()))
...
print("IS EAGER? - {}".format(tf.executing_eagerly()))
classifier = tf.estimator.Estimator(model_fn=my_model)
当我运行脚本时,结果如下:
IS EAGER? - True
INFO:tensorflow:Using default config.
...
INFO:tensorflow:Calling model_fn.
IS EAGER? (my_model) - False
INFO:tensorflow:Done calling model_fn.
如何让我的模型快速执行?我正在使用张量流 1.9.0
【问题讨论】:
标签: python tensorflow tensorflow-estimator