All Case Studies Design Development Interviews Our Way Project Management

Deep Learning Frameworks Comparison – Tensorflow, PyTorch, Keras, MXNet, The Microsoft Cognitive Toolkit, Caffe, Deeplearning4j, Chainer

Since many businesses want to make use of AI in order to scale up or take their start-up off the ground, it is crucial to realize one thing: the technology they choose to work with must be paired with an adequate deep learning framework, especially because each framework serves a different purpose. Finding that perfect fit is essential in terms of smooth and fast business development, as well as successful deployment.

The following list of deep learning frameworks might come in handy during the process of selecting the right one for the particular challenges that you’re facing. Compare the pros and cons of different solutions, check their limitations, and learn about best use cases for each solution!

1. TensorFlow

tensorflow

Created by Google and written in C++ and Python, TensorFlow is perceived to be one of the best open source libraries for numerical computation. It just has to be good, especially if giants like DeepMind, Uber, AirBnB, or Dropbox have all decided to leverage this framework.

TensorFlow is good for advanced projects, such as creating multilayer neural networks. It’s used in voice/image recognition and text-based apps (like Google Translate).

Of course, experts have considered both its pros...

  • It has a lot of documentation and guidelines;
  • It offers monitoring for training processes of the models and visualization  (Tensorboard);
  • It’s backed by a large community of devs and tech companies;
  • It provides model serving;
  • It supports distributed training;
  • Tensorflow Lite enables on-device inference with low latency for mobile devices;

...and cons:

  • It struggles with poor results for speed in benchmark tests compared with, for example, CNTK and MXNet,
  • It has a higher entry threshold for beginners than PyTorch or Keras. Plain Tensorflow is pretty low-level and requires a lot of boilerplate coding,
    And the default Tensorflow “define and run” mode makes debugging very difficult.

There is also one significant limitation: the only fully supported language is Python.

2. PyTorch

pytorch

PyTorch is the Python successor of Torch library written in Lua and a big competitor for TensorFlow. It was developed by Facebook and is used by Twitter, Salesforce, the University of Oxford, and many others.

PyTorch is mainly used to train deep learning models quickly and effectively, so it’s the framework of choice for a large number of researchers.

It has some significant advantages:

  • The modeling process is simple and transparent thanks to the framework’s architectural style;
  • The default define-by-run mode is more like traditional programming, and you can use common debugging tools as pdb, ipdb or PyCharm debugger;
  • It has declarative data parallelism;
  • It features a lot of pretrained models and modular parts that are ready and easy to combine;
    And distributed training has been supported since version 0.4.

But some cons are, of course, unavoidable:

  • It lacks model serving,
  • It’s not production-ready yet, however, the roadmap to version 1.0 looks impressive,
  • It lacks interfaces for monitoring and visualization such as Tensorboard – though you can connect externally to Tensorboard.

And it’s important to keep in mind: PyTorch is still relatively new, and it’s best for prototyping or small-scale projects. When it comes to larger cross-platform deployments – TensorFlow might be a better option. But PyTorch 1.0 is getting closer!

3. Keras

keras

This is a minimalistic Python-based library that can be run on top of TensorFlow, Theano, or CNTK. It was developed by a Google engineer, Francois Chollet, in order to facilitate rapid experimentation. It supports a wide range of neural network layers such as convolutional layers, recurrent layers, or dense layers.

One can make good use of it in areas of translation, image recognition, speech recognition, and so on.

The advantages...

  • Prototyping is really fast and easy;
  • It’s lightweight in terms of building DL models with a lot of layers;
  • It features fully-configurable modules;
  • It has a simplistic and intuitive interface – fantastic for newbies;
  • It has built-in support for training on multiple GPUs;
    It can be turned into Tensorflow estimators and trained on clusters of GPUs on Google Cloud;
  • It can be run on Spark;
  • It supports NVIDIA GPUs, Google TPUs, and Open-CL-enabled GPUs such as AMD.

...can easily blot out small disadvantages:

  • It might be too high-level and not always easy to customize;
  • It is constrained to Tensorflow, CNTK, and Theano backends.

It also doesn’t provide as many functionalities as TensorFlow, and ensures less control over the network, so these could be serious limitations if you plan to build a special type of DL model

4. MXNet

mxnet

This is a DL framework created by Apache, which supports a plethora of languages, like Python, Julia, C++, R, or JavaScript. It’s been adopted by Microsoft, Intel, and Amazon Web Services.

The MXNet framework is known for its great scalability, so it’s used by large companies mainly for speech and handwriting recognition, NLP, and forecasting.

Some of the main pros...

  • It’s quite fast, flexible, and efficient in terms of running DL algorithms;,
  • It features advanced GPU support;
  • It can be run on any device;
  • It has a high-performance imperative API;
  • It offers easy model serving;
  • It’s highly scalable;
  • It provides rich support for many programming languages, such as Python, R, Scala, Javascript, and C++, among others;

...and the cons of MXNet:

  • It has a much smaller community behind it compared with Tensorflow;
  • It’s not so popular among the research community.

So, MXNet is a good framework for big industrial projects, but since it is still pretty new, there’s a chance that you won’t receive support exactly when you need it – keep that in mind.

5. CNTK

cgnkt

This is now called The Microsoft Cognitive Toolkit – an open-source DL framework created to deal with big datasets and to support Python, C++, C#, and Java.

CNTK facilitates really efficient training for voice, handwriting, and image recognition, and supports both CNNs and RNNs. It is used in Skype, Xbox and Cortana.

As always, experts have considered both its advantages...

  • It delivers good performance and scalability;
  • It features a lot of highly optimized components;
  • It offers support for Apache Spark;
  • It’s very efficient in terms of resource usage;
  • It supports simple integration with Azure Cloud;

...and one disadvantage:

  • Limited community support.

6. Caffe and Caffe2

caffe2

Caffe is a framework implemented in C++ that has a useful Python interface. It supports CNNs and feedforward networks, and is good for training models (without writing any additional lines of code), image processing, and for perfecting existing networks. However… it’s sometimes poorly documented, and difficult to compile. There is no sign of any bigger company deploying Caffe right now.

But here comes Caffe2 – introduced by Facebook in 2017, a natural successor to the old Caffe, built for mobile and large-scale deployments in production environments. At Facebook, it’s known as “the production-ready platform, (...) shipping to more than 1 billion phones spanning eight generations of iPhones and six generations of Android CPU architectures.”

The framework is praised for several reasons:

  • It offers pre-trained models for building demo apps;
  • It’s fast, scalable, and lightweight;
  • It works well with other frameworks, like PyTorch, and it’s going to be merged into PyTorch 1.0;
  • It has server optimized inference.

The main cons include…

  • Limited community support.

And although Caffe2 is doing really well in space and speed tests, it is still quite new and might be a bit limited when it comes to implementing complex networks that require, for instance, useful debugging tools, or some help from a supportive community.

7. Deeplearning4j

dl4j

If your core programming language is Java – you should definitely take a closer look at DL4J. It’s a commercial-grade, open-source framework written mainly for Java and Scala, offering massive support for different types of neural networks (like CNN, RNN, RNTN, or LTSM).

It’s a great framework of choice, with a lot of potential in areas of image recognition, natural language processing, fraud detection, and text mining. Plus:

  • It’s robust, flexible and effective;
  • It can process huge amounts of data without sacrificing speed;
  • It works with Apache Hadoop and Spark, on top of distributed CPUs or GPUs;
  • The documentation is really good;
  • It has a community version and an enterprise version.

Surprisingly, when talking about DL4J, experts do not focus on any particular drawback of the framework as much as they do on the general cons of using Java for machine learning. Because Java is not very popular among machine learning projects, the framework itself cannot rely on growing codebases. As a result, the costs of development for your project may be much higher, significantly slowing down your business…

8. Chainer

chainer

Another Python-based DL framework, supported by giants like IBM, Intel, Nvidia, and AWS. It can be run on multiple GPUs with little effort.

Chainer is leveraged mainly for speech recognition, machine translation, and sentiment analysis. It supports various network architectures, like CNNs, fast-forward, nets and RNNs, and has some significant advantages over its competitors:

  • It’s much faster than other leading Python frameworks;
  • It’s super flexible and intuitive;
  • Existing networks can be modified at runtime.

On the other hand:

  • It’s more difficult to debug;
  • The community is relatively small.

As other Python-oriented frameworks are much more popular, you may not receive as much help with Chainer as you would with more popular frameworks, such as TF or PyTorch.

Wrapping it all up…

Choosing the perfect framework for a DL project can be a tough nut to crack. You have to take several factors into consideration:

  • the type of neural networks you’ll be developing,
  • the programming language you use,
  • the number of tools and additional options you’ll need,
  • the budget you have,
  • the character and general purposes of the project itself.

We hope the above comparison will shed some light on this problem and help you select the appropriate framework for your needs.

C
New call-to-action
READ ALSO FROM Machine Learning
Read also
Need a successful project?
Estimate project or contact us