【发布时间】:2020-06-26 06:18:23
【问题描述】:
我从 tesnorboard 下载了 CSV 文件,以便自己绘制损失,因为我希望它们平滑。
这是我目前的代码:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.read_csv('C:\\Users\\ali97\\Desktop\\Project\\Database\\Comparing Outlier Fractions\\10 Percent (MAE)\\MSE Validation.csv',usecols=['Step','Value'],low_memory=True)
df2 = pd.read_csv('C:\\Users\\ali97\\Desktop\\Project\\Database\\Comparing Outlier Fractions\\15 Percent (MAE)\\MSE Validation.csv',usecols=['Step','Value'],low_memory=True)
df3 = pd.read_csv('C:\\Users\\ali97\\Desktop\\Project\\Database\\Comparing Outlier Fractions\\20 Percent (MAE)\\MSE Validation.csv',usecols=['Step','Value'],low_memory=True)
plt.plot(df['Step'],df['Value'] , 'r',label='10% Outlier Frac.' )
plt.plot(df2['Step'],df2['Value'] , 'g',label='15% Outlier Frac.' )
plt.plot(df3['Step'],df3['Value'] , 'b',label='20% Outlier Frac.' )
plt.xlabel('Epochs')
plt.ylabel('Validation score')
plt.show()
我正在阅读如何平滑图形,我发现这里的另一个成员编写了关于 tensorboard 如何实际平滑图形的代码,但我真的不知道如何在我的代码中实现它。
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
谢谢。
【问题讨论】:
标签: python tensorflow tensorboard