Tensor Calculus Essentials
Introduction to Tensors
Beyond Vectors
You're already familiar with scalars (just a single number) and vectors (a list of numbers representing magnitude and direction). These are powerful tools, but sometimes they aren't enough to describe what's happening in the world.
Imagine stretching a rubber band. If you pull on one point, the material stretches not just in that direction, but in others as well. A single vector can't capture this complex, multi-directional response. We need a more general mathematical object. This is where tensors come in.
tensor
noun
A mathematical object that generalizes scalars, vectors, and matrices to higher dimensions. It's a container for data that can describe relationships between different sets of vectors.
Think of tensors as a way to organize information that has multiple directions or components associated with it. Just as a vector is an ordered list of numbers, a tensor is an ordered grid of numbers. The complexity of this grid is described by its rank (sometimes called order or degree).
All of deep learning is computations on tensors, which are generalizations of a matrix that can be indexed in more than 2 dimensions.
A Family of Ranks
The rank of a tensor tells you how many indices are needed to specify a particular element within it. This might sound abstract, but you've been using low-rank tensors all along.
Rank-0 Tensor: A Scalar A scalar is just a single number, like temperature () or mass ( kg). It has magnitude but no direction. It requires zero indices to identify it, because there's only one value.
Rank-1 Tensor: A Vector A vector is a list of numbers, like a velocity of m/s. It has both magnitude and direction. To specify an element, you need one index. For a vector , we might ask for the first component, , or the second, .
Rank-2 Tensor: A Matrix A matrix is a grid of numbers, arranged in rows and columns. A great example is stress in a material. To specify an element, you need two indices: one for the row and one for the column. For a matrix , we'd specify an element as .
Higher-Order Tensors Anything with a rank greater than 2 is a higher-order tensor. A rank-3 tensor is like a cube of numbers, requiring three indices () to locate an element. You can think of it as a collection of matrices stacked together, like pages in a book.
Working with Tensors
Basic operations on tensors are straightforward extensions of what you already know from vectors and matrices. Tensors are powerful because these simple rules allow us to manipulate complex, multi-dimensional data in a consistent way.
Addition and Subtraction: You can only add or subtract tensors of the same rank and same dimensions. The operation is done element-wise, just like with matrices.
Scalar Multiplication: To multiply a tensor by a scalar, you simply multiply every element of the tensor by that scalar. This scales the tensor without changing its rank or dimensions.
One new and crucial operation is tensor contraction. This process reduces the rank of a tensor. It involves summing over a pair of indices, one upper (contravariant) and one lower (covariant). For now, let's think of it as a generalization of the dot product.
For example, contracting a rank-2 tensor with a rank-1 tensor (a vector) involves summing over the shared index . The result is a new vector, .
This operation is fundamental in physics and engineering. It's how we apply transformations (like rotations, represented by a rank-2 tensor) to objects (like position vectors, rank-1 tensors) to find their new state.
Before we test your knowledge, let's review the key ideas with some flashcards.
Ready to check your understanding?
Which of the following best describes why a tensor might be needed instead of a simple vector?
What does the 'rank' of a tensor fundamentally define?
Understanding tensors as a generalization of scalars and vectors opens up a new way to describe the physical world and manage complex data. From here, you can explore how these objects transform and interact in more advanced scenarios.
