Display tf.summary.text with underscores in Tensorboard

I want to write a few lines with underscores on a tensor panel. However, underscores are seen as an accent somewhere in the pipeline. Here is sample code to illustrate the problem. I have included several versions that try to avoid underlining

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 conclusion:

enter image description here

How can I use a strain gauge to correctly display strain gauge strings? Package Options: Tensorflow 1.3.0, TensorBoard 0.1.8

+5
source share
2 answers

According to this issue, github is a bug with the current tensor map and Python 3. At the moment, using back measures, as suggested in another answer, is enough to correctly display underscores.

https://github.com/tensorflow/tensorboard/issues/647#issuecomment-337380296

+1
source

It works as intended. The documents for tf.summary.text , as well as for tensorboard.summary.text indicate that the text will be displayed using Markdown formatting - just like the text in this question and answer - and underscores in Markdown create italics.

If you do not want this to be the case, you can consider formatting these lines as code using

 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 gives the following result:

Screenshot of the resulting text dashboard

(Disclaimer: I work for TensorBoard.)

+1
source

Source: https://habr.com/ru/post/1272570/


All Articles