Learn about tensors and how to use them in one of the most famous machine learning libraries, pytorch.
One of the most important libraries in the field of deep learning (and even where ChatGPT was developed) is pytorch
. Together with the Tensorflow framework, pytorch
is one of the most famous neural network training frameworks available for software developers and data scientists. In addition to its usability and simple API, it excels in flexibility and memory usage, making it extremely fast in multidimensional calculation (one of the main components behind backpropagation, the important technique used to optimize Neural Network weights) . It is one of the most sought after libraries by companies when it comes to building deep learning models.
In this blog post, we are going to check some basic operations using pytorch
and understand how we can work with the tensor
object! Tensors are mathematical representations of data that commonly go by different names:
- 1-element tensor: commonly called scalar, it is made up of a single mathematical value.
- One-dimensional tensor: composed of north For example, they are typically called 1-D vectors and store different mathematical elements in a single dimension.
- Two-dimensional tensors: commonly called matrices, they are capable of storing data in two dimensions. Think of a regular SQL table or Excel spreadsheet.
- 3D Tensors and More: Data organized with this dimensionality is typically more difficult to visualize and is usually called n-dimensional tensioners.
With this short introduction to mathematical concepts, let’s explore how to use pytorch
in Python!
As we have described, the tensor object is a mathematical generalization of n-dimensional Objects that can expand to practically any dimension. Although in the context of deep learning, tensors
are generally multidimensional, we can also create single element tensors (usually called scalars) using torch
(although named pytorch
we use the name torch
to manipulate the library in Python).