Linear Algebra with NumPy
np.dot, np.linalg.inv, np.linalg.eig, np.linalg.solve for systems of equations.
Linear Algebra in NumPy
NumPy provides matrix operations through the @ operator and the np.linalg module, the foundation of nearly every machine learning algorithm.
Matrix Multiplication with @
The @ operator performs true matrix multiplication. Inner dimensions must match: (m,k) @ (k,n) gives (m,n).
import numpy as np
A = np.array([[1, 2], [3, 4]])
B = np.array([[5, 6], [7, 8]])
print(A @ B)
# [[19 22]
# [43 50]]