ML MATH & LINEAR ALGEBRA ยท INTERVIEW QUESTION
What is a matrix and why are matrices important in machine learning?
๐ข beginner ยท Linear Algebra
Hint: Think about data representation and linear transformations.
Answer
A matrix is a 2D array of numbers. In ML, matrices represent:
- Datasets: rows = samples, columns = features
- Weight matrices in neural networks:
- Covariance matrices: capture feature relationships
- Attention matrices in transformers:
Common Vector Operations
Addition: element-wise
Dot product:
Magnitude (L2 norm):
python
import numpy as np
# Row and column vectors
row = np.array([1, 2, 3])
col = np.array([[1], [2], [3]])
# Dot product
print(np.dot(row, [4, 5, 6])) # 32
# Magnitude
print(np.linalg.norm(row)) # 3.742GPUs excel at parallel matrix operations โ this is why deep learning is fast on GPUs.
Related questions
- What is the difference between eigenvalues and singular values?
- Explain the role of SVD in PCA. How does truncated SVD relate to dimensionality reduction?
- What is the rank of a matrix? Why does it matter in ML?
- Explain the relationship between eigendecomposition and diagonalization. Why is it useful?
- What is a dot product and why does it matter in ML?