# Linear Algebra for AI and Machine Learning: Complete Roadmap

> This linear algebra learning roadmap is specifically designed for AI and ML practitioners. It covers everything from scalars and vectors to eigenvalues, SVD, matrix decomposition, norms, gradients, and Hessians, clearly explaining how each concept is applied in neural networks, PCA, recommendation systems, and Transformers.

- Source: https://www.waytoagi.com/en/kb/learning-path/linear-algebra-roadmap-for-ai-ml
- Original (Feishu, Chinese): https://waytoagi.feishu.cn/wiki/UTSCw2RD5i9W55kMiLZcM6HJnZF
- Updated: 2026-10-23

---

**Original post:** https://x.com/TheVixhal/status/2047362720199274713

![](https://www.waytoagi.com/api/kb-media/PLdibNEploTmEYx1hncchRC2nXe)

You don’t need a PhD in mathematics to do AI/ML. You just need enough linear algebra so that when you open a research paper or the PyTorch documentation, you’re not constantly lost in the fog. This roadmap tells you exactly what to learn, in the right order, and why each piece matters.

Let’s dive in.

---

# Why Linear Algebra?

Before listing the topics, let’s first explain why this subject is so important in ML.

At its core, everything in machine learning is numbers. Images are grids of numbers. After tokenization, text becomes numbers. Audio is a sequence of numbers sampled over time. Once all your data is converted into numbers, you need a systematic way to:

1. Store these numbers efficiently  
2. Perform fast computations on them  
3. Transform them from one form into another  

Linear algebra is the language designed precisely for these three tasks. Neural networks? At heart, they are matrix multiplications with a sprinkle of non-linear functions. Principal Component Analysis? It’s all about eigenvectors. Recommendation systems? Essentially matrix factorization. Word embeddings? They are vectors in high-dimensional space.

You cannot avoid it.

But you can absolutely understand it.

Let’s continue.

---

# Phase 1: Absolute Fundamentals

This is where everyone should start—even if you think you already know it. Trust me, revisiting these basics is always worth it.

## 1. Scalars, Vectors, Matrices, and Tensors

![](https://www.waytoagi.com/api/kb-media/VfFhbhUeOo0TNdxq7mYcofTPn8g)

Start here and understand their hierarchy.

- A **scalar** is a single number, e.g. 5 or 3.14.  
- A **vector** is a list of numbers, e.g. `[2, 4, 7]`.  
- A **matrix** is a 2D grid of numbers—essentially rows and columns.  
- A **tensor** is the general case: it can be 3D, 4D, or even higher. In deep learning, a batch of images is typically a 4D tensor (batch, channel, height, width).

Why it matters: Every PyTorch or TensorFlow program you write uses these concepts. If you don’t understand the shape of your data, you will waste a huge amount of time debugging.

## 2. Vector Operations

You need to master:

- Adding two vectors  
- Multiplying a vector by a scalar  
- Calculating the length (magnitude or norm) of a vector  
- Understanding its geometric meaning: a vector points in a certain direction in space  

The concept of *norm* appears repeatedly. L1 norm, L2 norm—they show up in regularization and loss functions.

## 3. Dot Product

This is extremely important. The dot product tells you how similar two vectors are. It is the foundation of cosine similarity, which is used everywhere—from search engines and recommendation systems to the attention mechanism in Transformers.

Practice until you can compute dot products with your eyes closed.

## 4. Matrix Operations

- Matrix addition  
- Scalar multiplication on matrices  
- Matrix multiplication (**the most critical one**)  
- Matrix transpose  

Matrix multiplication is **not** element-wise multiplication. This is where many beginners get stuck. Spend extra time here. Truly understand why the dimensions must match—why an `(m × n)` matrix can only be multiplied by an `(n × p)` matrix to produce an `(m × p)` result.

---

# Phase 2: The Building Blocks You’ll Actually Use

Now we move into the concepts that appear frequently in real ML code.

## 5. Special Matrices

You should be able to recognize these:

- **Identity matrix**: the number 1 of the matrix world  
- **Diagonal matrix**: non-zero values only on the main diagonal, everything else is 0  
- **Symmetric matrix**: equal to its own transpose  
- **Orthogonal matrix**: its transpose equals its inverse  

You will encounter them constantly in covariance matrices, attention masks, rotation operations, and more.

## 6. Matrix Inverse

Not every matrix has an inverse. A matrix without an inverse is called a singular matrix. In ML we rarely compute inverses directly because they are slow and numerically unstable. However, understanding the concept helps you read and interpret formulas in papers.

You need to know what a determinant is and why a determinant of 0 means the matrix has no inverse.

## 7. Linear Independence and Rank

If you have a set of vectors where some are essentially just repeated expressions of others, that’s what linear independence addresses. The rank of a matrix tells you how many truly independent directions it has.

This is crucial in PCA and helps you understand the common phrase “the data lies on a lower-dimensional manifold.” The concept of rank is what lies behind that fancy-sounding statement.

## 8. Span, Basis, and Subspaces

You can think of a **basis** as the smallest set of vectors needed to describe a space. Just like on a map, you only need two directions—“north-south” and “east-west”—to describe any location.

Once you understand this, embeddings will make much more sense. A 768-dimensional word vector essentially places each word into a 768-dimensional space, and that space is defined by a specific set of basis vectors.


---


# Phase 3: The Parts That Actually Drive ML

Now we’re entering the core concepts that truly power machine learning algorithms.


## 9. Eigenvalues and Eigenvectors

I know the name sounds intimidating, but the core idea is actually quite simple.

When you multiply a matrix by a vector, the vector is usually both stretched and rotated. Eigenvectors are the special vectors that are only stretched—they are never rotated. The amount of stretching is given by the eigenvalue.

Why should you care?

- PCA (dimensionality reduction) uses the eigenvectors of the covariance matrix
- PageRank (Google’s early algorithm) is essentially an eigenvector problem
- Spectral clustering relies on eigendecomposition
- Understanding neural network training stability often involves the eigenvalues of the Hessian

This section is worth investing serious time in. Go watch the 3Blue1Brown videos—they’re free and among the best resources on the internet.


## 10. Singular Value Decomposition (SVD)

If I had to pick just one concept from applied linear algebra that is most important for ML, I would choose SVD. It can decompose *any* matrix—regardless of shape or size—into three simpler matrices.

Its applications in ML include:

- Low-rank approximation (matrix compression)
- Recommender systems (many algorithms from the Netflix Prize era used it)
- Data denoising
- Understanding LoRA in large language model fine-tuning
- Computing the pseudoinverse

If eigendecomposition is cool, SVD is even cooler—because it works for all matrices, not just square ones.


## 11. Matrix Factorization

It’s closely related to SVD but broader in scope. The core idea is to break a large matrix into several smaller matrices whose product can approximately recover the original.

This is the foundation of collaborative filtering. It also appears in LoRA: we approximate weight updates as the product of two smaller matrices, dramatically reducing memory usage during fine-tuning.


## 12. Revisiting Norms

At this point, you should go deeper into norms:

- **L1 norm** (sum of absolute values): used in Lasso regression to encourage sparsity
- **L2 norm** (what we usually call “length”): common in Ridge regression and weight decay
- **Frobenius norm** for matrices
- **Infinity norm**

Each has different properties, and these properties directly affect optimization and regularization.


---


# Phase 4: The Bridge Between Calculus and Linear Algebra

This is where machine learning actually happens. Linear algebra alone cannot train models, but once combined with calculus, it becomes gradient descent.


## 13. Gradients and Jacobians

A **gradient** is a vector of partial derivatives. A **Jacobian** is a matrix of partial derivatives for vector-valued functions. Backpropagation in neural networks is essentially a series of Jacobian-vector products.

You don’t need to compute these by hand—PyTorch handles it via autograd—but you must understand what they represent.


## 14. The Hessian Matrix

This is the matrix of second-order derivatives. Its eigenvalues tell you about the curvature of the loss landscape. Second-order optimization methods like Newton’s method use it directly. In deep learning we usually rely on approximations, because computing the full Hessian is too expensive.


## 15. The Chain Rule in Matrix Form

Backprop is fundamentally the chain rule applied to matrices. Once you see this clearly, neural networks lose their mystery—they’re simply “calculus acting on matrices.”


---


# Phase 5: Advanced Topics (Learn as Needed)

Don’t put too much pressure on yourself before you actually encounter these. But knowing they exist is very helpful.


## 16. Tensor Operations

- **Broadcasting**: how NumPy and PyTorch handle shape mismatches
- **Einstein summation** (`einsum`): once you learn it, you’ll write much cleaner code
- Contractions and reshape operations

Seriously, `einsum` is basically a superpower. Go learn it.

## 17. Matrix Calculus Identities

When taking derivatives of common matrix expressions, there is a set of very classic identities. Having a cheat sheet ready is extremely useful. The free PDF *The Matrix Cookbook* has long been a classic reference.


## 18. Positive Definite Matrices

These matrices satisfy: for all non-zero vectors `x`, `x^T A x > 0`. They appear in:

- covariance matrices (always positive semi-definite)
- Gaussian processes
- convex optimization
- kernel methods


## 19. Numerical Linear Algebra

Once things scale up, how computers actually perform these calculations becomes important. Examples include:

- condition number — how stable your computations are
- LU and QR decompositions
- iterative methods

You only need to dive deep here if you're doing heavy optimization work or writing low-level linear algebra code yourself.


---


# Phase 6: Where Exactly Do They Appear in ML?

I map each topic to real ML tasks so you’ll have a clearer idea of where you can apply what you’ve learned.

**Linear Regression**: matrix multiplication, matrix inverse (or pseudoinverse obtained via SVD), and norms used for regularization.

**Logistic Regression and Neural Networks**: every layer performs matrix multiplication, gradients are obtained through the Jacobian, and norms are used for weight decay.

**PCA**: eigenvectors of the covariance matrix, or equivalently, the SVD of the data matrix.

**Transformers and Attention**: heavy use of matrix multiplication, dot products for attention scores, and softmax over those scores.

**Diffusion Models**: linear transformations combined with noise, and eigenvalue analysis appears in stability studies.

**Recommendation Systems**: matrix factorization, SVD, low-rank approximation.

**Graph Neural Networks**: adjacency matrices, Laplacian matrices, and eigendecomposition (spectral methods).

**LoRA Fine-tuning**: low-rank decomposition. You are essentially learning two small matrices A and B whose product approximates a weight update.


---


# How Should You Actually Learn This?

Just reading is not enough. You need to:

1. **Write code yourself.** Implement matrix multiplication from scratch in Python. Perform SVD on a small image and reconstruct it using fewer components. Watch dimensionality reduction happen right in front of you.

2. **Compute by hand first, then scale up.** Manually working through a `2x2` matrix calculation will teach you more than a hundred `np.matmul` calls.

3. **Visualize.** The 3Blue1Brown *Essence of Linear Algebra* series is essential viewing. I’m not joking — go watch it.

4. **Put it into projects.** Build a simple recommendation system, run PCA on a dataset, or train a small neural network from scratch. Theory without practice will be forgotten within a week.

5. **Read papers that contain mathematical formulas.** Start with simpler ones. Force yourself not to skip the equations. Write them down and try to understand what every symbol actually represents.


---


# Resources Truly Worth Your Time

- **3Blue1Brown’s Essence of Linear Algebra (YouTube, free)**: Almost unmatched when it comes to visual intuition.

- **Gilbert Strang’s MIT OCW course**: Taught by the legend himself. It takes time, but it is the gold standard.

- **Mathematics for Machine Learning by Deisenroth, Faisal, and Ong**: A free PDF is available online, and it was written specifically for ML.

Unless you genuinely enjoy pure theory without ML context, try to avoid those kinds of books. Time is limited.


---


# Final Advice

Don’t try to learn all of this in one go. Seriously, don’t. You will burn out quickly and end up hating math.

A better approach is: solidly master Phase 1 and Phase 2 first, then touch any ML content. Start building a simple ML project, such as implementing linear regression from scratch. When you encounter something you don’t understand, come back and study Phase 3 or Phase 4. Then repeat the cycle.

The goal is not to memorize theorems.

**The goal is that when you write `model.forward(x)`, you truly understand what is happening inside.**

Linear algebra gives you this “X-ray vision.”

Also, if it takes you several months to internalize all of this, there’s no need to feel guilty. Some of these concepts took me years to truly understand. I still Google things to this day. Everyone does.

If you can’t recall what a Jacobian is at the moment, it doesn’t mean you’re stupid — it just means you haven’t used it for a while.

Keep learning. Keep building. Keep breaking things. Then fix them.

This is the only path.
