Elements of a PyTorch Deep Learning Model (1)- Tensors, Autograd and Optimization

Explore the key elements of PyTorch deep learning models, including tensors, autograd for gradient computation, and optimization techniques like SGD and Adagrad.

Rahul S
11 min readMay 19, 2023
src: https://www.learnpytorch.io/01_pytorch_workflow/

TENSOR AND COMMON TENSOR OPERATIONS

In PyTorch, a tensor is a multi-dimensional array that can represent scalars, vectors, matrices, or higher-dimensional data. Tensor refers to the generalization of vectors and matrices to an arbitrary number of dimensions. torch module provides extensive library of operations on them.

Each tensor in PyTorch has three attributes that uniquely identify it:

1. Data: The data attribute refers to the actual numerical values stored in the tensor. It represents the content of the tensor and defines its shape. The data can be stored in various data types, such as floats (`torch.float32`), integers (`torch.int64`), or booleans (`torch.bool`), depending on the requirements of the application.

2. Shape: The shape attribute describes the dimensions of the tensor. It is a tuple of integers that specifies the size of each dimension. For example, a 2D tensor with shape `(3, 4)` represents a matrix…

--

--