In my Keras code, I did the following:
model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])
history = model.fit(border_irregularity_features,y, epochs=5, batch_size=1, validation_split=0.33)
...
...
accuracy = history.history['acc']
val_acc = history.history['val_acc']
However, I'm having the following error:
val_acc = history.history['val_acc']
KeyError: 'val_acc'
Why is that? What am I missing?
Thanks.
EDIT-1
When I did:
print history.history.keys()
I got:
['acc', 'loss', 'val_acc', 'val_loss']
From tensorflow 2 the history keys are as follows : (['val_loss', 'val_accuracy', 'val_precision', 'val_recall', 'loss', 'accuracy', 'precision', 'recall'])
There seems to be no issue with the code per-se. I have copied part of the code from another script I had. I just erased the underscores in "val_acc" and "val_loss" and typed them again, and it worked!
Maybe some special characters where embedded when copying and pasting?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With