Thursday, March 19, 2020

Stay Safe During the COVID-19 Outbreak

Dear Readers of Codes of Interest,

Hope you, your family and loved ones are staying safe in these troubling times.

Being a globally impacting event, the COVID-19 pandemic has caused disruptions in many of our lives. Some more than others.

And, no doubt most of you have been forced to take a break from your daily routines and remain isolated from others.

SARS-CoV-2
SARS-CoV-2

While we all understand the importance of social distancing, the severity of the situation and the isolation is surely causing stress and uneasiness in all of us.

In order to attempt to provide a way to positively distract you from the stress, I have thought of giving away the kindle version of my book for free. Hopefully, this would allow you to have something to read and do while we wait for this pandemic to settle down.

The kindle eBook will be available via Amazon: https://www.amazon.com/dp/B07MY5Y643
It will be free until Monday, March 23, 2020, 11:59 PM PDT.

Stay safe during these troubling times

Wednesday, January 1, 2020

Fixing the KeyError: 'acc' and KeyError: 'val_acc' Errors in Keras 2.3.x

Have you been using the 'History' object returned by the fit() functions of Keras to graph or visualize the training history of your models? And have you been getting a 'KeyError' type error such as the following since recent Keras upgrade and wondering why?


Traceback (most recent call last):
  File "lenet_mnist_keras.py", line 163, in <module>
    graph_training_history(history)
  File "lenet_mnist_keras.py", line 87, in graph_training_history
    plt.plot(history.history['acc'])
KeyError: 'acc'

The KeyError: 'acc' when attempting to read the history object
The KeyError: 'acc' when attempting to read the history object


Traceback (most recent call last):
  File "lenet_mnist_keras.py", line 163, in <module>
    graph_training_history(history)
  File "lenet_mnist_keras.py", line 88, in graph_training_history
    plt.plot(history.history['val_acc'])
KeyError: 'val_acc'

The KeyError: 'val_acc' when attempting to read the history object
The KeyError: 'val_acc' when attempting to read the history object

Well, this is due to a breaking change introduced in Keras release 2.3.0.