简体   繁体   中英

loading accuracy and loss epochs of CNN

I have saved my history epochs of the built CNN using the below code

history=classifier.fit_generator(training_set,
                        steps_per_epoch = 3194 // batchsize,
                        epochs = 100,
                        validation_data =test_set,
                        validation_steps = 1020 // batchsize)
with open('32_With_Dropout_rl_001_1_layer', 'wb') as file_pi:
        pickle.dump(history.history, file_pi)

plt.plot(history.history['val_accuracy'])
plt.title('model accuracy using 32 filters, dropout and .001 Adam learning rate')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['test'], loc='upper left')
plt.show()
# summarize history for loss
plt.plot(history.history['val_loss'])
plt.title('model loss using 32 filters, dropout and .001 Adam learning rate')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['test'], loc='upper left')
plt.show()

I am trying to load the same plot that I saved using the below code, but it gives me AttributeError: 'dict' object has no attribute 'history'


f = open('32_With_Dropout_rl_001_1_layer', 'rb')
history = pickle.load(f)
f.close()

# summarize history for accuracy
plt.plot(history.history['val_accuracy'])
plt.title('model accuracy using 32 filters, dropout and .001 Adam learning rate')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['test'], loc='upper left')
plt.show()
# summarize history for loss
plt.plot(history.history['val_loss'])
plt.title('model loss using 32 filters, dropout and .001 Adam learning rate')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['test'], loc='upper left')
plt.show()



You are saving the history.histroy dict not history . Try access your data through history['val_loss'] from the loaded pickle data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM