Answers.Body: <p>In the past, I have used TensorFlow (1 and 2), Keras and PyTorch, so I will give an answer based on my experience. Currently, I use TF 2 and Keras (the version shipped with TF 2).</p>
  
  <p>In my (but not only) opinion, TF 1 is really ugly and painful, given that it involves sessions, placeholders and, in general, you need to define the computational graph before executing anything (even the simplest programs). With TF 2, you don't need sessions and placeholders anymore, and this is a very big improvement because you don't need to think that you first need to define a computational graph and then feed it with the input. Essentially, in TF 2, you can write TF code and you can almost be sure that your TF 2 code will look like any other Python code. </p>
  
  <p>TF and Keras have some bugs, but I think that also PyTorch must have some bugs (even though I don't remember having encountered them). </p>
  
  <p>TF comes with <a href="https://www.tensorflow.org/tensorboard" rel="nofollow noreferrer">TensorBoard</a>. You can also easily use TensorBoard from Keras. About one year ago, I had written a <a href="https://nbro.github.io/blogging/2019/01/06/an-example-of-how-to-use-visualdl-with-pytorch/" rel="nofollow noreferrer">blog post</a> about visualization tools for PyTorch. At the time, the tools didn't seem as developed as TensorBoard, but there were already a few options.</p>
  
  <p>Debugging in TF 2 isn't still perfect, but I would say that it has improved with respect to TF 1 (mainly because there is less boilerplate code). To debug in TF 2.0, I mainly use <a href="https://www.tensorflow.org/api_docs/python/tf/print" rel="nofollow noreferrer"><code>tf.print</code></a> (which behaves similarly to Python's <code>print</code> function), but there may be more advanced tools (e.g. I think there's a TF debugging plugin for PyCharm), even though I've never used them. TensorBoard could also be used as a debugging tool (for example, to understand how your models are learning, etc). </p>
  
  <p>The simplicity of PyTorch is comparable to that of Keras. TF now comes with an integrated version of Keras, which is optimized for TF, so TF code can look as simple as Keras code.</p>
  
  <p>In general, my impression is that, if you need to, TF provides more flexibility, but it's been a while since I used PyTorch. Furthermore, with TF 2.0, the code looks simpler, more consistent and the framework is better organized. On the other hand, PyTorch may still be easier to learn (because it doesn't have the past of TF, i.e. there are still many TF code that uses sessions, etc.).</p>
  
  <p>Both TF and PyTorch are supported by big companies (respectively, Google and Facebook), but TF is more mature and there are functionalities/libraries that exist for TF that still do not exist for PyTorch (AFAIK). I doubt that there is a functionality for PyTorch that doesn't also exist for TF or Keras.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-12T16:44:25.200Z
Answers.LastActivityDate: 2020-02-12T16:50:08.983Z
Answers.LastEditDate: 2020-02-12T16:50:08.983Z
Answers.UserDisplayName: nbro
Body: <p>I've been using PyTorch to do research  for a while and it seems to be quite easy to implement new things with. Also, it is easy to learn and I didn't have any problem with following other researchers code so far.</p>
  
  <p>However, I wonder whether TensorFlow has any advantage over PyTorch. The only advantage I know is, it's slightly faster than PyTorch. </p>
  
  <p>In general, does TensorFlow have any concrete advantages over PyTorch apart from performance, in particular for research purposes?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-12T13:19:29.463Z
Comments.Text: In my company we do it all in Keras and TF 1.x, and every single time I had to debug an operation embedded in the graph (say loss function or custom layers...)  it was a real pain. I don't know if TF 2.x fixes that. The only thing I find interesting about TF approach is the cheap TPUs for training.
Comments.UserDisplayName: JVGD
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-26T14:17:45.907Z
Comments.Text: [Here](https://ai.stackexchange.com/q/3402/2444) is a related question.
Comments.UserDisplayName: nbro
Tags: <deep-learning><tensorflow><comparison><research><pytorch>
Title: Is there a reason to use TensorFlow over PyTorch for research purposes?
UserDisplayName: SpiderRico
ThreadText: # Is there a reason to use TensorFlow over PyTorch for research purposes?
  
  (Asked by: username_0 on 2020-02-12)
  
  I've been using PyTorch to do research for a while and it seems to be quite easy to implement new things with. Also, it is easy to learn and I didn't have any problem with following other researchers code so far.
  
  However, I wonder whether TensorFlow has any advantage over PyTorch. The only advantage I know is, it's slightly faster than PyTorch.
  
  In general, does TensorFlow have any concrete advantages over PyTorch apart from performance, in particular for research purposes?
  
  **Tags:** deep-learning, tensorflow, comparison, research, pytorch
  > **Comments:**
  > **username_1**: In my company we do it all in Keras and TF 1.x, and every single time I had to debug an operation embedded in the graph (say loss function or custom layers...)  it was a real pain. I don't know if TF 2.x fixes that. The only thing I find interesting about TF approach is the cheap TPUs for training.  
  > **username_2**: [Here](https://ai.stackexchange.com/q/3402/2444) is a related question.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-02-12. Score: 4 | Accepted answer
  
  In the past, I have used TensorFlow (1 and 2), Keras and PyTorch, so I will give an answer based on my experience. Currently, I use TF 2 and Keras (the version shipped with TF 2).
  
  In my (but not only) opinion, TF 1 is really ugly and painful, given that it involves sessions, placeholders and, in general, you need to define the computational graph before executing anything (even the simplest programs). With TF 2, you don't need sessions and placeholders anymore, and this is a very big improvement because you don't need to think that you first need to define a computational graph and then feed it with the input. Essentially, in TF 2, you can write TF code and you can almost be sure that your TF 2 code will look like any other Python code.
  
  TF and Keras have some bugs, but I think that also PyTorch must have some bugs (even though I don't remember having encountered them).
  
  TF comes with [TensorBoard](https://www.tensorflow.org/tensorboard). You can also easily use TensorBoard from Keras. About one year ago, I had written a [blog post](https://nbro.github.io/blogging/2019/01/06/an-example-of-how-to-use-visualdl-with-pytorch/) about visualization tools for PyTorch. At the time, the tools didn't seem as developed as TensorBoard, but there were already a few options.
  
  Debugging in TF 2 isn't still perfect, but I would say that it has improved with respect to TF 1 (mainly because there is less boilerplate code). To debug in TF 2.0, I mainly use [`tf.print`](https://www.tensorflow.org/api_docs/python/tf/print) (which behaves similarly to Python's `print` function), but there may be more advanced tools (e.g. I think there's a TF debugging plugin for PyCharm), even though I've never used them. TensorBoard could also be used as a debugging tool (for example, to understand how your models are learning, etc).
  
  The simplicity of PyTorch is comparable to that of Keras. TF now comes with an integrated version of Keras, which is optimized for TF, so TF code can look as simple as Keras code.
  
  In general, my impression is that, if you need to, TF provides more flexibility, but it's been a while since I used PyTorch. Furthermore, with TF 2.0, the code looks simpler, more consistent and the framework is better organized. On the other hand, PyTorch may still be easier to learn (because it doesn't have the past of TF, i.e. there are still many TF code that uses sessions, etc.).
  
  Both TF and PyTorch are supported by big companies (respectively, Google and Facebook), but TF is more mature and there are functionalities/libraries that exist for TF that still do not exist for PyTorch (AFAIK). I doubt that there is a functionality for PyTorch that doesn't also exist for TF or Keras.
  
  
  ---
  
  