python学习——绘制loss、acc学习曲线
两种方式1.直接画# model.fit返回acc和loss的日志hist=model.fit(train_data, train_label,batch_size=64,epochs=2,validation_split=0.2,shuffle=True)# verbose = 0 为不在标...
·
两种方式
1.直接画
# model.fit返回acc和loss的日志
hist=model.fit(train_data, train_label,
batch_size=64,
epochs=2,
validation_split=0.2,
shuffle=True)
# verbose = 0 为不在标准输出流输出日志信息,verbose = 1 为输出进度条记录,verbose = 2 为每个epoch输出一行记录
# 创建一个绘图窗口
plt.figure()
acc = hist.history['acc']
val_acc = hist.history['val_acc']
loss = hist.history['loss']
val_loss = hist.history['val_loss']
epochs = range(len(acc))
plt.plot(epochs, acc, 'bo', label='Training acc') # 'bo'为画蓝色圆点,不连线
plt.plot(epochs, val_acc, 'b', label='Validation acc')
plt.title('Training and validation accuracy')
plt.legend() # 绘制图例,默认在右上角
plt.figure()
plt.plot(epochs, loss, 'bo', label='Training loss')
plt.plot(epochs, val_loss, 'b', label='Validation loss')
plt.title('Training and validation loss')
plt.legend()
plt.show()
参考:
方法二:
参考:
更多推荐
所有评论(0)