deep-learning-with-python-notebooks: Training and validation loss plot uses wrong history.history keys
Notebook 3.5-classifying-movie-reviews
The code that is supposed to generate the Training and validation loss side by side uses wrong history.history keys:
acc = history.history['acc']
val_acc = history.history['val_acc']
loss = history.history['loss']
val_loss = history.history['val_loss']
which results in the following errors:
KeyError: 'acc'
KeyError: 'val_acc'
If you examine de history.history keys you can see that they have different names:
history_dict = history.history
history_dict.keys()
dict_keys(['loss', 'val_loss', 'binary_accuracy', 'val_binary_accuracy'])
This is probably due to the use of metrics.binary_accuracy as the metric for evaluating the model. The following change in keys would fix the error:
acc = history.history['binary_accuracy']
val_acc = history.history['val_binary_accuracy']
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 17
- Comments: 17
Hey, for me it was solved by typing ‘accuracy’ instead of ‘acc’ , I was told that its a keras version mismatch. @techSash @seifmahmoud
@thisiseshan try ‘accuracy’ instead of ‘binary_accuracy’
It is still open because there are lots of us and new students who are struggling with coding (unlike you). Do not follow the thread if it is a waste of your precious time.
On Sat, Aug 22, 2020 at 10:41 PM Aryan Choudhary notifications@github.com wrote: