赞
踩
模型训练完成后,我们需要绘制训练过程中的精度和损失函数变换曲线,这里将训练和验证集的训练曲线绘制封装成一个函数,在模型训练完成后可以直接调用。
import matplotlib.pyplot as plt # define the function def training_plot(model_name): loss = model_name.history['loss'] val_loss = model_name.history['val_loss'] acc = model_name.history['acc'] val_acc = model_name.history['val_acc'] # make a figure fig = plt.figure(figsize=(8,4)) # subplot loss fig1 = fig.add_subplot(121) # 一行两列第一个 fig1.plot(loss,label='train_loss') fig1.plot(val_loss,label='val_loss') fig1.set_xlabel('Epochs') fig1.set_ylabel('Loss') fig1.set_title('Loss on Training and Validation Data') fig1.legend() plt.subplot(211) plt.plot(model_trained.history['acc']) plt.plot(model_trained.history['val_acc']) plt.title('Model Accuracy') plt.ylabel('Accuracy&#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。