keras 서버용 fitgenerator 달리기 코드,loss,acc 곡선도 저장

990 단어 keras
import matplotlib.pyplot as plt


...   //          

history = model.fit_generator(
    image_generator, steps_per_epoch=2000 // 32  ,
    epochs=16, verbose=1,
    validation_data=image_generator_TEST, validation_steps=20
)


print(history.history.keys())
plt.switch_backend('agg')    #                 
//acc
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.savefig('acc.jpg')
//loss
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.savefig('loss.jpg')

 
 

좋은 웹페이지 즐겨찾기