KEMBAR78
Bug Fix: Update Histogram YAxis Values to match those shown in the chart by rileyajones · Pull Request #5925 · tensorflow/tensorboard · GitHub
Skip to content

Conversation

@rileyajones
Copy link
Contributor

@rileyajones rileyajones commented Sep 13, 2022

  • Motivation for features / changes
    There is a bug where the lines on the histogram chart do not align with the ticks in the YAxis. This because of some fault logic around the maximum number ticks to be shown there. The issue will occur when the number of lines (steps) is fewer than the height of the chart / 15 (a seemingly arbitrary value).

  • Technical description of changes
    I updated the logic surrounding the number of ticks to be shown so that the number of ticks <= number steps.

  • Screenshots of UI changes
    Before
    image
    image

After
image
image

  • Detailed steps to verify changes work correctly (as executed by you)
  1. Start tensorboard with a log directory containing histogram data. Below is some python code. which should generate valid logs.
  2. Navigate to localhost:6006?enableDataTable&enableLinkedTime
  3. Note that the histogram chart has the same number of YAxis ticks as lines on the chart.
  4. Enable linked time and set a value for the upper value to enable range selection.
    Screen Shot 2022-09-13 at 4 36 40 PM
  5. Note that the upper fob is placed correctly on the chart.
# https://www.tensorflow.org/tensorboard/get_started
import tensorflow as tf
import datetime
mnist = tf.keras.datasets.mnist

(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

def create_model():
  return tf.keras.models.Sequential([
    tf.keras.layers.Flatten(input_shape=(28, 28)),
    tf.keras.layers.Dense(512, activation='relu'),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(10, activation='softmax')
  ])

model = create_model()
model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

log_dir = "logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)

model.fit(x=x_train, 
          y=y_train, 
          epochs=5, 
          validation_data=(x_test, y_test), 
          callbacks=[tensorboard_callback])

  • Alternate designs / implementations considered

@rileyajones rileyajones marked this pull request as ready for review September 13, 2022 23:28
@rileyajones rileyajones marked this pull request as draft September 14, 2022 18:40
@rileyajones rileyajones marked this pull request as ready for review September 14, 2022 22:40
Copy link
Contributor

@JamesHollyer JamesHollyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fix the issue when the number of steps is less than height/15. In your description you state that the problem only occurs then. However, IIUC the problem actually occurs when the number of steps is not evenly divisible by height/15. At that point I believe it is much less noticeable so maybe we do not care but I think it worth noting. Maybe a follow up PR to fix that issue?

@rileyajones
Copy link
Contributor Author

@JamesHollyer I was wrong about the spacing issue when number of spaces is not evenly divisible, d3 seems to handle this correctly.

@rileyajones rileyajones merged commit eb6943f into tensorflow:master Sep 19, 2022
yatbear pushed a commit to yatbear/tensorboard that referenced this pull request Mar 27, 2023
dna2github pushed a commit to dna2fork/tensorboard that referenced this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants