我正在遵循Kearas regression models教程中显示的完全相同的代码,但是无法访问tfdocs.plots.HistoryPlotter()
方法。 (是Google Colab和TensorFlow的新功能)。其余的单元格在训练进度图旁边工作。
触发错误的代码段:
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
非常感谢您的帮助!
答案 0 :(得分:0)
在代码中将“ mae”替换为“ mean_absolute_error”。