Tensorflow or PyTorch : The force is strong with which one?

Tensorflow or PyTorch : The force is strong with which one?

By ? Yashwardhan Jain

Image for postPhoto by Christian Stahl on Unsplash

So, since you?re reading this article, I?m going to assume you have started your deep learning journey and have been playing around for a while with artificial neural nets. Or maybe, you?re just thinking of starting. 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. And you can?t quite figure out what exactly is the difference. Fret not! I?m here to add one more article to the unending repository of the Internet. And maybe, help you get some clarity. Also, I?m going to make it easier and quicker for you, and give you just five points. Five points of comparison, no more. So, let?s begin!

Point #1:

While both Tensorflow and PyTorch are open-source, they have been created by two different wizards. Tensorflow is based on Theano and has been developed by Google, whereas PyTorch is based on Torch and has been developed by Facebook.

Point #2:

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. So what does this mean? In Tensorflow, you first have to define the entire computation graph of the model and then run your ML model. But in PyTorch, you can define/manipulate your graph on-the-go. This is particularly helpful while using variable length inputs in RNNs.

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:

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 tutorials and MOOCs 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 than PyTorch.

Point #5:

This comparison would be incomplete without mentioning TensorBoard. TensorBoard is a brilliant tool that enables visualizing your ML models directly in your browser. PyTorch doesn?t have such a tool, although you can always use tools like Matplotlib. Although, there are integrations out there that let you use Tensorboard with PyTorch. But it?s not supported natively.

Finally, Tensorflow is much better for production models 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.

Alright enough! Just tell me which one is better?

There is no right answer.(I know, I hate it too when someone says that)

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. They both are amazing magical wands that will let you do some machine learning magic.

I hope I was able to help you in clearing your confusion(little bit, maybe?). 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 this Deep Learning Nanodegree by Udacity.

And finally, these are just tools. You can pick any and start learning the science and art of machine learning.

Happy Learning!

About the Author | Yashvardhan Jain

Computer Science Undergrad. AI enthusiast. Bibliophile.

Follow him on Medium, Twitter, and Quora

13

No Responses

Write a response