TensorBoard 标量图中 "smoothing" 参数背后的数学原理是什么?
What is the mathematics behind the "smoothing" parameter in TensorBoard's scalar graphs?
我认为它是某种移动平均线,但有效范围在 0 到 1 之间。
它被称为exponential moving average,下面是代码解释它是如何创建的。
假设所有 real 标量值都在一个名为 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
这是执行指数平滑的实际源代码片段,并在评论中解释了一些额外的去偏,以补偿零初始值的选择:
last = last * smoothingWeight + (1 - smoothingWeight) * nextVal
我认为它是某种移动平均线,但有效范围在 0 到 1 之间。
它被称为exponential moving average,下面是代码解释它是如何创建的。
假设所有 real 标量值都在一个名为 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
这是执行指数平滑的实际源代码片段,并在评论中解释了一些额外的去偏,以补偿零初始值的选择:
last = last * smoothingWeight + (1 - smoothingWeight) * nextVal