Stage 2 · Lesson 2 of 9
Matrix multiplication and shapes
You can multiply a matrix of (m, n) by one of shape (n, p), and the answer has shape (m, p). The two inner numbers must match. Each cell of the answer is the of one row from the first matrix and one column from the second.
This is how a whole batch of predictions is made at once: X of shape (1000, 3) times of shape (3, 1) gives 1,000 predictions, shape (1000, 1). Every neural network layer later on is a matrix multiplication plus a bias. Reading shapes here is what lets you fix errors like 'mat1 and mat2 shapes cannot be multiplied'. Also learn the , which swaps rows and columns.
Common trapthinking order does not matter: A @ B and B @ A usually differ, and often one of them is not even allowed.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidMathematics for Machine Learning and Data Science Specialization
DeepLearning.AI · Beginner · Coursera subscription; financial aid available
Paid, with financial aid: linear algebra, calculus and statistics taught visually with Python labs
- CourseFreeKhan Academy Statistics and Probability
Khan Academy · Beginner
Free, complete statistics and probability with practice questions on every topic
Keep handy
Also worth your time
- Mathematics for Machine LearningGo deeper
Free book that ties the maths directly to regression, PCA and classifiers