Day 8 - Tensors

Nischal BaidarNischal Baidar
2 min read

A tensor is a multi-dimensional array of data. Just like a scalar is a single number, a vector is a one-dimensional array of numbers, and a matrix is a two-dimensional array, a tensor extends this concept to higher dimensions. Tensors are used to represent data and parameters in machine learning models.

Types of Tensors ๐Ÿ“

  1. Scalar (0-D Tensor) ๐Ÿ†

    • Description: A single number.

    • Example: 7, 3.14

    • Usage: Represents constants or single data points in computations.

  2. Vector (1-D Tensor) ๐Ÿ“ˆ

    • Description: A one-dimensional array of numbers.

    • Example: [1, 2, 3]

    • Usage: Used to represent data features or model parameters in a list.

  3. Matrix (2-D Tensor) ๐Ÿ“‰

    • Description: A two-dimensional array of numbers.

    • Example: [[1, 2], [3, 4]]

    • Usage: Commonly used to represent datasets, transformation matrices, and more.

  4. 3-D Tensor ๐Ÿ“ฆ

    • Description: A three-dimensional array of numbers.

    • Example: [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]

    • Usage: Often used in image processing where each image has multiple color channels (RGB).

  5. 4-D Tensor and Higher ๐Ÿ“

    • Description: An array with four or more dimensions.

    • Example: In deep learning, a 4-D tensor might represent a batch of images, where dimensions correspond to batch size, image height, image width, and number of channels.

    • Usage: Utilized in complex models, such as those handling batches of multi-dimensional data.

Why Tensors are Essential in Machine Learning? ๐Ÿš€

  • Data Representation ๐Ÿ—ƒ๏ธ: Simplifies data processing and learning.

  • Efficient Computations โš™๏ธ: Enables fast, GPU-optimized operations.

  • Model Building ๐Ÿ—๏ธ: Defines model parameters and layers.

  • Versatility ๐ŸŒ: Handles diverse data types and complex models.

0
Subscribe to my newsletter

Read articles from Nischal Baidar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nischal Baidar
Nischal Baidar