PyTorch - Introduction


Advertisements

PyTorch is defined as an open source machine learning library for Python. It is used for applications such as natural language processing. It is initially developed by Facebook artificial-intelligence research group, and Uber’s Pyro software for probabilistic programming which is built on it.

Originally, PyTorch was developed by Hugh Perkins as a Python wrapper for the LusJIT based on Torch framework. There are two PyTorch variants.

PyTorch redesigns and implements Torch in Python while sharing the same core C libraries for the backend code. PyTorch developers tuned this back-end code to run Python efficiently. They also kept the GPU based hardware acceleration as well as the extensibility features that made Lua-based Torch.

Features

The major features of PyTorch are mentioned below −

Easy Interface − PyTorch offers easy to use API; hence it is considered to be very simple to operate and runs on Python. The code execution in this framework is quite easy.

Python usage − This library is considered to be Pythonic which smoothly integrates with the Python data science stack. Thus, it can leverage all the services and functionalities offered by the Python environment.

Computational graphs − PyTorch provides an excellent platform which offers dynamic computational graphs. Thus a user can change them during runtime. This is highly useful when a developer has no idea of how much memory is required for creating a neural network model.

PyTorch is known for having three levels of abstraction as given below −

  • Tensor − Imperative n-dimensional array which runs on GPU.

  • Variable − Node in computational graph. This stores data and gradient.

  • Module − Neural network layer which will store state or learnable weights.

Advantages of PyTorch

The following are the advantages of PyTorch −

  • It is easy to debug and understand the code.

  • It includes many layers as Torch.

  • It includes lot of loss functions.

  • It can be considered as NumPy extension to GPUs.

  • It allows building networks whose structure is dependent on computation itself.

TensorFlow vs. PyTorch

We shall look into the major differences between TensorFlow and PyTorch below −

PyTorch TensorFlow

PyTorch is closely related to the lua-based Torch framework which is actively used in Facebook.

TensorFlow is developed by Google Brain and actively used at Google.

PyTorch is relatively new compared to other competitive technologies.

TensorFlow is not new and is considered as a to-go tool by many researchers and industry professionals.

PyTorch includes everything in imperative and dynamic manner.

TensorFlow includes static and dynamic graphs as a combination.

Computation graph in PyTorch is defined during runtime.

TensorFlow do not include any run time option.

PyTorch includes deployment featured for mobile and embedded frameworks.

TensorFlow works better for embedded frameworks.

Advertisements