NUMPY 101
numpy-101 · v1.0.0
ivyx✓
Arrays that think in bulk: replace your loops with array operations, predict the shape a broadcast produces, and redo everything ai-math-101 built by hand (dot, matmul, cosine) in one line each.
What this course is for
By the end of this course you can replace a loop with an array operation, predict the shape a broadcast produces, and redo everything ai-math-101 built by hand in one line each.
What you will be able to do
- Say why an array beats a list of numbers, and measure the speedup yourself
- Predict dtype promotion, and catch integer floor-division and overflow before they eat data
- Tell views from copies, and stop in-place edits from leaking into caller data
- Filter with boolean masks and write through them in place
- Predict broadcast output shapes, and columnize a vector on purpose
- Multiply matrices with @, and compute norms and cosine similarity in one-liners
- Aggregate along the axis you mean, and seed randomness for reproducibility
Who it is for
Learners who built vectors and matrices by hand in AI MATH 101 and are ready for the industrial version, and anyone whose NumPy is guesswork around axis=, views and broadcasting
Before you start
- AI MATH 101, or hand familiarity with vectors, dot products and matmul
- PYTHON 101-level Python
Lesson path
What an array is, why it is fast, and what one dtype per array costs
- 1Why arrays exist30 min
Time a Python loop against a vectorized op on a million numbers
- 2dtype and shape30 min
Predict what np.array([1, 2.5]) becomes and why
Windows, copies, and conditions as indexes
- 3Slices are views40 min
Slice an array, mutate the slice, and explain what happened to the original
- 4Boolean masks30 min
Filter an array with a condition instead of a loop
The rules for when two shapes meet, and how to use them on purpose
- 5The broadcasting rules40 min
Predict the output shape of (3,1)+(1,4) before running it
- 6Vectorize a computation30 min
Normalize the columns of a matrix without writing a loop
The by-hand course, cashed in
- 7@ and transpose30 min
Replace ai-math-101's triple-loop matmul with one operator and time both
- 8Norms and similarity30 min
Compute cosine similarity on real vectors in two lines
Aggregation you can aim, randomness you can repeat
- 9axis= and seeds30 min
Aggregate along the axis you meant, and make randomness repeatable
About this course
NUMPY 101: Arrays that think in bulk
Nine lessons that turn the mathematics you built by hand in AI MATH 101 into
the industrial version every ML library runs on. Loops become array
operations (and you time the difference yourself; expect two orders of
magnitude), your three-loop matmul becomes a @ b, your cosine similarity
becomes a working retrieval ranking, and axis= stops being a guess.
How this course teaches
Same tutor as the rest of the series: predict before you run, hints climb a
ladder that ends in an explanation rather than pasted code. NumPy's
particular danger is code that runs cleanly and means something else: a
slice that was secretly a window onto the original, a broadcast that lined
prices up with the wrong axis of a square matrix, a * where @ belonged,
blessed by a test the data let pass. This course's diagnose cells are built
from exactly those, and several were seeded three courses ago: the matrices
in lesson 7's first cell are the same ones you multiplied by hand.
What you will be able to do
- Say why an array beats a list of numbers, and measure the speedup yourself
- Predict dtype promotion, and catch floor-division and overflow before they eat data
- Tell views from copies, and stop in-place edits leaking into caller data
- Filter with boolean masks and write through them in place
- Predict broadcast output shapes, and columnize a vector on purpose
- Multiply matrices with
@, and compute norms and cosine in one-liners - Aggregate along the axis you mean, with seeded, repeatable randomness
The lessons
From lists to arrays
- Why arrays exist
- dtype and shape
Selecting 3. Slices are views 4. Boolean masks
Broadcasting 5. The broadcasting rules 6. Vectorize a computation
Linear algebra, revisited
7. @ and transpose
8. Norms and similarity
Statistics on axes 9. axis= and seeds
Where this course sits
Third course of the ivyx AI series, directly after ai-math-101, which is a real prerequisite rather than a formality: this course constantly cashes cheques that one wrote (the matmul race in lesson 7, the music friends in lesson 8, the rows-first shape convention everywhere). pandas-101 builds straight on top: labeled columns over these arrays. The cosine you productionize in lesson 8 returns unchanged in hf-101, pointed at transformer embeddings.