From 12791c3481a121dca1a624d8878ea18e3058e061 Mon Sep 17 00:00:00 2001 From: Pascal Laube Date: Tue, 12 Jun 2018 10:50:02 +0200 Subject: [PATCH] Added add_text_dict() function to Summarywriter which is able to print dictionaries as a text block. --- tensorboardX/writer.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tensorboardX/writer.py b/tensorboardX/writer.py index 4b959a9d..bf2ef7af 100644 --- a/tensorboardX/writer.py +++ b/tensorboardX/writer.py @@ -408,6 +408,25 @@ def add_text(self, tag, text_string, global_step=None): """ self.file_writer.add_summary(text(tag, text_string), global_step) + def add_text_dict(self, tag, d, global_step=None): + """Add dictionary as text to summary. + + Args: + tag (string): Data identifier + d (dictionary): Key value pairs to print + global_step (int): Global step value to record + + Examples:: + + writer.add_text('parameters', params, 0) + """ + + text_string = "" + for key, value in d.items(): + text_string += "\t" + str(key) + ": " + str(value) + "\n" + + self.file_writer.add_summary(text(tag, text_string), global_step) + def add_graph_onnx(self, prototxt): self.file_writer.add_graph_onnx(gg(prototxt))