What is the difference between a scalar, a vector, a matrix, and a tensor?

Quick Overview

Asks how scalars, vectors, matrices and tensors relate and differ, with examples from data science and machine learning. Tests understanding of axes and shapes, and of the different meanings of rank and dimension in linear algebra and in array libraries.

What is the difference between a scalar, a vector, a matrix, and a tensor?

Role: Data Scientist

Category: Statistics & Math

Difficulty: easy

Interview Round: Other

What is the difference between a scalar, a vector, a matrix, and a tensor? ```hint Count the indices Ask how many indices you need to pick out a single number from each object. ``` ### What a Strong Answer Covers - Each object described by the number of indices (axes) needed to address one entry - A concrete data science or machine learning example of each - The distinction between the number of axes and the size along each axis - How the machine learning meaning of "tensor" relates to the mathematical one ### Follow-up Questions - What is the shape of a batch of 32 RGB images of size 224 by 224, and how does it change between channels-last and channels-first layouts? - "Rank" means the number of axes for a tensor and something else for a matrix. What is the rank of a matrix, and can a 3 by 3 matrix have rank 1? - How does NumPy broadcasting combine a vector of shape `(3,)` with a matrix of shape `(4, 3)`? - Why does it matter whether a vector is stored with shape `(n,)`, `(n, 1)` or `(1, n)`?

Overview: Asks how scalars, vectors, matrices and tensors relate and differ, with examples from data science and machine learning. Tests understanding of axes and shapes, and of the different meanings of rank and dimension in linear algebra and in array libraries.

PracHub logo
General
Nov 25, 2026
easyData ScientistOtherStatistics & Math
0
0

What is the difference between a scalar, a vector, a matrix, and a tensor?

What a Strong Answer Covers Guidance

  • Each object described by the number of indices (axes) needed to address one entry
  • A concrete data science or machine learning example of each
  • The distinction between the number of axes and the size along each axis
  • How the machine learning meaning of "tensor" relates to the mathematical one

Follow-up Questions Guidance

  • What is the shape of a batch of 32 RGB images of size 224 by 224, and how does it change between channels-last and channels-first layouts?
  • "Rank" means the number of axes for a tensor and something else for a matrix. What is the rank of a matrix, and can a 3 by 3 matrix have rank 1?
  • How does NumPy broadcasting combine a vector of shape (3,) with a matrix of shape (4, 3) ?
  • Why does it matter whether a vector is stored with shape (n,) , (n, 1) or (1, n) ?