Migrated from https://github.com/tensorflow/tensorflow/issues/7060.
@untom says:
Tensorboard currently (version 0.12.1) has an option to plot graphs with a logarithmic log scale, but this functionality doesn't work well whenever plotting very small values (e.g. the ones that converge to zero, like loss values).
I'll add that very often these are precisely the plots that we're interested in, so I consider this a pretty important issue.
+1. Experiencing the exact same issue. @chihuahua @jart @dandelionmane
Here are a few screenshots to demonstrate. The only thing log scale does here is zoom in slightly.


Just found this: https://github.com/palantir/plottable/issues/3348
Have we tried the scale._pivot = 0 suggestion?
Here's where Plottable uses the _pivot property. https://github.com/palantir/plottable/blob/3a5b401d2f44b299d1c38e5a69554efefef7c77a/src/scales/modifiedLogScale.ts#L70
I'm trying to understand the motivation behind adjusting the log value in that manner. Specifically, why add a value to the log output that ranges from 1 (at x = 0) to 0 (at x = base).
Applying that solution sometimes results in good charts, but sometimes results in completely unviewable ones. See below.
log scale off:

log scale on (bad examples circled):

I think I understand the trade-offs now. log(x) goes to -infinity when x is 0, so the Plottable folks never let that happen by adding a _pivot value (that interpolates between 1 and 0 up to the base, at which log_base(base) = 1) to tiny raw inputs.
Hence, we can't just set _pivot = 0. That won't work because for many cases, charts will look crazy due to extremely negative outputs.
A solution to this issue must be more nuanced. We must multiply the x input values by some value (based on the magnitudes of the x values) before applying log.
I think the main issue with a fully log scale is if you have both positive and negative values in your graph. The thing is that's very rare though, and log scale wouldn't make sense for a graph with positive and negative values anyway.
What if we only enabled log scale on graphs where all of the values were positive? Should be fairly easy to get proper log scale in that case. Even if the Plottable library doesn't work on values less than 1, you can multiply all of the values by some large enough multiplier to get them all above 1 before passing them to Plottable (so if your values are 0.01, 0.02, 0.03, just pass in 1, 2, 3).
I don't see what the problem is with using an actual normal log scale.
Users know whether their data is appropriate to be visualized on a log scale. If the user selects "log scale," then they know that their data is all positive.
If charts "look crazy due to extremely negative outputs," this means that you have data very close to zero. When using a linear scale, the data will look like a perfectly flat line. You get _no information_ out of such a chart. If you use a proper log scale and see extremely negative outputs, then you are learning exactly what you wanted to about your data.
"If you have both positive and negative values in your graph," then you just shouldn't use a log scale. It's not the right tool for the job in that case. On the other hand, this pseudolinear scale that we currently use is _never_ the right tool for the job.
I am very wary of "multiply[ing] the x input values by some value based on their magnitudes" before taking their logarithms. The goal of the chart is not to create a pretty line; it is to display the user's data. Distorting the data is obviously incorrect.
As long as TensorBoard does not _crash_ when the plot has negative values (preferably show NaN-triangles in the graph; alternately show an error or something), it seems clear that _using a log scale when the user asks for a log scale_ is the right way to go.
For a point of reference, open any other application that plots data: Excel, Sheets, gnuplot, pgfplots, octave, matplotlib. I guarantee you that if you select a log scale on _any_ of them, you will get a log scale.
I agree. I don't mean that TensorBoard should display multiplied values to the user, but that it should find some sort of workaround rather than just be incorrect when values are less than 1. Another possibility if I understand the code correctly is to set scale._pivot to the smallest value in your data, which should set it up so that all your data gets displayed correctly as log scale.
It was pointed out that #938 is a duplicate of this older issue. There's some valuable more recent discussion on #938 but we're centralizing on this issue for tracking purposes.
I've marked this contributions welcome, since we are stretched thin in terms of our ability to do new feature work right now. That said, I agree that this should be fixed and we would happily take a PR to replace the ModifiedLog scale with a true log scale as long as it has some reasonable provision for negative values (like the matplotlib style here: https://github.com/tensorflow/tensorboard/issues/938#issuecomment-367865761).
Most helpful comment
I don't see what the problem is with using an actual normal log scale.
Users know whether their data is appropriate to be visualized on a log scale. If the user selects "log scale," then they know that their data is all positive.
If charts "look crazy due to extremely negative outputs," this means that you have data very close to zero. When using a linear scale, the data will look like a perfectly flat line. You get _no information_ out of such a chart. If you use a proper log scale and see extremely negative outputs, then you are learning exactly what you wanted to about your data.
"If you have both positive and negative values in your graph," then you just shouldn't use a log scale. It's not the right tool for the job in that case. On the other hand, this pseudolinear scale that we currently use is _never_ the right tool for the job.
I am very wary of "multiply[ing] the x input values by some value based on their magnitudes" before taking their logarithms. The goal of the chart is not to create a pretty line; it is to display the user's data. Distorting the data is obviously incorrect.
As long as TensorBoard does not _crash_ when the plot has negative values (preferably show NaN-triangles in the graph; alternately show an error or something), it seems clear that _using a log scale when the user asks for a log scale_ is the right way to go.
For a point of reference, open any other application that plots data: Excel, Sheets, gnuplot, pgfplots, octave, matplotlib. I guarantee you that if you select a log scale on _any_ of them, you will get a log scale.