TensorFlow: tf.summary.text and linebreaks
Asked Answered
I

6

8

How do you use tf.summary.text to emit text that contains linebreaks?

I have tried replacing '\n' with <br> but I cannot get the output to show proper linebreaks. Without proper linebreaks makes it very hard to read yaml output as shown here:

enter image description here

Illustrational answered 10/7, 2017 at 15:48 Comment(0)
A
21

Tensorboard text uses the markdown format (though it doesn't support all its features). That means you need to add 2 spaces before \n to produce a linebreak, e.g. line_1 \nline_2 \nline_3

Avie answered 12/10, 2018 at 17:42 Comment(0)
T
2

Use \n\n. It produces too much line break though.

Turbulent answered 28/7, 2017 at 5:53 Comment(0)
C
2

I had been encountering the same issue, so I will answer here what I found ( I put this in the issue as well).

For me I cared specifically about tables and regardless of line break type \n or \r\n ( or double space for that matter) it results in the same line-ending-less output.

| heading | heading | |--- |--- | | key | value | | key | value |

I entirely missed the part about 2d tensors will be rendered as tables but the following does create a table:

tl = [
    ["**key**","**value**"],
    ["key_2","`value_2`"],
    ["key_3","value_3"]
]
tfboard.add_summary(sess.run(tf.summary.text("eh1", tf.convert_to_tensor(tl))))

So it looks like all newlines are just stripped from single strings and if you want consecutive lines, try making a table as a list.

Chondrite answered 30/9, 2017 at 17:57 Comment(0)
T
2

In case you want to dump a pandas DataFrame, use to_markdown().

Thunderstruck answered 8/4, 2020 at 17:5 Comment(0)
C
1

Based on the documentation:

The standard TensorBoard Text Dashboard will render markdown in the strings, and will .....

So you need to provide strings as you would provide them for markdown (<br> and \n do not work in markdown so they do not work here as well).

Cosimo answered 11/7, 2017 at 1:36 Comment(1)
The documentation for Markdown says: When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return. That also does not work.Illustrational
P
0

This looks like a bug on TensorBoard. Please file an issue on our GitHub (https://github.com/tensorflow/tensorboard/issues) with a simple gist that will reproduce it, and we'll figure out what's going on and make sure it's fixed.

Peregrine answered 12/7, 2017 at 4:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.