Smooth data using 1st-order IIR low-pass filter (what tensorflow does). Reference: https://github.com/tensorflow/tensorboard/blob/f801ebf1f9fbfe2baee1ddd65714d0bccc640fb1/tensorboard/plugins/scalar/vz_line_chart/vz-line-chart.ts#L704 # noqa: E501 Args: values (list): A list of va
(values, smooth_weight)
| 66 | |
| 67 | |
| 68 | def smooth_data(values, smooth_weight): |
| 69 | """ Smooth data using 1st-order IIR low-pass filter (what tensorflow does). |
| 70 | |
| 71 | Reference: https://github.com/tensorflow/tensorboard/blob/f801ebf1f9fbfe2baee1ddd65714d0bccc640fb1/tensorboard/plugins/scalar/vz_line_chart/vz-line-chart.ts#L704 # noqa: E501 |
| 72 | |
| 73 | Args: |
| 74 | values (list): A list of values to be smoothed. |
| 75 | smooth_weight (float): Smooth weight. |
| 76 | """ |
| 77 | values_sm = [] |
| 78 | last_sm_value = values[0] |
| 79 | for value in values: |
| 80 | value_sm = last_sm_value * smooth_weight + (1 - smooth_weight) * value |
| 81 | values_sm.append(value_sm) |
| 82 | last_sm_value = value_sm |
| 83 | return values_sm |
nothing calls this directly
no outgoing calls
no test coverage detected