Tensors in Machine Learning: The Clearest Explanation You’ll Ever Read (ML Chapter-1)
Last Updated on November 25, 2025 by Editorial Team
Author(s): Sayan Chowdhury
Originally published on Towards AI.

If you’ve ever opened a machine learning textbook or played with a deep-learning framework, you’ve seen the word tensor pop up everywhere. It sounds intimidating. It feels mathematical. And everyone seems to assume you already know what it means.
But here’s the good news:
A tensor is much simpler than people make it sound.
Why Are Tensors Everywhere in ML?
All machine learning systems work with numbers. Whether your input is:
an image, a chunk of text, an audio waveform, a row from your dataset, or even a video…your model only sees numbers. And those numbers must be stored in some structure.
That structure is a tensor.
What Exactly Is a Tensor?
A tensor is a structured container for numbers. Its structure depends on how many dimensions it has.
This “number of dimensions” is also called:
- Rank
- Order
- Axes
All mean the same thing.
1. Scalars (Rank 0)
A scalar is just one number.
#Examples:
Temperature= 31.2,
Learning_rate= 0.001
Loss_value= 2.43
2. Vectors (Rank 1)
A vector is a 1D list of numbers. It has length, but no width or height.
Examples: A 3D point: [2, 5, 7] , A color pixel: [120, 200, 45] , A word embedding (e.g., 300 numbers)
#A word like “king” can be represented as a 300-dimensional vector:
[0.12, -0.53, 0.91, ..., 0.04]
3. Matrices (Rank 2)
A matrix is a 2D grid of numbers: rows and columns.
Examples: grayscale image (28 × 28), confusion matrix, weight matrix for a neural network layer
#3x3 Image
[ 1 2 3 ]
[ 4 5 6 ]
[ 7 8 9 ]
4. Tensors (Rank 3 and above)
Once you go beyond 2D, you’re in tensor territory.
A tensor is simply: a vector of matrices, or a matrix of matrices, or a stacked collection of grids, or even a stack of stacks
# Rank 3 Tensor Example: RGB Image
Height × Width × Channels = 224 × 224 × 3
# Rank 4 Tensor Example: Batch of Images
Batch × Height × Width × Channels = 32 × 224 × 224 × 3
# Rank 5 Tensor Example: Video
Frames × Height × Width × Channels × Batch= 32 videos × 60 frames × 128 × 128 × 3
The shape tells you how many “directions” the data extends into.

If you remember one idea from this article:
A tensor is just a structured container for numbers.
Different ranks represent different shapes, and ML models learn by transforming these tensors step by step.
Once you see tensors as nothing more than organized numbers, the entire Machine learning ecosystem becomes far easier to understand.
Thanks for reading. If you’d like more clear and practical ML content, hit the follow button ➕.
Your support helps me keep creating useful Machine-learning explainers 💗😊
Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.
Published via Towards AI
Towards AI Academy
We Build Enterprise-Grade AI. We'll Teach You to Master It Too.
15 engineers. 100,000+ students. Towards AI Academy teaches what actually survives production.
Start free — no commitment:
→ 6-Day Agentic AI Engineering Email Guide — one practical lesson per day
→ Agents Architecture Cheatsheet — 3 years of architecture decisions in 6 pages
Our courses:
→ AI Engineering Certification — 90+ lessons from project selection to deployed product. The most comprehensive practical LLM course out there.
→ Agent Engineering Course — Hands on with production agent architectures, memory, routing, and eval frameworks — built from real enterprise engagements.
→ AI for Work — Understand, evaluate, and apply AI for complex work tasks.
Note: Article content contains the views of the contributing authors and not Towards AI.