I have done something similar on my example. Let define three nodes with summaries and merge them into one summary node:
_, accuracy = tf.metrics.accuracy(labels, logits)
_, precision = tf.metrics.precision(labels, logits)
_, recall = tf.metrics.recall(labels, logits)
acc_sum = tf.summary.scalar('accuracy', accuracy)
pred_sum = tf.summary.scalar('precision', precision)
rec_sum = tf.summary.scalar('recall', recall)
summary_acc_op = tf.summary.merge([acc_sum, pred_sum, rec_sum])
Then run it within the session:
summ_str = sess.run(summary_acc_op, feed_dict=feed_dict)
I saved it to a binary file and tried to find out its structure. The function below construct the dictionary of summaries names and values:
def summaryStringToDict(self, summ_str):
idx = 0
ret_dict = {}
while idx < len(summ_str):
item_len = struct.unpack('B', summ_str[idx+1])[0]
name_len = struct.unpack('B', summ_str[idx+3])[0]
name = summ_str[idx+4:idx+4+name_len]
value = struct.unpack('<f', summ_str[idx+5+name_len:idx+9+name_len])[0]
ret_dict[name] = value
idx += item_len + 2
return ret_dict
This should work for any summary containing floats. The'<f'
is for little-endian float decoding. My example output from the function above is:
{"accuracy_1": 0.734375, "precision_1": 1.0, "recall_1": 0.291666656733}
I hope that the similar structure is used for more advanced summaries.