Linear algebra for ML
Understand vectors, matrices and geometric operations used in models.
A dense layer multiplies an input vector by a weight matrix and adds a bias.
Interview questions
Choose a question to reveal its answer.
01EasyCoreWhat does the dot product tell you about two vectors?
Answer
What does the dot product tell you about two vectors?
Sum of pairwise coordinate products; measures alignment and depends on vector lengths.
Compute the weighted sum of input features.
import numpy as np
a = np.array([1, 2])
b = np.array([3, 4])
print(a @ b) # 11The dot product sums pairwise products.
02EasyCoreWhat dimensions must agree for matrix multiplication?
Answer
What dimensions must agree for matrix multiplication?
Combines rows of the first matrix with columns of the second; inner dimensions must match.
Transform a batch of feature vectors using a weight matrix.
03EasyCoreWhat does a matrix transpose do?
Answer
What does a matrix transpose do?
Swaps rows and columns of a matrix.
Convert a column vector into a row vector.
04MediumHigh priorityHow do you calculate the L2 norm of a vector?
Answer
How do you calculate the L2 norm of a vector?
Square root of the sum of squared coordinates.
Measure the length of an embedding vector.
05MediumHigh priorityWhy is cosine similarity useful for embeddings?
Answer
Why is cosine similarity useful for embeddings?
Dot product divided by both nonzero vector norms; measures directional similarity.
Compare text embeddings independently of magnitude.
06MediumWhat is an eigenvector and why is it useful in ML?
Answer
What is an eigenvector and why is it useful in ML?
Nonzero vector whose direction is preserved up to a scalar by a linear map.
Find a principal direction of a covariance matrix.
07MediumWhat does an eigenvalue represent in PCA?
Answer
What does an eigenvalue represent in PCA?
Scalar multiplier associated with an eigenvector.
Measure variance along a covariance eigenvector.
08MediumWhat does matrix rank tell you about feature redundancy?
Answer
What does matrix rank tell you about feature redundancy?
Dimension of the column space, equal to the dimension of the row space.
Detect redundant linear features.
09HardWhat does it mean for two vectors to be orthogonal?
Answer
What does it mean for two vectors to be orthogonal?
Two vectors have zero dot product.
Identify independent perpendicular axes in a two-dimensional plot.
10HardHow does SVD enable low-rank approximation?
Answer
How does SVD enable low-rank approximation?
Factorization of a matrix into orthonormal factors and nonnegative singular values.
Approximate a matrix by keeping its largest singular values.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.
1. What is the dot product of [1,2] and [3,4]?
2. What is the shape of a 4×3 matrix multiplied by a 3×2 matrix?
3. What is cosine similarity between nonzero perpendicular vectors?
Calculus and gradients
Continue to the next set of interview questions.