summary作用:在tensorboard中直观展示训练信息。
# 初始化summaries
summaries = set(tf.get_collection(tf.GraphKeys.SUMMARIES))
# 添加summary
summaries.add(tf.summary.scalar('learning_rate', learning_rate))
# merge所有summary
tf.summary.merge_all(key=_ops.GraphKeys.SUMMARIES, scope=None, name=None)
tensorflow中有以下几种展示方式:
1、显示标量信息
tf.summary.scalar(name, tensor, collections=None, family=None)
2、显示直方图信息
tf.summary.histogram(name, values, collections=None, family=None)
3、显示图像信息
tf.summary.image(name, tensor, max_outputs=3, collections=None, family=None)
4、显示音频信息
tf.summary.audio(name, tensor, sample_rate, max_outputs=3, collections=None,family=None)
5、显示文本信息
tf.summary.text(name, tensor, collections=None)
6、多维标量显示
tf.summary.tensor_summary(name,tensor,summary_description=None,collections=None,summary_metadata=None,
family=None,display_name=None)
7、合并summarys
tf.summary.merge(inputs, collections=None, name=None)
需要用到 tf.get_collections() 函数收集参数信息。
使用案例:merge_summary = tf.summary.merge([tf.get_collection(tf.GraphKeys.SUMMARIES,'accuracy'),...(其他信息)])
8、merge所有summarys信息
tf.summary.merge_all(key=_ops.GraphKeys.SUMMARIES, scope=None, name=None)