Search code examples
tensorboardtensorflow2.0

How to put scalars in the same row in tensorboard in TF2.0?


If I have 3 different scalars in tensorboard and I want to put two of them in the same row, what can I do? The following code produces a tensorboard with 3 different rows. And I want to put the first two in one row and the second in the other.

with summary_writer.as_default():
    tf.summary.scalar("training_loss", loss, step=batch_index)
    tf.summary.scalar("learning_rate", optimizer.learning_rate, step=batch_index)
with summary_writer.as_default():
    tf.summary.scalar("validation_loss", val_loss, step=batch_index)

Solution

  • After asking this question on TensorFlow GitHub, I got the answer. The link is https://github.com/tensorflow/tensorboard/issues/2984.

    Basically, just add the catagory name before the scalar name as:

    with summary_writer.as_default():
        tf.summary.scalar("training/training_loss", loss, step=batch_index)
        tf.summary.scalar("training/learning_rate", optimizer.learning_rate, step=batch_index)
    with summary_writer.as_default():
        tf.summary.scalar("validation/validation_loss", val_loss, step=batch_index)