Tensorflow vs Pytorch


So, since you’re reading this article, I’m going to assume you have started your deep learning journey and have been playing around with artificial neural nets. Or maybe, you’re just thinking about starting your career in this field . Whichever case it be, you find yourself in a bit of a dilemma. You have read about various deep learning frameworks and libraries and maybe two really stand out. The two most popular deep learning libraries: TensorFlow
 and PyTorch . I’m here to add one  article to the huge repository of the Internet. And maybe, help you get some clarity. Here are the points of comparison, no more. So, let’s begin!

Point 1:(Developers)

While both Tensorflow and PyTorch are open-source, they have been created by two different powerful tech giants. Tensorflow is based on Theano and has been developed by tech giant Google, whereas PyTorch has been developed by another tech giant Facebook.

Point 2:(style of doing computations)

The most important difference between the two is the way these frameworks define the computational graphs. While Tensorflow creates a static graph, PyTorch believes in a dynamic graph. That means,  In Tensorflow, you first have to define the entire computation graph(called as DAG or Directed Acyclic Graph) of the model and then run your ML model. 

Point 3:

Tensorflow has a more steep learning curve than PyTorch. PyTorch is more pythonic and building ML models feels more intuitive. On the other hand, for using Tensorflow, you will have to learn a bit more about it’s working (sessions, placeholders etc.) and so it becomes a bit more difficult to learn Tensorflow than PyTorch.

Point 4:(debugging)

Since Pytorch's computation graph is defined in the runtime(dynamic)  we can use our own debugging tools. But this is not in the case with Tensorflow. You have a special tool called tfdbg which allows to evaluate Tensorflow expressions at the runtime.

Point 5:(visualization and easiness)

When it comes to visualization aspect Tensorflow is ming blowing.This comparison would be incomplete without mentioning TensorBoard. TensorBoard is a brilliant tool that enables visualizing your ML models directly in your browser. Tensorboard can visualize images, distributions, histograms, display model graphs. PyTorch doesn’t have such a tool, although you can always use tools like Matplotlib  and  Seaborn . 

Finally, Tensorflow is much better for production and scalability. It was built to be production ready. Whereas, PyTorch is easier to learn and lighter to work with, and hence, is relatively better for passion projects and building rapid prototypes.

Point 6:(Resources and Communities)

Tensorflow has a much bigger community behind it than PyTorch. This means that it becomes easier to find resources to learn Tensorflow and also, to find solutions to your problems. Also, many deep learning , NLP  tutorials cover Tensorflow instead of using PyTorch. This is because PyTorch is a relatively new framework as compared to Tensorflow. So, in terms of resources, you will find much more content about Tensorflow  in Google, also in Tensorflow community in Github , than Pytorch community .

The truth is, some people find it better to use PyTorch while others find it better to use Tensorflow. Both are great frameworks with a huge community behind them and lots of support. They both get the job done. Tensorflow is very powerful and mature deep learning library and also Tensorflow is a good option if you want to develop industry type models , want a better documentation and larger community support . Here is a graph showing interest over time:

Histogram scores of different frameworks :


I hope I was able to help you in clearing your confusion(little bit) .  And if you are really confused and haven’t used any of them yet, pick any and just start. You will develop more intuition which will help you decide.

If you are just beginning your deep learning journey, and want to learn how to build deep learning models(like CNNs, RNNs or GANs) in Tensorflow and Keras, try out the Deep Learning Specialization by Andrew NG 

And finally, these are just tools. You can pick any and start learning the  in the big fields like Machine Learning , Deep Learning. If you liked This please leave a comment . Here are the links to some courses I have gone through.

1: Deep Learning Specialization  by deeplearning.ai (Andrew NG )                    2: Machine Learning  by Stanford University (Andrew NG)                  3: Introduction to Tensorflow  by Coursera                                                4: Deep Learning Explained   by Edx                                                                    5: Deep Learning Nanodegree  by Udacity

 Happy Learning !

Comments

Popular posts from this blog

A Simple Proteus project for Beginners