TensorBoard标量图中"平滑"参数背后的数学是什么?

Wil*_*uda 14 tensorflow tensorboard

我认为它是某种移动平均线,但有效范围在0到1之间.

blu*_*ers 29

@ drpng的答案指向了正确的解释,但由于链接可能在这里下去,因此使用的平滑函数的Pythonic转换代码.

假设所有真实标量值都在名为scalars平滑的列表中,则应用如下:

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
Run Code Online (Sandbox Code Playgroud)

  • 我希望你能在移动平均线和滑动移动平均线之间做出选择! (2认同)

Ben*_*man 5

这是执行指数平滑的实际源代码,并在注释中解释了一些额外的去偏置,以补偿零初始值的选择:

last = last * smoothingWeight + (1 - smoothingWeight) * nextVal
Run Code Online (Sandbox Code Playgroud)

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