Linear Algebra for ML
Machine Learning · Intermediate
Definition
Vectors, matrices, dot products and matrix multiplication are the language of ML models.
Neural networks are mostly matrix multiplications.
Diagram
Flowchart
Example: Matrix × vector
X = [[1, 2], [3, 4]]
w = [0.5, 1]
print([sum(a * b for a, b in zip(row, w)) for row in X])Output: [2.5, 5.5]
Key points
- Dot product measures alignment
- Shapes must match: (n×d)(d×k)
Interview questions
When is matrix multiplication valid?
When the first matrix's columns equal the second's rows.