Keras - Plot training, validation and test set accuracy

前端 未结 4 1687
萌比男神i
萌比男神i 2020-12-07 22:36

I want to plot the output of this simple neural network:

model.compile(loss=\'binary_crossentropy\', optimizer=\'adam\', metrics=[\'accuracy\'])
history = m         


        
4条回答
  •  孤城傲影
    2020-12-07 23:36

    import keras
    from matplotlib import pyplot as plt
    history = model1.fit(train_x, train_y,validation_split = 0.1, epochs=50, batch_size=4)
    plt.plot(history.history['acc'])
    plt.plot(history.history['val_acc'])
    plt.title('model accuracy')
    plt.ylabel('accuracy')
    plt.xlabel('epoch')
    plt.legend(['train', 'val'], loc='upper left')
    plt.show()
    

    plt.plot(history.history['loss'])
    plt.plot(history.history['val_loss'])
    plt.title('model loss')
    plt.ylabel('loss')
    plt.xlabel('epoch')
    plt.legend(['train', 'val'], loc='upper left')
    plt.show()
    

提交回复
热议问题