Block 18: Linear Algebra Basics
Perform matrix operations used frequently in ML.
Concepts
- Matrix multiplication: A @ B or np.dot(A, B)
- Transpose: A.T
- np.linalg.norm(), np.linalg.det(), np.linalg.inv()
- Solving a linear system: np.linalg.solve(A, b)
Code Examples
See exercise below.
Exercise
Create A (2×3) and B (3×2), compute A @ B, verify shape. Solve the system 2x + y = 5, x - y = 1 using np.linalg.solve.
Homework
Verify that A @ np.linalg.inv(A) ≈ identity matrix for a 3×3 matrix. Friday