[Service Development Team, Hyun-Jun Han]
Introduction
Tensorflow and PyTorch are the most popular libraries for machine learning. Developers who develop AI services or researchers who study models often face difficulties in selecting a library at the beginning. Also, there are a lot of changes as the library version goes up, so we want to provide a guide in choosing a library.
Google – Tensorflow
Tensorflow was created by the Google Brain Team for research and product development, and compatible languages include C++, Python, JavaScript, and Swift. After the 1.x and 2.x versions, the stable version 2.4 has been released. The difference between 1.x and 2.x versions is that the use of Session is almost unnecessary, declaration minimization and Keras are internalized. In addition, there was a speed improvement through functionalization. There are many other changes, including Tensorflow-Lite - mobile/embedding support, TensorflowJS - browser, Node.js support, etc. However, this change caused the inconvenience of having to change the code of the user who was already using it. Of course, it supported the conversion module, but there were also bugs, so many users left.
Facebook – PyTorch
PyTorch is a library developed by Facebook AI Research Lab for research purposes. Compatible languages include C++ and Python. In the beginning, the community was relatively small, but it has grown explosively and has overtaken Tensorflow in conference papers. The reason why users in many research fields have moved to PyTorch is that it can use dynamic graphs. This is because it was advantageous for RNN, CNN, and GAN research because it was possible to compare data by replacing data in real time through dynamic graphs. Also, I think the code has grown significantly as the difficulty is relatively easy compared to Tensorflow.
Tensorflow VS PyTorch
This is a graph of papers for each conference in the field of artificial intelligence. It can be seen that the trend of PyTorch's papers expressed as solid lines is higher than Tensorflow expressed with dotted lines. I think PyTorch is a bit more advantageous when it comes to researching conference papers.
Tensorflow | PyTorch | |
Github Repository | 108k | 68k |
visualization | Tensorboard | Visdom Tensorboard [1.2 Pytorch] |
Graph Definition | static graph, Dynamic graph [tensorflow 2.0] | dynamic graph |
debugging | tfdbg | Python standard debuggers |
model deployment | Tensorflow Serving | TorchServe |
Mobile Support | O | O |
When comparing each library functionally, it seems that they tend to be more and more identical as the versions go up. There were many differences between the two libraries at first, but over time the differences have diminished significantly as they have had good features from each other.
Nevertheless, the limitations of both libraries still exist. Tensorflow is still relatively difficult to construct dynamic graphs, and debugging also requires training. PyTorch has few open sources yet, it is difficult to support other environments, it is difficult to deploy, and above all, it is difficult to meet the various constraints required by the industry. Referring to these points, it will be helpful in selecting a library if you proceed with the project after clearly understanding whether the focus is for research purposes or to provide products and services.
conclusion
Tensorflow – for product building purposes. Browser, Node.js, Embeded, Mobile environment support. Easy to deploy. NLP, etc.
Pytorch – for research purposes. An environment familiar with Python. Relatively low difficulty. RNNs, CNNs, GANs, etc.
Both Tensorflow and Pytorch are powerful ML libraries. If you select a library according to your purpose, I think more productive research/development will be made.
Reference
https://towardsdatascience.com/pytorch-vs-tensorflow-2021-d403504d7bc3
https://builtin.com/data-science/pytorch-vs-tensorflow
https://www.imaginarycloud.com/blog/pytorch-vs-tensorflow/