Study Tensors and easy methods to use them in one of the crucial famous machine learning libraries, pytorch
Considered one of most significant libraries within the Deep Learning field (and inclusively, where ChatGPT was built upon) is pytorch
. Together with the Tensorflow framework, pytorch
is one of the crucial famous neural network training frameworks available for software developers and data scientists. Other than its usability and straightforward API, it excels in flexibility and memory usage, making it extremely fast in multi-dimensional calculus (one among the most important components behind backpropagation, the vital technique that’s used to optimize Neural Network’s weights) — these details make it one of the crucial wanted libraries by firms on the subject of construct Deep Learning models.
On this blog post, we’re going to ascertain some basic operations using pytorch
and understand how we will work with the tensor
object! Tensors are mathematical representations of knowledge which can be commonly addressed by different names:
- 1 element Tensor: commonly called the scalar, consists of a single mathematical value.
- 1-Dimensional Tensor: consisting of n examples, they’re normally called 1-D vectors and stores different mathematical elements in a single dimension.
- 2-Dimensional Tensors: commonly called matrices, are capable of store data in two dimensions. Consider a traditional SQL table or an excel spreadsheet.
- 3-Dimensional Tensors and beyond: Data organized with this dimensionality are normally harder to visualise and are generally called n-dimensional tensors.
With this small introduction on mathematical concepts, let’s explore easy methods to use pytorch
in Python!
As we’ve described, the tensor object is a mathematical generalization of n-dimensional objects that may expand to virtually any dimension. Although within the context of Deep Learning, tensors
are generally multidimensional, we also can create single element tensors (normally called scalars) using torch
(although named pytorch
, we use the name torch
to govern the library in Python).