- by x32x01 ||
A matrix can do much more than multiply numbers.
It can stretch, compress, rotate, reflect, shear, or project data into a new space. That is why matrix transformations are so important in Linear Algebra-and why they show up everywhere in AI and Machine Learning.
In the previous lesson, we saw that
So, what does a matrix actually do? 🤔
Let’s start with a simple example.
You can think of it as an arrow that starts at the origin and points to the right.
Now consider this matrix:
When we calculate
What happened?
The arrow became twice as long.
The vector itself did not change manually. The matrix transformed it.
This is called Scaling.
For the vector:
the result is still:
The horizontal direction was not stretched.
But if we use:
the result becomes:
The vertical direction is now twice as long.
🎯 This gives us an important idea:
A matrix can transform different directions in different ways.
That is one of the key ideas behind linear transformations.
Consider this matrix:
Start with:
After applying the transformation:
The vector that originally pointed to the right now points upward. 🔄
The matrix has performed a 90-degree counterclockwise rotation.
So a matrix does not simply "calculate a number."
It can change the direction and position of a vector.
This is why it is useful to think of:
Matrix → Transformation
rather than seeing a matrix as nothing more than a table of numbers.
💡 Once you start thinking this way, matrix multiplication becomes much easier to visualize.
One of the most common equations in a neural network layer is:
Here,
The important part for this lesson is
It transforms the input into a new representation.
If
A simplified neural network can be viewed like this:
Each layer takes the representation produced by the previous layer and transforms it again.
💡 This gives us another way to understand neural networks:
A neural network is a sequence of transformations that gradually changes the representation of data.
The activation functions between these transformations add non-linearity, allowing neural networks to learn much more complex relationships than a simple sequence of matrix multiplications could represent.
The following example rotates the vector
The result is:
Now change the matrix and see how the transformation changes.
Try a scaling matrix:
Then try a shear transformation:
Don't only ask:
"What is the result?"
Ask a more useful question:
"What did the matrix do to the data?"
That question changes the way you look at Linear Algebra.
Instead of seeing:
you start seeing:
Data → Transformation → New Representation
And this small idea becomes extremely important later when you study:
🔹 PCA
🔹 Embeddings
🔹 Neural Networks
🔹 Computer Vision
🔹 Transformers
Once you understand matrices as transformations, many AI concepts that initially look abstract become much easier to visualize.
What does
It can stretch, compress, rotate, reflect, shear, or project data into a new space. That is why matrix transformations are so important in Linear Algebra-and why they show up everywhere in AI and Machine Learning.
In the previous lesson, we saw that
Wx is not just a mathematical operation. It is a transformation that takes one vector and produces a new vector.So, what does a matrix actually do? 🤔
Let’s start with a simple example.
A Matrix Can Stretch a Vector
Suppose we have this vector: Code:
x = [1, 0] Now consider this matrix:
Code:
W = [
2 0
0 1
] Wx, we get: Code:
[2, 0] The arrow became twice as long.
The vector itself did not change manually. The matrix transformed it.
This is called Scaling.
Scaling Different Directions
Now try a different matrix: Code:
W = [
1 0
0 2
] Code:
x = [1, 0] Code:
[1, 0] But if we use:
Code:
x = [0, 1] Code:
[0, 2] 🎯 This gives us an important idea:
A matrix can transform different directions in different ways.
That is one of the key ideas behind linear transformations.
A Matrix Can Rotate a Vector
Now let’s make things more interesting.Consider this matrix:
Code:
W = [
0 -1
1 0
] Code:
x = [1, 0] Code:
Wx = [0, 1] The matrix has performed a 90-degree counterclockwise rotation.
So a matrix does not simply "calculate a number."
It can change the direction and position of a vector.
What Can a Matrix Do?
Depending on its values, a matrix can represent different geometric transformations.| Transformation | What it does |
|---|---|
| Scaling | Stretches or compresses data |
| Rotation | Changes the direction of data |
| Reflection | Flips data across an axis or plane |
| Shearing | Slants the shape of data |
| Projection | Maps data onto a lower-dimensional space |
Matrix → Transformation
rather than seeing a matrix as nothing more than a table of numbers.
💡 Once you start thinking this way, matrix multiplication becomes much easier to visualize.
So What Does This Have to Do With AI? 🤖
A lot.One of the most common equations in a neural network layer is:
Code:
y = Wx + b W is the weight matrix, x is the input, and b is the bias.The important part for this lesson is
Wx.It transforms the input into a new representation.
If
x contains a set of features, Wx maps those features into another space that the next layer can work with.A simplified neural network can be viewed like this:
Code:
Input
↓
Wx + b
↓
Activation
↓
W₂x + b₂
↓
Activation
↓
...
↓
Prediction 💡 This gives us another way to understand neural networks:
A neural network is a sequence of transformations that gradually changes the representation of data.
The activation functions between these transformations add non-linearity, allowing neural networks to learn much more complex relationships than a simple sequence of matrix multiplications could represent.
Try the Transformation Yourself 💻
You can see this idea directly with Python and NumPy.The following example rotates the vector
[1, 0] by 90 degrees: Python:
import numpy as np
x = np.array([1, 0])
W = np.array([
[0, -1],
[1, 0]
])
print(W @ x) Code:
[0 1] Try a scaling matrix:
Python:
W = np.array([
[2, 0],
[0, 2]
])
print(W @ x) Python:
W = np.array([
[1, 1],
[0, 1]
])
print(W @ x) "What is the result?"
Ask a more useful question:
"What did the matrix do to the data?"
That question changes the way you look at Linear Algebra.
Instead of seeing:
Matrix × Vectoryou start seeing:
Data → Transformation → New Representation
And this small idea becomes extremely important later when you study:
🔹 PCA
🔹 Embeddings
🔹 Neural Networks
🔹 Computer Vision
🔹 Transformers
Once you understand matrices as transformations, many AI concepts that initially look abstract become much easier to visualize.
Frequently Asked Questions
------------------What does a matrix do to a vector?
A matrix applies a transformation to a vector. Depending on the matrix, it can scale, rotate, reflect, shear, or project the vector into another space.Why are matrices important in AI?
Matrices provide an efficient way to transform large amounts of numerical data. Neural networks use matrix operations to transform input features into new representations at each layer.What does Wx mean in a neural network?
Wx means that the input vector x is multiplied by the weight matrix W. This transforms the input into a new representation before the bias and activation function are applied.