Lesson 14
Broadcasting Basics
Broadcasting handles different-shaped arrays:
a * 10 # scalar broadcast m + v # 1D broadcasts over 2D rows
Rules
- Compare dims right to left
- Sizes match OR one is 1
Why this matters
Broadcasting is why you can write matrix * vector without nested loopsβit is the mental model behind most βit just worksβ shape math in NumPy.
Shape mistakes here show up everywhere: normalization, biases in neural nets, feature scaling.
ResourcesDocs, references & more β opens in a new tab
π― Your Task
prices = [[10,20,30],[40,50,60]], tax_rate = [0.05,0.08,0.10]. Compute totals = prices + prices * tax_rate.
tax_rate broadcasts across rows
ββ run Β· ββ β nav
βΆ Output
Run your code to see output here.