3
$\begingroup$

Recently I've been working on a pretty vanilla ANN model in Python with sklearn (and its preprocessing pipeline), mostly in jupyterhub notebooks if that matters.

I am considering changing the framework I work with as I need some more tools (drop out at least). but I am not so familiar with Python frameworks. The 2020 state of AI report point out (p. 14) that the two main frameworks are PyTorch and Tensorflow.

What are the practical differences between those two frameworks ?

$\endgroup$

1 Answer 1

2
$\begingroup$

As of October 2020...

In terms of basic neural network functionality, they are pretty equivalent.

Some differences:

  • Stability: tensorflow 2.0 underwent a lot of changes from tensorflow 1.x, specifically in the very way it worked (they changed from a computational graph paradigm to an imperative paradigm). This caused a lot of friction and left many underlying problems in tensorflow.
  • API coherence: tensorflow API has evolved and changed a lot and, through its evolution, many pieces of functionality were duplicated, and later where deprecated and removed. Also, there is a framework called Keras, which, at the beginning was a separate piece of code, but now is integrated in tensorflow. The co-existence of tensorflow and keras brought tension (see here). The Pytorch API has been more consistent over time.
  • Documentation: the API of tensorflow has changed a lot over the time that many tutorials and stackoverflow questions are outdated. Pytorch has changed less and has kept good backward compatibility so, while there are some tutorials that may include outated practices, most of them should work.
  • Deployment: tensorflow is known to be better suited for "production scenarios", e.g. it has tensorflow serving for exposing trained models through a service. This, however, is changing and now there are official alternatives for model deployment for pytorch.
  • Mobile support: tensorflow lite is the official way of having deep learning models use the GPU of Android mobile devices, so it's easier to deploy on Android if you use tensorflow. Note that, while there is a mobile version of Pytorch, it does not support GPU yet.

So, how to choose? This is my opinion:

  • Use tensorflow if you have a specific reason for using it, e.g. you want to deploy on Android easily, you want to use tensorflow serving, you want to reuse models that are only available for tensorflow.
  • Use pytorch in any other case.
$\endgroup$
6
  • 1
    $\begingroup$ There is a dedicated branch of Pytorch for mobile & embedded devices, too - Pytorch Mobile - that's why personally I don't like this kind of questions here and I think there is a certain risk in trying to answer them: when it comes to facts, it is almost certain that something significant will be left out (unless one goes for a full & detailed survey, which is arguably out of scope); and if it is about opinions, it is explicitly off-topic... $\endgroup$
    – desertnaut
    Commented Oct 20, 2020 at 10:04
  • $\begingroup$ As far as I understand, Pytorch mobile does not support GPU usage (see this and this), which is what I mentioned in my answer. I think this kind of questions are very useful precisely due to the difficulty of getting a clear picture for newcomers, given the many aspects to take into account. $\endgroup$
    – noe
    Commented Oct 20, 2020 at 10:08
  • $\begingroup$ I will add a comment about Pytorch Mobile, though. Thanks @desertnaut! $\endgroup$
    – noe
    Commented Oct 20, 2020 at 10:11
  • $\begingroup$ Does not yet indeed: "Support for hardware backends like GPU, DSP, NPU will be available soon". But this does not change the general argument (BTW, it seems you have a typo in the mobile bullet - I guess you meant to say "it's easier to deploy on Android if you use tensorflow"?). $\endgroup$
    – desertnaut
    Commented Oct 20, 2020 at 10:12
  • 1
    $\begingroup$ Yes, that's a mistake, I wanted to refer to tensorflow, thanks! $\endgroup$
    – noe
    Commented Oct 20, 2020 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.