我已使用以下代码保存了构建的CNN的历史纪元
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()
我正在尝试加载与使用以下代码保存的图相同的图,但是它给了我AttributeError:'dict'对象没有属性'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()
答案 0 :(得分:3)
您要保存history.histroy
字典而不是history
。尝试通过history['val_loss']
从已加载的泡菜数据中访问数据。