【发布时间】:2020-04-05 06:16:28
【问题描述】:
我遵循与Kearas regression models 教程中显示的完全相同的代码,但无法访问tfdocs.plots.HistoryPlotter() 方法。 (Google Colab 和 TensorFlow 的新手)。其余单元格在训练进度图旁边工作。
触发错误的代码sn-p:
plotter.plot({'Basic': history}, metric = 'mae') plt.ylim([0, 10])
plt.ylabel('MAE [MPG]')
还有错误:
KeyError Traceback (most recent call last)
<ipython-input-25-deee24f0bc59> in <module>()
----> 1 plotter.plot({'Basic': history}, metric = 'mae')
2 plt.ylim([0, 10])
3 plt.ylabel('MAE [MPG]')
/usr/local/lib/python3.6/dist-packages/tensorflow_docs/plots/__init__.py in plot(self, histories, metric, smoothing_std)
86 self.color_table[name] = color
87
---> 88 train_value = history.history[metric]
89 val_value = history.history['val_' + metric]
90 if smoothing_std is not None:
KeyError: 'mae'
并且还从 tensorflow_docs 导入必要的函数(如教程页面所示),没有任何错误:
!pip install -q git+https://github.com/tensorflow/docs
非常感谢任何帮助!
【问题讨论】:
-
我相信 'mae' 不包含在历史记录中,您是否按照文档的建议正确初始化了变量?
-
谢谢。 @tharina11 建议解决了这个问题。
标签: python tensorflow keras google-colaboratory