I want to log a few strings with underscores to tensorboard. However, the underscores are treated as emphasis somewhere in the pipeline. Here's some example code to illustrate the problem. I've included a few versions that attempt to escape the underscores
import tensorflow as tf
sess = tf.InteractiveSession()
text0 = """/a/b/c_d/f_g_h_2017"""
text1 = """/a/b/c\_d/f\_g\_h\_2017"""
text2 = """/a/b/c\\_d/f\\_g\\_h\\_2017"""
summary_op0 = tf.summary.text('text', tf.convert_to_tensor(text0))
summary_op1 = tf.summary.text('text', tf.convert_to_tensor(text1))
summary_op2 = tf.summary.text('text', tf.convert_to_tensor(text2))
summary_op = tf.summary.merge([summary_op0, summary_op1, summary_op2])
summary_writer = tf.summary.FileWriter('/tmp/tensorboard', sess.graph)
summary = sess.run(summary_op)
summary_writer.add_summary(summary, 0)
summary_writer.flush()
summary_writer.close()
Here's the output:
How can I use tensorboard to properly render strings with tensorboard? Package versions: Tensorflow 1.3.0, TensorBoard 0.1.8
This is working as intended. The docs for tf.summary.text
and also for tensorboard.summary.text
state that the text will be rendered using Markdown formatting—just like the text in this question and answer—and in Markdown, underscores create italics.
If you don't want this to be the case, you can consider formatting these strings as code, by using either
text0 = """`/a/b/c_d/f_g_h_2017`""" # backticks: inline code formatting
text1 = """ /a/b/c\_d/f\_g\_h\_2017""" # four-space indent: code block
This yields the following result:
(Disclaimer: I work on TensorBoard.)
According to this github issue, this is a bug with the current tensorsorboard and Python 3. For now, using backticks as suggested in another answer is sufficient to render the underscores correctly.
https://github.com/tensorflow/tensorboard/issues/647#issuecomment-337380296
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With