绘制训练损失和训练精度曲线

from keras import models
from keras import layers
model = models.Sequential()
model.add(layers.Dense(26,activation='relu',input_shape=(38,)))
model.add(layers.Dense(26,activation='relu'))
model.add(layers.Dense(1))
model.compile(optimizer='rmsprop',loss='mse',metrics=['mse'])

history = model.fit(train_x, labels_x, epochs=20, batch_size=32, validation_data=(train_y, labels_y))
loss = history.history['loss']
val_loss = history.history['val_loss']
import matplotlib.pyplot as plt
epochs = range(1, len(loss)+1)
plt.plot(epochs, loss, label='Training loss')
plt.plot(epochs, val_loss, label='Validation loss')
plt.title('Training and validation loss')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.show()

 

你可能感兴趣的:(Keras深度学习笔记)