Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Logarithmic scale" is not actually logarithmic for sub-unit values #57

Closed
wchargin opened this issue Jun 16, 2017 · 9 comments
Closed

Comments

@wchargin
Copy link
Contributor

Migrated from tensorflow/tensorflow#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.

@nealwu
Copy link

nealwu commented Aug 18, 2017

+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.

screenshot from 2017-08-17 17 48 36
screenshot from 2017-08-17 17 48 42

@nealwu
Copy link

nealwu commented Aug 18, 2017

Just found this: palantir/plottable#3348

Have we tried the scale._pivot = 0 suggestion?

@chihuahua
Copy link
Member

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).

@chihuahua
Copy link
Member

Applying that solution sometimes results in good charts, but sometimes results in completely unviewable ones. See below.

log scale off:
no-log-scale

log scale on (bad examples circled):
log-scale

@chihuahua
Copy link
Member

chihuahua commented Aug 23, 2017

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.

@nealwu
Copy link

nealwu commented Aug 23, 2017

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).

@wchargin
Copy link
Contributor Author

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.

@nealwu
Copy link

nealwu commented Aug 24, 2017

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.

@nfelt
Copy link
Contributor

nfelt commented Apr 24, 2018

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: #938 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants