Tensorflow Estimator API Save Image Summary In Eval Mode
at the moment I try to train a autoencoder on a custom image dataset using the new Estimator API of Tensorflow. So far everything is working. The only problem I have is to save the
Solution 1:
With TF1.4, you can pass tf.estimator.EstimatorSpec evaluation_hooks. The evaluation_hooks is a list of hooks, and you must add to it the following hook:
# Create a SummarySaverHook
eval_summary_hook = tf.train.SummarySaverHook(
save_steps=1,
output_dir= self.job_dir + "/eval_core",
summary_op=tf.summary.merge_all())
# Add it to the evaluation_hook list
evaluation_hooks.append(eval_summary_hook)
#Now, return the estimator:
return tf.estimator.EstimatorSpec(
mode=mode,
predictions=predictions,
loss=loss,
train_op=train_op,
training_hooks=training_hooks,
eval_metric_ops=eval_metric_ops,
evaluation_hooks=evaluation_hooks)
Now you can simply add tf.summary.image and have it in Tensorboard. Make use you open Tensrobaord on a parent directory of the specified output directory you used in the eval_summary hook. In my example it was called 'eval_core', so I opened Tensorboard on its parent directory, and as you can see in the picture below, it is showing up nicely in a blue box.
Post a Comment for "Tensorflow Estimator API Save Image Summary In Eval Mode"