In order to fulfill the basic functions of our service, the user hereby agrees to allow Xiaomi to collect, process and use personal information which shall include but not be limited to written threads, pictures, comments, replies in the Mi Community, and relevant data types listed in Xiaomi's Private Policy. By selecting "Agree", you agree to Xiaomi's Private Policy and Content Policy .
Agree

Tech

[Discussion] Keras Vs. PyTorch : Choosing Your First Deep Learning Framework

2018-06-29 14:56:38
1291 5

Hi, Mi Fans!

So, you want to learn deep learning? Whether you want to start applying it to your business, base your next side project on it, or simply gain marketable skills – picking the right deep learning framework to learn is the essential first step towards reaching your goal. Therefore, I strongly recommend that you pick either Keras or PyTorch. These are powerful tools that are enjoyable to learn and experiment with. Let's know more about these tools!


Introduction:-
Keras and PyTorch are open-source frameworks for deep learning gaining much popularity among data scientists.
  • Keras is a high-level API capable of running on top of TensorFlow, CNTK, Theano, or MXNet (or as tf.contrib within TensorFlow). Since its initial release in March 2015, it has gained favour for its ease of use and syntactic simplicity, facilitating fast development. It’s supported by Google.
  • PyTorch, released in October 2016, is a lower-level API focused on direct work with array expressions. It has gained immense interest in the last year, becoming a preferred solution for academic research, and applications of deep learning requiring optimizing custom expressions. It’s supported by Facebook.

PyTorch:


PyTorch is one of the newest deep learning framework which is gaining popularity due to its simplicity and ease of use. Pytorch got very popular for its dynamic computational graph and efficient memory usage. The dynamic graph is very suitable for certain use-cases like working with text. Pytorch is easy to learn and easy to code. For the lovers of oop programming, torch.nn.Module allows for creating reusable code which is very developer friendly. Pytorch is great for rapid prototyping especially for small-scale or academic projects.
Keras:
François Chollet, who works at Google developed Keras as a wrapper on top of Theano for quick prototyping. Later this was expanded for multiple frameworks such as Tensorflow, MXNet, CNTK etc as back-end. Keras is being hailed as the future of building neural networks. Keras is designed to remove boilerplate code. Few lines of keras code will achieve so much more than native Tensorflow code. You can easily design both CNN and RNNs and can run them on either GPU or CPU. Currently, Keras is one of the fastest growing libraries for deep learning. The power of being able to run the same code with different back-end is a great reason for choosing Keras.


Ease of use and flexibility:-
  • Keras is a higher-level framework wrapping commonly used deep learning layers and operations into neat, lego-sized building blocks, abstracting the deep learning complexities away from the precious eyes of a data scientist.
  • PyTorch offers a comparatively lower-level environment for experimentation, giving the user more freedom to write custom layers and look under the hood of numerical optimization tasks. Development of more complex architectures is more straightforward when you can use the full power of Python and access the guts of all functions used.

Consider this head-to-head comparison of how a simple convolutional network is defined in Keras and PyTorch:

The code snippets above give a little taste of the differences between the two frameworks. As for the model training itself – it requires around 20 lines of code in PyTorch, compared to a single line in Keras. Enabling GPU acceleration is handled implicitly in Keras, while PyTorch requires us to specify when to transfer data between the CPU and GPU.

Performance:-
PyTorch is as fast as TensorFlow, and potentially faster for Recurrent Neural Networks. Keras is consistently slower. As the author of the first comparison points out, gains in computational efficiency of higher-performing frameworks (ie. PyTorch & TensorFlow) will in most cases be outweighed by the fast development environment, and the ease of experimentation Keras offers.


Conclusion:-
Keras and PyTorch are both excellent choices for your first deep learning framework to learn.

If you’re a mathematician, researcher, or otherwise inclined to understand what your model is really doing, consider choosing PyTorch. It really shines, where more advanced customization (and debugging thereof) is required or when we need to optimize array expressions other than neural networks. As far as training speed is concerned, PyTorch outperforms Keras.

Keras is without a doubt the easier option if you want a plug & play framework: to quickly build, train, and evaluate a model, without spending much time on mathematical implementation details. Keras is more concise and has simpler API.

Here is the Popularity Growth Graph:

Source: 1

So guys, which framework experience appeals to you more? Let me know in the comment section below!
2018-06-29 14:56:38
Favorites4 RateRate

Master Bunny

meetgour | from Redmi Note 5 Pro

#1

Nice Thread!!
2018-06-29 15:15:51

Moderator

Sam_crazy | from Redmi Note 4

#2

Keras will be a good option. Its much easier indeed. thanks for sharing such topic in detail. :)
2018-06-29 15:28:36

Grandmaster Bunny

Solver13 | from Redmi Note 4

#3

Nice Comparison with detailed information. Thanks For Sharing
2018-06-30 02:00:06
Thanks for this information

2018-07-03 21:29:20
Invalid floor, the posts have been deleted #5
please sign in to reply.
Sign In Sign Up

Mohammad Enayat

Master Bunny

  • Followers

    64

  • Threads

    55

  • Replies

    817

  • Points

    8194

3 Days Check-In
7 Days Check-In
21 Days Check-In
40 Days Check-In
Nov-100 replies in a month
Dec-100 replies in a month
100 ответов в декабре
Android O Tester
Christmas 2017
ThrowBackWithMiCommunity
MIUI Instagram
Mi Community Updater
Color Your Planet
Color Our Planet Game
The Motivator
MIUI 10
Golden Mi Bunny
Go Bunny Medal
MIUI Subscriber
Mi A2
MIUI 8th Anniversary
Go Bunny Master
Eid Mubarak
5 Million Registered Users
Throwback With Mi 2018

Read moreGet new
Copyright©2010-2020 Xiaomi.com, All Rights Reserved
Content Policy
Quick Reply To Top Return to the list