INDEX: LINEAR-ALGEBRA-FOR-ML / MATH-LA-11READING_TIME: 8 mins

4.2 Special Matrices: The Identity Matrix

In normal arithmetic, we have the number 11. The number 11 is special because multiplying any number by it leaves that number completely unchanged:

5×1=55 \times 1 = 5 12.5×1=12.5-12.5 \times 1 = -12.5

In matrix algebra, we have a similar concept called the Identity Matrix, denoted by the letter II. It acts as the number "1" of the matrix world.


1. Defining the Identity Matrix

The Identity matrix is always a square matrix (it has the same number of rows and columns). It features:

  • Ones (11) along the main diagonal (running from top-left to bottom-right).
  • Zeros (00) everywhere else.

Depending on the dimension, here is how we write it:

I2=[1001]I_2 = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} I3=[100010001]I_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}


2. Geometric Intuition: The "Do Nothing" Transformation

Let's look at the Identity matrix columns to see what it does geometrically:

  • Column 1 is [10]\begin{bmatrix} 1 \\ 0 \end{bmatrix}: This means basis vector i^\hat{i} lands at (1,0)(1, 0) (it doesn't move).
  • Column 2 is [01]\begin{bmatrix} 0 \\ 1 \end{bmatrix}: This means basis vector j^\hat{j} lands at (0,1)(0, 1) (it doesn't move).

Because the basis vectors do not budge, the Identity transformation leaves the entire coordinate space completely untouched. Every single vector in the universe stays exactly where it was.


3. Algebraic Property: Neutral Element

If you multiply any matrix AA by the Identity matrix II, the result is exactly AA.

AI=AA \cdot I = A IA=AI \cdot A = A

Let's test this with a 2×22 \times 2 example:

A=[3512],I=[1001]A = \begin{bmatrix} 3 & 5 \\ 1 & -2 \end{bmatrix}, \quad I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}

Let's compute AIAI:

  • Row 1 of A ×\times Col 1 of I: (3×1)+(5×0)=3(3 \times 1) + (5 \times 0) = 3
  • Row 1 of A ×\times Col 2 of I: (3×0)+(5×1)=5(3 \times 0) + (5 \times 1) = 5
  • Row 2 of A ×\times Col 1 of I: (1×1)+(2×0)=1(1 \times 1) + (-2 \times 0) = 1
  • Row 2 of A ×\times Col 2 of I: (1×0)+(2×1)=2(1 \times 0) + (-2 \times 1) = -2

AI=[3512]=AAI = \begin{bmatrix} 3 & 5 \\ 1 & -2 \end{bmatrix} = A

It works exactly as advertised!


4. Machine Learning Application: Initialization & Regularization

Why is the Identity matrix important in Machine Learning?

I. Identity Initialization

In deep learning, particularly for recurrent networks (RNNs), we initialize weight matrices. If we initialize weights to zero, neurons learn nothing. If we initialize them too large, values explode. A common technique is initializing weight matrices close to the Identity Matrix. This guarantees that, initially, information flows through network layers without being distorted or shrunk.

II. Ridge Regression (L2L_2 Regularization)

In linear regression, if features are highly correlated, the matrix XTXX^T X is singular (non-invertible). To fix this, we add a small diagonal term using the identity matrix:

(XTX+λI)(X^T X + \lambda I)

This adds a tiny number (λ\lambda) to the diagonal elements, guaranteeing the matrix is non-singular and invertible, which makes the model numerically stable.


5. Check Your Understanding

Quiz / Test Your Knowledge

What is the result of multiplying the vector v = [4, -7]^T by the identity matrix I_2?