【发布时间】:2022-07-03 16:43:21
【问题描述】:
我想用指数移动平均线重新绘制一个图表,所以我在下面定义了平滑曲线。
def smooth_curve(points, factor=0.8):
smoothed_points = []
for point in points:
if smoothed_points:
previous = smoothed_points[-1]
smoothed_points.append(previous * factor + point * (1 - factor))
else:
smoothed_points.append(point)
return
我尝试使用matplotlib.pyplot as plt 进行绘图
plt.plot(epochs, smooth_curve(acc), 'bo', label='smoothed training acc')
但是我得到了下面的错误。
plt.plot(epochs, smooth_curve(acc), 'bo', label='smoothed training acc')
Traceback (most recent call last):
Input In [119] in <cell line: 1>
plt.plot(epochs, smooth_curve(acc), 'bo', label='smoothed training acc')
File C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py:2757 in plot
return gca().plot(
File C:\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py:1632 in plot
lines = [*self._get_lines(*args, data=data, **kwargs)]
File C:\Anaconda3\lib\site-packages\matplotlib\axes\_base.py:312 in __call__
yield from self._plot_args(this, kwargs)
File C:\Anaconda3\lib\site-packages\matplotlib\axes\_base.py:459 in _plot_args
raise ValueError("x, y, and format string must not be None")
ValueError: x, y, and format string must not be None
我检查了smooth_curve(acc)编译成功。
【问题讨论】:
标签: python matplotlib keras