diff options
author | 2017-01-31 16:39:07 -0800 | |
---|---|---|
committer | 2017-01-31 16:53:38 -0800 | |
commit | 4e080697a51feef4bb42b8837cc83c46f85f3c2b (patch) | |
tree | 0eb29ede29f7bf66158653794571ca46acddb7c5 | |
parent | 2ddb9a0960af173cbc596be8436ec79bc7efb000 (diff) |
TensorBoard: Don't render smoothed lines towards end
Change: 146182705
-rw-r--r-- | tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html | 33 | ||||
-rw-r--r-- | tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts | 13 |
2 files changed, 26 insertions, 20 deletions
diff --git a/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html b/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html index 210aab6c69..0d160795e8 100644 --- a/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html +++ b/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html @@ -148,12 +148,13 @@ such as different X scales (linear and temporal), tooltips and smoothing. * * The smoothing algorithm is a simple moving average, which, given a * point p and a window w, replaces p with a simple average of the - * points in the [p - floor(w/2), p + floor(w/2)] range. - * If there aren't enough points to cover the entire window to the left - * and to the right, the window is reduced to fit exactly the amount of - * elements available. This means that the smoothed line will be less - * smoothed at both extremities and gradually become more smooth until - * the desired window is reached. + * points in the [p - floor(w/2), p + floor(w/2)] range. If there + * aren't enough points to cover the entire window to the left, the + * window is reduced to fit exactly the amount of elements available. + * This means that the smoothed line will be less in and gradually + * become more smooth until the desired window is reached. However when + * there aren't enough points on the right, the line stops being + * rendered at all. */ smoothingEnabled: { type: Boolean, @@ -162,17 +163,17 @@ such as different X scales (linear and temporal), tooltips and smoothing. /** * Weight (between 0.0 and 1.0) of the smoothing. This weight controls - * the window size, and a weight of 1.0 means using the entire length of - * each dataset as the window, while a weight of 0.0 means using a - * window of 0 (and thus replacing each point with themselves). + * the window size, and a weight of 1.0 means using 50% of the entire + * dataset as the window, while a weight of 0.0 means using a window of + * 0 (and thus replacing each point with themselves). * - * The growth between 0.0 and 1.0 is not linear though. Because changing - * the window from 0% to 30% of the dataset smooths the line a lot more - * than changing the window from 70% to 100%, an exponential function is - * used instead. This function increases the size of the window slowly - * at the beginning and gradually speeds up the growth, but 0.0 still - * means a window of 0 and 1.0 still means a window of the dataset's - * length. + * The growth between 0.0 and 1.0 is not linear though. Because + * changing the window from 0% to 30% of the dataset smooths the line a + * lot more than changing the window from 70% to 100%, an exponential + * function is used instead: http://i.imgur.com/bDrhEZU.png. This + * function increases the size of the window slowly at the beginning + * and gradually speeds up the growth, but 0.0 still means a window of + * 0 and 1.0 still means a window of the dataset's length. */ smoothingWeight: { type: Number, diff --git a/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts b/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts index 7bd0507cf9..1be2a8f913 100644 --- a/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts +++ b/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts @@ -442,12 +442,17 @@ module VZ { let kernelRadius = Math.floor(data.length * factor / 2); data.forEach((d, i) => { - let actualKernelRadius = Math.min(kernelRadius, i, data.length - i - 1); + let actualKernelRadius = Math.min(kernelRadius, i); let start = i - actualKernelRadius; let end = i + actualKernelRadius + 1; - - // Only smooth finite numbers. - if (!_.isFinite(d.scalar)) { + if (end >= data.length) { + // In the beginning, it's OK for the smoothing window to be small, + // but this is not desirable towards the end. Rather than shrinking + // the window, or extrapolating data to fill the gap, we're simply + // not going to display the smoothed line towards the end. + d.smoothed = Infinity; + } else if (!_.isFinite(d.scalar)) { + // Only smooth finite numbers. d.smoothed = d.scalar; } else { d.smoothed = d3.mean( |