一个简单的python包来打印keras nn训练历史。
plot-keras-histor的Python项目详细描述
一个python包,用于打印Keras model training history
如何安装此软件包?
像往常一样,只需使用pip:
pip install plot_keras_history
用法
假设您有一个由函数my keras生成的模型:
绘制培训历史
在下面的示例中,我们将了解如何绘制、显示或保存培训历史记录:
fromplot_keras_historyimportplot_historyimportmatplotlib.pyplotaspltmodel=my_keras_model()history=model.fit(...).historyplot_history(history)plt.show()plot_history(history,path="standard.png")plt.close()
绘制成单独的图形
默认情况下,这些图都在一个大图像中,但出于各种原因,您可能需要逐个使用它们:
fromplot_keras_historyimportplot_historyimportmatplotlib.pyplotaspltmodel=my_keras_model()history=model.fit(...).historyplot_history(history,path="singleton",single_graphs=True)plt.close()
用savgol滤波器降低历史噪声
在某些情况下,必须能够看到历史的进展,以便对结果进行插值以消除一点噪声。提供了一个参数来自动应用savgol过滤器:
fromplot_keras_historyimportplot_historyimportmatplotlib.pyplotaspltmodel=my_keras_model()history=model.fit(...).historyplot_history(history,path="interpolated.png",interpolate=True)plt.close()
自动别名
许多指标会自动从默认指标转换为更具说服力的指标,例如“lr”变为“learning rate”,或“acc”变为“accurity”。
所有可用选项
defplot_history(history,# Either the history object or a pandas DataFrame. When using a dataframe, the index name is used as abscissae label.style:str="-",# The style of the lines.interpolate:bool=False,# Wethever to interpolate or not the graphs datapoints.side:float=5,# Dimension of the graphs side.graphs_per_row:int=4,# Number of graphs for each row.customization_callback:Callable=None,# Callback for customizing the graphs.path:str=None,# Path where to store the resulting image or images (in the case of single_graphs)single_graphs:bool=False# Wethever to save the graphs as single of multiples.)
链接历史
停止并重新启动模型的训练是很常见的,这会将history对象分成两部分:因此可以使用方法chain_histories:
fromplot_keras_historyimportchain_historiesmodel=my_keras_model()history1=model.fit(...).historyhistory2=model.fit(...).historyhistory=chain_histories(history1,history2)