Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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 tf.summary.image似乎不适用于估计器预测_Python_Tensorflow_Tensorflow Estimator - Fatal编程技术网

Python tf.summary.image似乎不适用于估计器预测

Python tf.summary.image似乎不适用于估计器预测,python,tensorflow,tensorflow-estimator,Python,Tensorflow,Tensorflow Estimator,我想在预测时使用tf.assistant可视化我的输入图像,但似乎tf.summary.image没有保存图像。但它对训练有用 这是我在model_fn中的代码: ... summary_hook = tf.train.SummarySaverHook( save_secs=2, output_dir='summary', scaffold=tf.train.Scaffold(summary_op=tf.summary.merge_all()))

我想在预测时使用tf.assistant可视化我的输入图像,但似乎tf.summary.image没有保存图像。但它对训练有用

这是我在model_fn中的代码:

...
summary_hook = tf.train.SummarySaverHook(
        save_secs=2,
        output_dir='summary',
        scaffold=tf.train.Scaffold(summary_op=tf.summary.merge_all()))
        #summary_op=tf.summary.merge_all())
tf.summary.histogram("logit",logits)
tf.summary.image('feat', feat)
if mode == tf.estimator.ModeKeys.PREDICT:
    return tf.estimator.EstimatorSpec(mode, predictions=preds, prediction_hooks=[summary_hook])
...
这是我的预测代码:

config = tf.estimator.RunConfig(save_summary_steps=0)
estimator = tf.estimator.Estimator(model_fn=model_fn, model_dir='logs', config=config)
preds = estimator.predict(input_fn=eval_input_fn)

使用
tf.train.SummarySaverHook
是否有问题?

我假设您需要在调用
merge\u all
之前放置摘要ops(直方图/图像),以便
merge\u all
实际上有东西要合并

...
tf.summary.histogram("logit",logits)
tf.summary.image('feat', feat)
summary_hook = tf.train.SummarySaverHook(
    save_secs=2,
    output_dir='summary',
    scaffold=tf.train.Scaffold(summary_op=tf.summary.merge_all()))
    #summary_op=tf.summary.merge_all())
if mode == tf.estimator.ModeKeys.PREDICT:
    return tf.estimator.EstimatorSpec(mode, predictions=preds, prediction_hooks=[summary_hook])
...