The fundamental data structure of deep learning — a multidimensional array of numbers that generalizes scalars, vectors, and matrices to arbitrary dimensions, and on which all neural network computations operate.
In Depth
In the context of deep learning, a tensor is a multidimensional array of numbers — the container that holds all data flowing through a neural network. A scalar (single number) is a 0-dimensional tensor. A vector is a 1D tensor. A matrix is a 2D tensor. An RGB image is a 3D tensor (height × width × 3 color channels). A batch of images is a 4D tensor (batch size × height × width × channels). Neural networks process data by performing mathematical operations — addition, multiplication, activation functions — on these tensors as they flow through layers.
The two dominant deep learning frameworks — TensorFlow (which takes its name from this concept) and PyTorch — are fundamentally tensor computation libraries. They provide optimized operations for creating, transforming, and computing on tensors, with automatic differentiation (the ability to compute gradients for backpropagation) built in. Critically, both frameworks execute tensor operations on GPUs, which are designed for massively parallel numerical computation — this is what makes training large neural networks feasible.
Understanding tensor shapes and dimensions is essential for deep learning practitioners. A common class of bugs involves shape mismatches — trying to multiply tensors with incompatible dimensions. Broadcasting rules govern how tensors of different shapes can interact. Reshaping, transposing, and slicing tensors are everyday operations. While the mathematical concept of a tensor in physics and differential geometry is more abstract, in deep learning the term simply means 'a multi-dimensional grid of numbers that flows through computational graphs.'
Tensors are multidimensional arrays of numbers — the universal data structure of deep learning. Every piece of data and every computation in neural networks is expressed as tensor operations.