NumPy Lab
Build deep intuition for NumPy internals, vectorization, and performance — the way FAANG expects ML engineers to think.
You can write fast, memory-efficient, interview-ready NumPy code and explain *why* it is efficient.
Progress — 0/26 tasks
Setup
Section 1 — ndarray Fundamentals
Task 1.1: Array Creation & Shapes
ndarray Fundamentals
Create a 1D array with values 0 to 99 (no loops)
Reshape arr_1d into a (10, 10) array
Create a 3D array of shape (4, 5, 3)
dtype & Memory
Create two arrays with same values but different dtypes
Compare memory usage
Indexing, Views & Copies
Create a 2D array and slice every alternate row
Modify A_slice and observe A
Boolean Masking
Create random array of size 1000
Extract values greater than mean
Replace negative values with 0 (no loops)
Broadcasting
Create A (1000, 50) and b (50,)
Add b to each row of A
Normalize each row of A
Broadcasting Trap
Intentionally trigger a broadcasting error Then fix it
Vectorization vs Loops
Create large array X of size 1,000,000
Normalize using Python loop
Normalize using vectorization
Compute pairwise Euclidean distance matrix without loops
Numerical Stability
Implement naive softmax
Fix numerical instability
Linear Algebra
Try valid and invalid matrix multiplications
Solve Ax = b and verify solution
Performance & Memory
Compare in-place vs out-of-place operations
Inspect array strides and explain
Mini Case Study
Given X (10000, 100):