Safekipedia
Deep learning softwareFacebook softwareFree science softwareFree software programmed in C

PyTorch

Adapted from Wikipedia ยท Discoverer experience

PyTorch logo white

PyTorch is an open-source deep learning library originally created by Meta Platforms and now supported by the Linux Foundation. It is the successor to Torch and offers a high-level API that makes building and training models much easier. With PyTorch, complex tasks like training deep learning models can be done in just a few lines of code.

PyTorch works with a special kind of data called a tensor, similar to tools used in NumPy. It uses something called a reversed automatic differentiation system, named Autograd, to help improve models during training. This system creates a map of all the steps used in training, which allows the computer to adjust the model effectively.

As of 2025, PyTorch is one of the most popular deep learning libraries, used alongside others like TensorFlow and Keras. It can be installed using tools such as Anaconda. Many important technologies rely on PyTorch, including ChatGPT, Tesla Autopilot, Uber's Pyro, Hugging Face's Transformers, and Catalyst.

History

In 2001, a machine-learning library called Torch was created. It supported many methods, including neural networks and support vector machines. Around 2010, it was rewritten with a frontend in Lua. In 2016, some developers began working on a new version called PyTorch.

Meta Platforms started developing PyTorch, and in 2018, they merged another library called Caffe2 into it. In 2022, PyTorch became part of the independent PyTorch Foundation under the Linux Foundation. The latest major update, PyTorch 2.0, was released in March 2023, making code run faster on major cloud platforms.

PyTorch tensors

Main article: Tensor (machine learning)

PyTorch uses something called a Tensor (torch.Tensor) to store numbers in a multi-dimensional array. These Tensors work much like arrays in NumPy but can also use powerful graphics processing units (GPUs) to make calculations faster. PyTorch supports GPUs from companies like NVIDIA and also works with other GPU technologies such as AMD's ROCm and Apple's Metal Framework.

PyTorch neural networks

Main article: Neural network (machine learning)

PyTorch uses a special part called nn (or torch.nn) to help build neural networks. This part gives you many tools, like different layers and functions, to make smart models. You can create your own network by using these tools and telling the computer the steps it needs to follow. This makes it easier to teach computers new things!

Example

This example shows how PyTorch works with a simple program. It creates special number groups called tensors and performs basic math operations on them. The code also demonstrates how to build a small neural network using PyTorch's tools. Neural networks are like digital brains that can learn from data to solve problems.

This article is a child-friendly adaptation of the Wikipedia article on PyTorch, available under CC BY-SA 4.0.

Images from Wikimedia Commons. Tap any image to view credits and license.