Deep Learning

The ultimate face-off between different deep learning Frameworks

February 10, 2020

Greetings fellow Deep learning enthusiast! It is time for the ultimate face-off between different deep learning frameworks. In this article, we will be discussing Tensorflow vs. Keras vs. Caffe vs. Theano. At the end of this article, you will be able to comprehend;

  • A quick recap of Deep Learning
  • What is Tensorflow, Keras, Caffe, and Theano?
  • Features of these tools that give them the edge over the others
  • Usage and scope of each of these frameworks in Deep Learning
  • Pros of Tensorflow, Caffe, Keras, and Theano
  • Cons of Tensorflow, Caffe, Keras, and Theano
  • A quick comparative between all these tools and frameworks

Let us now quickly recall what deep learning is, and then we will get started with our comparision analysis of Keras, Theano, Caffe, and Tensorflow.

Deep learning: Quick recap

Deep learning falls under the Machine learning domain, and is also known as Deep structured learning and hierarchical learning. It is based on recognizing and learning from the data representations, without using ‘task-specific’ algorithms. Deep learning can be supervised, semi-supervised, or unsupervised. 

Deep machine learning models are inspired and based on the robust information processing design of the human brain, i.e., layered neural coding via which the brain defines a relationship between the various stimuli and corresponding neural responses. 

A quick glance at the applications of Deep learning suggests that it is used for but not limited to;

  • Computer or machine vision
  • Natural language processing
  • Text and speech recognition
  • Social network filtering
  • Predictions based on Big data analysis
  • Bioinformatics
  • Business intelligence
  • Data analytics

Time to get started with our comparative analysis of Deep Learning Frameworks:

#1. TensorFlow

What is TensorFlow?

TensorFlow is an open-source software library that is used across a variety of tasks involving dataflow programming. It is primarily a mathematics library designed for machine learning applications, especially to develop neural network applications. TensorFlow was initially developed by Google’s Brain team and was meant for internal use by the Google. 

TensorFlow features

Following are the features of TensorFlow;

  • TensorFlow can run on multiple CPUs and GPUs, and CUDA & SYCL extensions are optional. 
  • Apart from running on multiple OS like Linux, macOS, and Windows, TensorFlow can also run on mobile device platforms like Android & iOS.
  • TensorFlow comes with the Python, C++, Haskell, Java, Go, and Rust APIs. It can also be coupled with third party APIs available for C, Julia, R, Scala, etc.
  • Models on the TensorFlow can be trained on distributed resources.
  • A crucial feature of TensorFlow is the TensorBoard. It enables the user to visualize the graphs that are being used for ML. 
  • Model checkpointing allows the user to stop the training in the middle, evaluate the model, and then resume the training from the same checkpoint. 
  • TensorFlow comes with a large community support and is recognized by almost any machine learning professional. 

TensorFlow for Deep learning;

TensorFlow is a popular choice for developing deep learning applications. Google’s RankBrain, an algorithm learning AI system. 

Pros;

  • Supports Numpy library in Python
  • Comes with a feature to visualize the graphs
  • Enhanced compilation performance (With respect to Theano)
  • TensorBoard for graph visualization

Cons;

  • TensorFlow is slower as compared to other frameworks
  • Lesser number of pre-trained models are available
  • Lack of commercial support
  • Prone to Dynamic typing errors in larger scale software projects

Also see: Beginner's guide to TensorFlow

#2. Keras

What is Keras?

Keras is an open-source neural network library coded in Python. Keras is able to run atop the Deeplearning4j, MXNet, TensorFlow, Theano, and Microsoft cognitive toolkit. This framework has been specifically designed for rapid experimentation with the deep neural models. Hence, Keras is minimal, robust, modular, and extensible by design. 

Since 2017, Keras has been supported by the TensorFlow’s core library. It allows for seamless configuration of the neural networks with high-level intuitive set of abstractions, irrespective of the backend computing library. 

Keras features;

Following are the key-features of Keras;

  • Keras allows for backend usage of Theano or Tensorflow, and allows for easy switching from the backend for a deep learning neural network.
  • Keras supports fully connected, pooling, convolution, embedding, recurrent, dropout, etc. neural layers. 
  • Modular design of Keras separates each component of the deep neural model as a module. Hence, they are easily and fully configurable. Example, optimizers, layers, dropouts, etc. 
  • Kerass’ user-friendly API allows for easy coding and development of deep learning models without heavy processing load. This also makes it easy to spot the bugs and resolve coding issues. 

Keras for Deep learning

Keras is a popular tool for High level abstraction models. Its APIs are seamless and that has what made it famous as the official high level abstraction of the TensorFlow framework. Keras is an excellent tool for building deep neural networks. 

Pros;

  • Keras comes with an intuitive API that has been inspired by the ‘Torch’ framework’s design
  • Keras is a rapidly growing framework
  • Supports integrated working with TensorFlow, Theano, Deeplearning4j, and CNTK (Soon to be announced) at the backend
  • Keras will most probably become the standard Python API for the Neural Network development

Cons;

  • Keras is not much useful for low level abstraction applications. It usually displays ‘Theano Low-level’ error.
  • Going beyond the surface-level customization can be tedious.
  • Data processing tools are not high performance and may require manual writing of sequence/non-sequence pre-processing routines.

Also see: Beginner's guide to Keras

#3. Caffe

What is Caffe?

Caffe is an open-source deep learning framework developed for Machine Learning. It is written in C++ and Caffe’s interface is coded in Python. It has been developed by the Berkeley AI Research, with contributions from the community developers. 

Caffe has been designed for the purposes of speed, open-source ML development, expressive architecture and seamless community support. These features make Caffe framework a popular choice for building Deep Learning models.

Caffe features;

Following are the key-features of Caffe framework;

  • The Caffe framework features top-notch codes, algorithms and models. Over the time, Caffe has witnessed many changes contributed by the developers and researchers that makes it a powerful platform for deep learning projects.
  • An expressive and modular architecture of Caffe allows for boosted development of applications and programs based on machine learning. One can define the models and optimize them without hard-coding efforts. The user can switch between GPU (Graphics Processing Unit) and CPU by using a single-flag and train the ML model on a GPU machine.
  • Speed is another feature that makes Caffe a popular choice for Deep Learning operations. With a single Nvidia K40 GPU, Caffe can process over 60 million images per day. That speed translates to 1 millisecond/image for inference and 4 milliseconds/image for learning operations. Recent library versions and latest hardware are still boosting Caffe’s speed performance.
  • The users of Caffe platform can get developer support from Caffe-users group and GitHub platform. Various startup-prototypes, academic research projects, and industrial applications relating to vision, speech, and multimedia recognition have been forged on Caffe, and powered by the support of Caffe Community.

Caffe for Deep learning;

Caffe supports multiple types of Deep Learning Architectures. These can range from ‘image classification’ to ‘Image segmentation.’ Caffe also supports the use of GPU based acceleration using Nvidia’s CuDNN library. This makes Caffe a prime choice for speedy Deep learning network development.

Pros;

  • Caffe is an excellent framework for image processing and Feedforward networks.
  • It is also suitable for fine-tuning the existing deep neural networks.
  • Users can build models without requiring to write extensive codes.
  • Python interface makes Caffe a seamless to use tool.

Cons;

  • Caffe is not suitable for building recurrent networks
  • Caffe can be tedious to use framework when working with extensive networks like ResNet, GoogLeNet, etc.
  • Lack of commercial support turns-off the enterprise-grade developers.
  • Caffe is under a slow-paced development. This factor is fading its popularity amongst ML professionals.

Also see: Beginner's guide to Caffe

#4. Theano

What is Theano?

Theano is Python’s numerical computation library. It handles multidimensional arrays like Numpy, etc. The computations in Theano are expressed as NumPy-esque syntax. These can be compiled for executional processing on the GPU as well as CPU architectures. In fact, numerous open-source library frameworks have been built atop the Theano framework. These include Keras, Blocks, and Lasagne. Theano was primarily meant for data exploration and research purposes. 

However, one important thing to note is that Theano has ran out of popularity. That is, it is essentially dead. Due to the developers inability to maintain and evolve Theano further, it has lost its fame. 

Theano Features;

Following are some noteworthy features of Theano;

  • Theano can compile parts of the expression graph using the nvcc or g++ on the GPU or CPU instructions. This helps in running the graphs at a much faster rate than just using Python.
  • Theano can autonomously build symbolic graphs to calculate computing gradients. 
  • Theano has a special feature for identifying the numerically unstable expressions. It can then calculate them for more stable-algorithms. 
  • Theano’s APIs are known to be stable for a longer duration despite the updates, and rarely reports bugs due to updates. 

Theano for deep learning;

Theano allows for building networks that can attain speeds comparative to scratch-built ‘C’ programs, especially those that involve large amounts of data. Combine this with its automation features like numerical instability detection, and Theano becomes a right choice for the Deep learning model builders.

Pros;

  • Theano supports Python plus NumPy libraries
  • It supports neatly abstracted computational graphs
  • Theano integrates RNNs in the graphs seamlessly
  • High-level abstraction engines like Lasagne & Keras make working on Theano less tedious.

Cons;

  • Suitable for Low-level abstractions only
  • Extensive and deeper models require long-compilation time
  • Lack of developer support for the available pre-trained models
  • Usually displays bugs when deployed in the AWS.
  • Theano supports only a single Graphics Processing Unit (GPU).

Also see: Beginner's guode to Theano

Now that we understand the key features, advantages, and disadvantages that come with these tools, let us now take a look at the comparative analysis for the same in a table. You will then be able to judge each tool closely. 

Pointers\ToolsTensorFlowKerasCaffeTheano
FeaturesMultiple GPU & CPU supportPython, Java, Haskel, C++, Go APIs supportVisuals through TensorBoardEasy switching of Theano or TensorFlow at the BackendFull support of various neural layersModular design Comes with latest algorithms and modelsSpeed & expressive modular architecture make it an excellent toolCan compile graphs using CPU & GPU instructionsAutomatic gradient computationTheano APIs are highly stable
ProsNumPy+ PythonVisual graphsTensorBoard toolIntuitive APIs & rapidly growing networkTensorFlow, Theano, Deeplearning4j supportExcellent for image processing & Feedforward networksPython interfaceNo extensive coding requiredPython +NumPy library supportNeatly abstracted computational graphsSeamless RNN integration in the graphs
ConsSlower as compared to other networksLack of commercial supportLesser number of pre-trained modelsUnsuitable for low-level abstractionsAverage performing data processing toolsSurface-layer customization is tediousNot suitable for Recurrent networksTedious with extensive networksLack of commercial supportSuitable for low-level abstractions onlyBugs when deploying model on AWSOnly single GPU support

There you go! We just came across the ultimate showdown between four popular deep learning frameworks. Be a keen judge and select the most suitable one for your deep learning project. Happy coding till then!