# save model
model_json=model.to_json()open('cifar10_architecture.json','w').write(model_json)model.save_weights('cifar10_weights.h5',overwrite=True)# load model
model_architecture='cifar10_architecture.json'model_weights='cifar10_weights.h5'model=model_from_json(open(model_architecture).read())model.load_weights(model_weights)
history=model.fit(X_train,y_train,batch_size=BATCH_SIZE,epochs=NB_EPOCH,verbose=VERBOSE,validation_split=VALIDATION_SPLIT)score=model.evaluate(X_test,y_test,verbose=VERBOSE)print("\nTest score:",score[0])print('Test accuracy:',score[1])# list all data in history
print(history.history.keys())# summarize history for accuracy
plt.plot(history.history['acc'])plt.plot(history.history['val_acc'])plt.title('model accuracy')plt.ylabel('accuracy')plt.xlabel('epoch')plt.legend(['train','test'],loc='upper left')plt.show()# summarize history for loss
plt.plot(history.history['loss'])plt.plot(history.history['val_loss'])plt.title('model loss')plt.ylabel('loss')plt.xlabel('epoch')plt.legend(['train','test'],loc='upper left')plt.show()