{"id":167476,"date":"2023-03-30T09:13:29","date_gmt":"2023-03-30T08:13:29","guid":{"rendered":"https:\/\/liora.io\/en\/?p=167476"},"modified":"2026-08-07T10:27:20","modified_gmt":"2026-08-07T09:27:20","slug":"pytorch-all-about-this-framework","status":"publish","type":"post","link":"https:\/\/liora.io\/en\/pytorch-all-about-this-framework","title":{"rendered":"PyTorch: all about Facebook&#8217;s Deep Learning framework"},"content":{"rendered":"\n<p><strong>The Python language being one of the most used, it contains a lot of frameworks, and many of them are developed exclusively for Data Science. In this article, we will talk about one of them in detail : PyTorch.<\/strong><\/p>\n\n\n<p>In the last few years, the popularity of Data Science has been growing steadily over and this has led to an explosion in the resources available to programmers: it is no longer necessary to code by hand. Programming environments such as <strong>Pytorch<\/strong>, known as &#8220;frameworks&#8221;, allow complex models to be used in just a few lines.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"whats-the-origin-of-pytorch\">What\u2019s the origin of PyTorch ?<\/h3>\n\n\n<p>Frameworks are made to <strong>make programming easier<\/strong>. They are usually developed in &#8220;<strong>open source<\/strong>&#8220;, which means that the code is available and editable by all, which allows reliability, transparency and continuous maintenance.<\/p>\n\n\n<p>PyTorch is no exception to this rule. Based on the former Torch library, <strong>PyTorch<\/strong> was officially launched in 2016 by a team from <strong>Facebook&#8217;s research lab<\/strong>, and has been developed in open source ever since. The goal of this framework is to <strong>enable the implementation and training of Deep Learning<\/strong> models in a simple and efficient way. Its merger in 2018 with <strong>Caffe2<\/strong> (another Python framework) has further improved its performance.<\/p>\n\n\n<p>Pytorch is now used by 17% of Python developers (<a href=\"https:\/\/www.jetbrains.com\/lp\/python-developers-survey-2020\/\"><strong>Python<\/strong> <strong>Foundation 2020 study<\/strong><\/a>), and in many companies like Tesla, Uber etc.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"why-use-pytorch\">Why use PyTorch?<\/h3>\n\n\n<p>PyTorch is a new machine learning library, but it has a lot of <strong>manuals and tutorials<\/strong> where you can find examples. It also has a community that is growing by leaps and bounds.<\/p>\n\n\n<p>PyTorch has a very <strong>simple interface<\/strong> for creating neural networks although it is necessary to work directly with tensors without needing a higher level library like Keras for Theano or Tensorflow.<\/p>\n\n\n<p>Unlike other machine learning tools such as Tensorflow, <strong>PyTorch works with dynamic<\/strong> rather than static graphs. This means that at runtime, features can be changed and the calculation of gradients will vary with them. In contrast, in Tensorflow, one must first define the computational graph and then use the session to compute the tensor results, which <strong>makes debugging the code more difficult<\/strong> and implementation more tedious.<\/p>\n\n\n<p>PyTorch is compatible with graphics cards (GPUs). It uses CUDA internally, an API that connects the CPU to the GPU which has been developed by<strong> NVIDIA<\/strong>.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"advantages-of-pytorch\">Advantages of PyTorch<\/h3>\n\n\n<p>PyTorch has many advantages, here are the main ones:<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"1-pytorch-and-python\"><strong>\u00a0\u00a01. PyTorch and Python<\/strong><\/h2>\n\n\n<p>Most of the work related to Machine Learning and Artificial Intelligence is done using Python. However, <strong>PyTorch and Python are related<\/strong>, which means that Python developers should feel more comfortable coding with PyTorch than with other Deep Learning frameworks.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"2-easy-to-learn\"><strong>\u00a0\u00a0\u00a02. Easy to learn<\/strong><\/h2>\n\n\n<p>Like the Python language, PyTorch is considered relatively <strong>easier to learn<\/strong> compared to other frameworks. The main reason is due to its simple and intuitive syntax.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"3-strong-community\"><strong>\u00a03. Strong community<\/strong><\/h2>\n\n\n<p>Although PyTorch is a relatively new framework, it has developed a dedicated community of developers very quickly. Moreover, PyTorch documentation is very <strong>organized and useful<\/strong> for beginners.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"4-easy-debugging\"><strong>4. Easy debugging<\/strong><\/h2>\n\n\n<p>PyTorch is deeply integrated with Python, so much so that many Python debugging tools can be easily used with it.<\/p>\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex is-content-justification-center wp-container-core-buttons-is-layout-5ee10de4\" style=\"margin-top:32px;margin-bottom:32px\"><div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/en\/courses\/data-ai\/data-scientist\">Become an expert with PyTorch<\/a><\/div><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"pytorch-vs-keras-vs-tensorflow-what-are-the-differences\">Pytorch vs Keras vs Tensorflow : What are the differences ?<\/h3>\n\n\n<p>It seems difficult to introduce PyTorch without mentioning the other alternatives, all created within a few years of each other with the same goal but different methods.<\/p>\n\n\n<p><strong>Keras<\/strong> was developed in March 2015 by Fran\u00e7ois Chollet, a researcher at Google. Keras quickly gained popularity thanks to <strong>its easy-to-use API<\/strong>, which is heavily inspired by <strong>scikit-learn<\/strong>, the standard <strong><a href=\"https:\/\/liora.io\/en\/machine-learning-what-is-it-and-why-does-it-change-the-world\">Machine Learning<\/a><\/strong> library in Python.<\/p>\n\n\n<p>A few months later, in November 2015, Google released a <strong>first version of <\/strong><a href=\"https:\/\/liora.io\/en\/tensor-flow-all-about-googles-machine-learning-framework\"><strong>TensorFlow<\/strong><\/a>, which quickly became the reference framework for <strong><a href=\"https:\/\/liora.io\/en\/all-about-deep-learning\">Deep Learning<\/a><\/strong>, as it allows you to use Keras. Tensorflow also <strong>developed a number of Deep Learning<\/strong> features that researchers needed to easily create complex neural networks.<\/p>\n\n\n<p><strong>Keras was therefore very simple to use<\/strong>, but lacked some of the &#8220;low-level&#8221; features or customizations needed for state-of-the-art models. But it didn&#8217;t look like the usual Python style and had very <strong>complicated documentation<\/strong> for beginners<\/p>\n\n\n<p>PyTorch solved these problems by <strong>creating an API <\/strong>that is both accessible and easy to customize, allowing the creation of new types of networks, optimizers and architectures. However, recent developments in these frameworks have <strong>brought the way they work much closer together<\/strong>.<\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"pytorch-and-deep-learning-does-it-work-together\">PyTorch and Deep Learning, does it work together ?<\/h3>\n\n\n<p>We have talked about the complexity of models and networks without mentioning the execution speed of algorithms. Indeed, PyTorch is designed to <strong>minimize this time<\/strong> and to <strong>make the best use of the hardware specificities<\/strong>.<\/p>\n\n\n<p>PyTorch represents data as multidimensional arrays, similar to NumPy arrays, called &#8220;tensors&#8221;. The tensors <strong>store the inputs<\/strong> of the neural network, the parameters of the hidden layers and the outputs. From these tensors, PyTorch can perform, in a <strong>hidden and efficient way<\/strong>, 4 steps to train the network:<\/p>\n\n\n<ul class=\"wp-block-list\">\n<li aria-level=\"1\">Assemble a graph from the tensors of the neural network, which allows a <strong>dynamic structure<\/strong>, it is possible to modify the <strong>neural network<\/strong> (number of nodes, connections between them&#8230;) during training.<\/li>\n<li aria-level=\"1\">Perform the predictions of the network (forward pass)<\/li>\n<li aria-level=\"1\">Compute the loss or error compared to the predictions<\/li>\n<li aria-level=\"1\">Go through the network in the opposite way : &#8220;<strong>backpropagation<\/strong>&#8220;, and adjust the tensors so that the network makes <strong>more accurate predictions<\/strong> based on the calculated loss\/error.<\/li>\n<\/ul>\n\n\n<p>This function of PyTorch called &#8220;Autograd&#8221; is very optimized, and is compatible with the use of <strong>GPUs<\/strong> and <strong>data parallelism<\/strong>, which accelerates calculations considerably. Moreover, it allows for use on all clouds, while Tensorflow is only optimized for GoogleCloud and its TPUs (Tensor Processing Unit)..<\/p>\n\n\n<p>Recently, and in partnership with AWS (Amazon Web Services), Pytorch has released 2 new features. The first one, named TorchServe, effectively manages the deployment of already trained neural networks. The second one, <strong>TorchElastic<\/strong>, allows the use of Pytorch on <strong>Kubernetes clusters<\/strong> while being resistant to failures.<\/p>\n\n\n<p>These 3 frameworks have their <strong>own specificity<\/strong>. In particular PyTorch which is mainly adapted for complex and deep neural networks. To learn to use the framework, we offer <strong><a href=\"\/en\/courses\/data-ai\/data-scientist\">Data Scientist training<\/a><\/strong> with <strong>dedicated modules to Deep Learning<\/strong> with PyTorch.<\/p>\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex is-content-justification-center wp-container-core-buttons-is-layout-5ee10de4\" style=\"margin-top:32px;margin-bottom:32px\"><div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/liora.io\/en\/courses\/data-ai\/machine-learning-engineer\">Find out more about our Data Science courses<\/a><\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>The Python language being one of the most used, it contains a lot of frameworks, and many of them are developed exclusively for Data Science. In this article, we will talk about one of them in detail : PyTorch. In the last few years, the popularity of Data Science has been growing steadily over and [&hellip;]<\/p>\n","protected":false},"author":79,"featured_media":167477,"comment_status":"open","ping_status":"open","sticky":false,"template":"elementor_theme","format":"standard","meta":{"_acf_changed":false,"editor_notices":[],"footnotes":""},"categories":[2433],"class_list":["post-167476","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-ai"],"acf":[],"_links":{"self":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/167476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/users\/79"}],"replies":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/comments?post=167476"}],"version-history":[{"count":4,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/167476\/revisions"}],"predecessor-version":[{"id":209768,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/167476\/revisions\/209768"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/media\/167477"}],"wp:attachment":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/media?parent=167476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/categories?post=167476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}