Subscribe to DSC Newsletter

Getting to Know Keras for New Data Scientists

This article was originally published on, written by Daniel Gutierrez.

For many new data scientists transitioning into AI and deep learning, the Keras framework is an efficient tool.

Keras is a powerful and easy-to-use Python library for developing and evaluating deep learning models. In this article, we’ll lay out the welcome mat to the framework. You should walk away with a handful of useful features to keep in mind as you get up to speed.

In the words of the developers, “Keras is a high-level neural networks API, written in Python and developed with a focus on enabling fast experimentation. It has been open sourced since its initial release in March 2015. Its documentation can be found on with source code on GitHub.

The Genesis of Keras

Although there are many quality deep learning frameworks to choose from, the Keras framework makes it easy to get started because of its design as an intuitive high-level API. It is attractive to new data scientists because with it, they can quickly prototype and develop new models.

Keras was built with modular building blocks and programmers can easily extend it with new custom layers. Considered a deep learning “front end” with a choice of “back ends,” it is an important tool for any data scientist working within neural networks and deep learning. It is particularly useful for training convolutional neural networks that have small training data sets.

François Chollet, a deep learning researcher at Google, developed the framework as part of project ONEIROS (Open-ended Neuro-Electronic Intelligent Robot Operating System). In 2017, Google’s TensorFlow team decided to support Keras in TensorFlow’s core library. Microsoft added a CNTK back end to the framework, which was available as of CNTK v2.0.

Object-Oriented Design

Keras is based on object-oriented design principles. This characteristic was described by its author François Chollet in the following way:

Another important decision was to use an object-oriented design. Deep learning models can be understood as chains of functions, thus making a functional approach look potentially interesting. However, these functions are heavily parameterized, mostly by their weight tensors, and manipulating these parameters in a functional way would just be impractical. So in Keras, everything is an object: layers, models, optimizers, etc. All parameters of a model can be accessed as object properties: e.g. `model.layers[3].output` is the output tensor of the 3rd layer in the model, `model.layers[3].weights` is the list of symbolic weight tensors of the layer, and so on.

Choice of Back Ends


Though developers initially built Keras on top of Theano, its abstraction ability made it easy for them to add TensorFlow shortly after Google released the back end. Eventually, the Keras API was implemented as part of Google TensorFlow.

Now, the deep learning front end supports a number of back end implementations: TensorFlow, Theano, Microsoft Cognitive Toolkit (CNTK), Eclipse Deeplearning4J, and Apache MXNet.

Seamless Python Integration

As a native Python package, Keras offers seamless Python integration. This includes simple access to the complete Python data science feature set, and framework extension using Python. The Python Scikit-learn API can also use Keras models. There are great tutorials to integrate these two tools and develop simple neural networks.

Porting Between Frameworks

Industry experts regard the Keras framework as the accepted tool to use to migrate between deep learning frameworks. Developers can migrate deep learning neural network algorithms and models along with pre-trained networks and weights.

Runs on CPUs and GPUs

The framework runs on both CPUs and GPUs. It can use single or multiple GPUs to train deep neural networks, or it can run on a GPU using the NVIDIA CUDA Deep Neural Network GPU-accelerated library (cuDNN). This approach is much faster than a typical CPU because developers designed Keras to deal with parallel computation.

Keras in the Cloud

There are many options to run the framework on a cloud service, including Amazon Web Services (AWS), Google Cloud Platform (GCP), Microsoft Azure, and IBM Cloud.

Graph Data Structure

Rather than relying on graph data structures from underlying back end frameworks, Keras has its own structures to handle computational graphs. This approach frees new data scientists from being forced to learn to program the back end framework. This feature is also what prompted Google to add the API to its TensorFlow core.

Deep Learning Education

Keras is a common choice for deep learning education because it allows beginners and seasoned practitioners alike to quickly build and train neural networks. What’s more, it allows users to do so without revising low-level details, which makes it easier to begin to understand the concepts of mechanics of deep learning.

The Keras framework is used to teach deep learning on popular online platforms, including on Coursera with Andrew Ng and with Jeremy Howard. (The latter has been Kaggle’s number 1 competitor for two years.)


As I’ve stressed in this article, Keras is a popular, high-level, deep learning API that helps data scientists rapidly build neural networks using a modular approach. It provides support for multiple back ends and allows for training on CPUs or GPUs. With it, data scientists can iterate machine learning hypotheses and move from experiments to production in a seamless fashion.

Views: 508


You need to be a member of Data Science Central to add comments!

Join Data Science Central


  • Add Videos
  • View All

© 2019   Data Science Central ®   Powered by

Badges  |  Report an Issue  |  Privacy Policy  |  Terms of Service