Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the mathematics behind the "smoothing" parameter in TensorBoard's scalar graphs?

I presume it is some kind of moving average, but the valid range is between 0 and 1.

like image 616
Willian Mitsuda Avatar asked Feb 16 '17 18:02

Willian Mitsuda


2 Answers

It is called exponential moving average, below is a code explanation how it is created.

Assuming all the real scalar values are in a list called scalars the smoothing is applied as follows:

def smooth(scalars: List[float], weight: float) -> List[float]:  # Weight between 0 and 1
    last = scalars[0]  # First value in the plot (first timestep)
    smoothed = list()
    for point in scalars:
        smoothed_val = last * weight + (1 - weight) * point  # Calculate smoothed value
        smoothed.append(smoothed_val)                        # Save it
        last = smoothed_val                                  # Anchor the last smoothed value

    return smoothed
like image 91
bluesummers Avatar answered Nov 15 '22 07:11

bluesummers


Here is the actual piece of source code that performs that exponential smoothing the with some additional de-biasing explained in the comments to compensate for the choice of the zero initial value:

last = last * smoothingWeight + (1 - smoothingWeight) * nextVal

Source: https://github.com/tensorflow/tensorboard/blob/34877f15153e1a2087316b9952c931807a122aa7/tensorboard/components/vz_line_chart2/line-chart.ts#L714

like image 4
Ben Usman Avatar answered Nov 15 '22 07:11

Ben Usman