Fixing the KeyError: ‘acc’ and KeyError: ‘val_acc’ Errors in Keras 2.3.x or Newer

Fixing the KeyError: ‘acc’ and KeyError: ‘val_acc’ Errors in Keras 2.3.x or Newer

If you’re getting errors such as KeyError: ‘acc’ or KeyError: ‘val_acc’ in your Keras code, it may be due to a recent change in Keras 2.3.x.

In Keras 2.3.0, how the matrices are reported was changed to match the exact name it was specified with. If you are using older code or older code examples, then you might run into errors. Here is how to fix them.

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'

ai troubleshooting deep-learning keras

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Deep Learning in Keras - Building a Deep Learning Model

Deep learning is one of the most interesting and promising areas of artificial intelligence (AI) and machine learning currently. With great advances in technology and algorithms in recent years, deep learning has opened the door to a new era of AI applications.

Keras Tutorial - Ultimate Guide to Deep Learning - DataFlair

Keras Tutorial - Learn Keras Introduction, installation, Keras Features, Applications of Keras, Keras Layers, Keras models and keras visualize training.

Top 10 Deep Learning Sessions To Look Forward To At DVDC 2020

Looking to attend an AI event or two this year? Below ... Here are the top 22 machine learning conferences in 2020: ... Start Date: June 10th, 2020 ... Join more than 400 other data-heads in 2020 and propel your career forward. ... They feature 30+ data science sessions crafted to bring specialists in different ...

How to Perform Face Detection with Deep Learning in Keras

Perform Face Detection with Deep Learning in Keras .If you’re a regular user of Google Photos, you may have noticed how the application automatically extracts and groups faces of people from the photos that you back up to the cloud.

Why Learn Keras - Reasons Why Choose Keras - DataFlair

Learn the Features of Keras that make it worth to learn keras like backend support, the basis of innovation, and the simplicity of Keras API etc.