Author: Pulkit Sharma
Translator: Chen Zhiyan
Proofreader: Ding Nanya
This article contains about 3900 words, and is recommended to read for 10+ minutes.
This article analyzes and compares the advantages and applications of five very useful deep learning frameworks.
Overview
Since I started my career, I have always been a programmer. I enjoy coding from scratch, which helps me understand the subject (or skill) clearly. This approach is especially useful when we first start learning data science.
Trying to implement a neural network from scratch, you will understand many interesting things. But is it still a good idea when it comes to building deep learning models for real-world datasets? If it takes you days or weeks to build a model, that is simply not feasible.
For those who do not have unlimited computing resources, you have come to the right place.
Fortunately, we now have easy-to-use open-source deep learning frameworks designed to simplify the implementation of complex and large-scale deep learning models. With these amazing frameworks, we can implement complex models like convolutional neural networks.
This article will introduce five very useful deep learning frameworks, their advantages, and applications. We will compare each framework to understand when and where to use them.
We have also created a very cool infographic for each deep learning framework, attached at the end of the article, which is essential for every data scientist.
Table of Contents
1. What is a Deep Learning Framework?
2. TensorFlow
3. Keras
4. PyTorch
5. Caffe
6. Deeplearning4j
7. Comparison of the Five Deep Learning Frameworks
1. What is a Deep Learning Framework?
Let’s understand this concept with an example, let’s look at the following collection of images:
This image contains different categories: cats, camels, deer, elephants, etc. Our task is to categorize these images into their respective classes (or categories). A quick Google search will tell you that Convolutional Neural Networks (CNNs) are very effective for this type of image classification task.
What we need to do is implement this model, right? If we write a convolutional neural network from scratch, it could take days (or even weeks) to get an effective model, and we simply can’t wait that long!
This is where deep learning frameworks truly change the game.
A deep learning framework is an interface, library, or tool that makes it easier and faster for us to build deep learning models without needing to delve into the details of the underlying algorithms. Deep learning frameworks define models using a collection of pre-built and optimized components, providing a clear and concise method for model implementation.
With the right framework, you can quickly build models without writing hundreds of lines of code. A good deep learning framework has the following key features:
-
Optimized performance
-
Easy to understand and code
-
Good community support
-
Parallel processes to reduce computation
-
Automatic gradient calculation
These five points are also the criteria I used to select the top five deep learning frameworks. Let’s take a closer look at them.
2. TensorFlow
TensorFlow is developed by researchers and engineers from the Google Brain team, and it is the most commonly used software library in the field of deep learning (although other software is rapidly emerging).
There are two reasons I love TensorFlow: it is completely open-source, and it has excellent community support. TensorFlow has pre-written code for most complex deep learning models, such as recurrent neural networks and convolutional neural networks.
One of the biggest reasons TensorFlow is so popular is its support for multiple languages to create deep learning models, such as Python, C, and R, and it has good documentation and guides.
TensorFlow has many components, the most notable ones are:
-
Tensorboard: Helps with effective data visualization using data flow graphs
-
TensorFlow: For quickly deploying new algorithms/experiments
TensorFlow’s flexible architecture allows us to deploy deep learning models on one or more CPUs (and GPUs). Here are some typical use cases of TensorFlow:
-
Text-based applications: language detection, text summarization
-
Image recognition: image captioning, facial recognition, object detection
-
Sound recognition
-
Time series analysis
-
Video analysis
Use cases are far beyond these; if you know other applications of TensorFlow beyond what has been mentioned, I would love to know! Feel free to tell me in the comments section of this article, and we can discuss it further.
Installing TensorFlow is also a very simple task.
For CPU:
pip install tensorflow
For GPU cards with CUDA enabled:
pip install tensorflow-gpu
Learn how to use TensorFlow to build neural network models through the following comprehensive tutorials:
-
Introduction to Implementing Neural Networks Using TensorFlow
https://www.analyticsvidhya.com/blog/2016/10/an-introduction-to-implementing-neural-networks-using-tensorflow/?utm_source=blog&utm_medium=comparison-deep-learning-framework
-
TensorFlow Tutorials
https://www.tensorflow.org/tutorials
3. Keras
Are you comfortable using Python? If so, then you can immediately connect to Keras. This is the perfect framework to kickstart your deep learning journey.
Keras is written in Python and can run on top of TensorFlow (as well as CNTK and Theano). The TensorFlow interface has its challenges, as it is a low-level library, and new users may find it difficult to understand some implementations.
On the other hand, Keras is a high-level API developed for quick experimentation. Therefore, if you want quick results, Keras automatically handles core tasks and generates outputs. Keras supports convolutional neural networks and recurrent neural networks and can run seamlessly on both CPUs and GPUs.
Beginners in deep learning often complain about not being able to properly understand complex models. If you are such a user, Keras is the right choice for you! Its goal is to minimize user operations and make its models truly easy to understand.
Models in Keras can be roughly divided into two categories:
1. Sequential
The layers of the model are defined sequentially. This means that when we train a deep learning model, these layers are implemented in sequence. Here is an example of a sequential model:
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
# we can add multiple layers to the model using .add()
model.add(Dense(units=64, activation='relu', input_dim=100))
model.add(Dense(units=10, activation='softmax'))
2. Keras Functional API
Used to define complex models, such as multi-output models or models with shared layers. Check the code below to understand this:
from keras.layers import Input, Dense
from keras.models import Model
inputs = Input(shape=(100,)) # specify the input shape
x = Dense(64, activation='relu')(inputs)
predictions = Dense(10, activation='softmax')(x)
model = Model(inputs=inputs, outputs=predictions)
Keras has various architectures, as described below, used to solve a wide range of problems, including one of my favorites: image classification!
-
VGG 16
-
VGG 19
-
InceptionV 3
-
Mobilenet and more
You can refer to the official Keras documentation for a detailed understanding of how the framework works.
Keras Official Chinese Documentation
https://keras.io/zh/
It only takes one line of code to install Keras:
pip install keras
Interested in Keras? You can continue learning with the following tutorials on how to implement neural networks using Keras:
-
Optimizing Neural Networks Based on Keras
https://www.analyticsvidhya.com/blog/2016/10/tutorial-optimizing-neural-networks-using-keras-with-image-recognition-case-study/?utm_source=blog&utm_medium=comparison-deep-learning-framework
4. PyTorch
Remember we said TensorFlow is currently the most commonly used deep learning framework? However, considering the speed at which data scientists and developers are embracing Facebook’s PyTorch, it may soon fall behind.
I am an advocate of PyTorch, as it is the most flexible among the frameworks I have studied.
PyTorch is an interface to the Torch deep learning framework, which is used to build deep neural networks and perform tensor computations. Torch is a Lua-based framework, while PyTorch runs on Python.
PyTorch is a Python package that provides tensor computation. Tensors are multi-dimensional arrays, similar to numpy’s ndarray, and it can also run on GPUs. PyTorch uses dynamic computation graphs, and PyTorch’s Autograd package generates computation graphs from tensors and automatically computes gradients.
Unlike predefined graphs with specific functions, PyTorch provides a framework for building computation graphs at runtime, and even modifying these graphs during runtime. This feature is valuable when you are unsure how much memory is needed to create a neural network.
You can use PyTorch to tackle various challenges in deep learning, including:
-
Image (detection, classification, etc.)
-
Text (NLP)
-
Reinforcement learning
Want to know how to install PyTorch on your machine? Please hold on. The installation steps depend on the operating system, the PyTorch package to install, the tools/languages being used, CUDA, and some other factors.
Check the PyTorch installation steps based on the content of this link, and once you have the framework ready, check out the following two resources to build your first neural network using PyTorch:
-
Learn How to Build Fast and Accurate Neural Networks Using PyTorch – 4 Great Case Studies
https://www.analyticsvidhya.com/blog/2019/01/guide-pytorch-neural-networks-case-studies/https://www.analyticsvidhya.com/blog/2019/01/guide-pytorch-neural-networks-case-studies/?utm_source=blog&utm_medium=comparison-deep-learning-framework
-
PyTorch Tutorials
https://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html
5. Caffe
Caffe is another popular deep learning framework aimed at the field of image processing, developed by Yangqing Jia during his PhD at the University of California, Berkeley. It is also open-source!
Firstly, Caffe does not support recurrent networks and language modeling as well as the three frameworks mentioned above. However, Caffe’s standout feature is its processing speed and the speed at which it learns from images.
Caffe can process over sixty million images a day with a single NVIDIA K40 GPU, with 1 millisecond/image for inference and 4 milliseconds/image for learning.
It has solid support for interfaces such as C, Python, MATLAB, and traditional command line.
Through the Caffe Model Zoo framework, pre-trained networks, models, and weights for solving deep learning problems are accessible. These models can accomplish the following tasks:
-
Simple recursion
-
Large-scale visual classification
-
SiameSE networks for image similarity
-
Speech and robotics applications
For more details, you can check the Caffe documentation.
-
Caffe Installation Documentation
http://caffe.berkeleyvision.org/installation.html
-
Caffe Documentation
http://caffe.berkeleyvision.org/
6. Deeplearning4j
Are there any Java programmers in our community? This is your ideal deep learning framework! Deeplearning4j is implemented in Java, making it more efficient than Python. It uses a tensor library called ND4J, which provides the ability to handle n-dimensional arrays (also known as tensors). This framework also supports both CPU and GPU.
Deeplearning4j handles the tasks of loading data and training algorithms as separate processes, providing great flexibility. Everyone loves that, especially in deep learning!
Deeplearning4j is also suitable for different types of data:
-
Images
-
CSV
-
Plain text, etc.
Deep learning models built with Deeplearning4j include:
-
Convolutional Neural Networks (CNNs)
-
Recurrent Neural Networks (RNNs)
-
Long Short-Term Memory (LSTM) and other architectures
Read the installation steps and documentation for Deeplearning4j to get started with this framework.
-
Deeplearning4j Installation Steps
https://deeplearning4j.org/docs/latest/deeplearning4j-config-gpu-cpu
-
Deeplearning4j Documentation
https://deeplearning4j.org/docs/latest/deeplearning4j-quickstart
7. Comparison of the Five Deep Learning Frameworks
We have discussed the five most popular deep learning frameworks, each with its unique features. So how will data scientists make their choices?
Have you decided which one to use? Or are you planning to switch to a whole new framework? Regardless of the situation, it is essential to understand the advantages and limitations of each framework. If you choose the right framework, you won’t be surprised when you encounter errors!
Some frameworks work very well with image data but cannot parse text data; some frameworks perform well with both image and text data, but their internal workings can be challenging to understand.
In this section, we will compare the five deep learning frameworks using the following criteria:
-
Community support strength
-
Languages used
-
Interface
-
Support for pre-trained models
The table below compares these frameworks:
This is a very convenient comparison table for choosing which framework to use!
All of these frameworks are open-source, support CUDA, and have pre-trained models. But how should you start correctly, and which framework should you choose to build (initial) deep learning models? Let’s discuss this in detail!
-
TensorFlow
Let’s first talk about TensorFlow. TensorFlow can handle image and sequence-based data. If you are a beginner in deep learning or do not have a solid foundation in mathematical concepts such as linear algebra and calculus, the learning curve of TensorFlow will be steep and daunting.
I completely understand that it may be too complicated for beginners. But I encourage you to practice continuously, explore the community, and keep reading articles to master the tricks of TensorFlow. Once you have a good understanding of this framework, implementing a deep learning model will be a piece of cake for you.
-
Keras
Keras is a very solid framework to kickstart your deep learning journey. If you are familiar with Python and have not engaged in advanced research or developed any special neural networks, then Keras is right for you.
Keras focuses more on achieving results rather than being bogged down by the complexities of the models. Therefore, if you have a project related to image classification or sequence models, you can start with Keras and quickly build a working model.
Keras is also integrated into TensorFlow, so you can use tf.keras. to build models.
-
Caffe
Caffe is a good choice for building deep learning models on image data. However, when it comes to recurrent neural networks and language models, Caffe lags behind the other frameworks we discussed. The main advantage of Caffe is that you can build deep learning models even without strong knowledge of machine learning or calculus.
Caffe is primarily used to build and deploy deep learning models for mobile phones and other computation-constrained platforms.
-
Deeplearning4j
As mentioned earlier, Deeplearning4j is a paradise for Java programmers. It provides extensive support for different neural networks such as CNNs, RNNs, and LSTMs, and can handle large amounts of data without sacrificing speed. Sounds great, doesn’t it? Don’t miss out!
Conclusion and Infographic
Besides the five deep learning frameworks mentioned in this article, do you have other deep learning frameworks? I would love to hear your thoughts and feedback. Please reach out to me in the comments section below.
Remember, these frameworks are essentially just tools to help us achieve our ultimate goals, and choosing them correctly can save a lot of effort and time.
Finally, here is an infographic that details each of the deep learning frameworks we covered. Download it, print it out, and use it the next time you build a deep learning model!
Original Title:
Top 5 Amazing Deep Learning Frameworks Every Data Scientist Must Know! (with Illustrated Infographic)
Original Link:
https://www.analyticsvidhya.com/blog/2019/03/deep-learning-frameworks-comparison/
Translator’s Profile

Chen Zhiyan, graduated from Beijing Jiaotong University with a master’s degree in Communication and Control Engineering. He has worked as an engineer at Great Wall Computer Software and System Company and Datang Microelectronics Company, and is currently a technical support engineer at Beijing Wuyi Chaoqun Technology Co., Ltd. He is engaged in the operation and maintenance of intelligent translation teaching systems and has accumulated some experience in artificial intelligence deep learning and natural language processing (NLP). In his spare time, he enjoys translation and creative writing, with translated works including: IEC-ISO 7816, Iraq Oil Engineering Projects, New Fiscal Taxation Declaration, etc. His Chinese-to-English work “New Fiscal Taxation Declaration” was officially published in GLOBAL TIMES. He hopes to join the translation volunteer group of THU Data Party platform in his spare time to exchange and share with everyone and make progress together.
Translation Group Recruitment Information
Job Content: Requires a meticulous heart to translate selected foreign articles into fluent Chinese. If you are a data science/statistics/computer student, or working overseas in related fields, or confident in your foreign language skills, you are welcome to join the translation group.
What You Can Get: Regular translation training to improve volunteers’ translation skills, enhance understanding of the forefront of data science, overseas friends can maintain contact with domestic technological application development, and the background of THU Data Party’s industry-university-research collaboration brings good development opportunities for volunteers.
Other Benefits: Data science workers from well-known companies, students from prestigious universities such as Peking University and Tsinghua University, and overseas students will all become your partners in the translation group.
Click on the end of the article “Read the Original” to join the Data Party team~
Reprint Notice
If you need to reprint, please indicate the author and source prominently at the beginning of the article (transferred from: Data Party ID: datapi), and place a prominent QR code of Data Party at the end of the article. For articles with original identification, please send [Article Name – Name of the Authorized Public Account and ID] to the contact email to apply for whitelist authorization and edit as required.
After publishing, please feedback the link to the contact email (see below). Unauthorized reprints and adaptations will be pursued legally.
Click on “Read the Original” to embrace the organization