Letters and the little numbers: xᵢ, x², x⁽ⁱ⁾
Subscripts pick an item, superscripts are usually powers, and a superscript in brackets means a training example. Three tiny marks, three different meanings.
1. The idea
Maths notation is compressed code. One line in a paper can stand for a loop over a dataset, a loop over features and a sum, all at once. The first skill is reading the small numbers and letters stuck to a symbol, because they say which item you are looking at.
A subscript picks an item. xᵢ is item number i of the list x, and Xᵢⱼ is the entry in row i, column j of the table X. A superscript is usually a power: x² is x times x. Machine learning adds a third kind, a superscript in brackets, x⁽ⁱ⁾, which means “training example number i” and has nothing to do with powers. So x₂ is the second feature, x² is x squared, and x⁽²⁾ is the second example in the dataset.
One trap catches everyone once: maths counts from 1, Python counts from 0. The x₁ of a paper is x[0] in NumPy. When you turn an equation into code, shift every index down by one.
2. Try it: point at an entry
Here is a small dataset: 4 examples (rows) and 3 features (columns). Pick i and j and see which entry xⱼ⁽ⁱ⁾ names, and how you'd write it in NumPy.
3. The math
4. The code (python)
import numpy as np
# 4 examples (rows) and 3 features (columns)
X = np.array([[1.2, 3.0, 0.5],
[0.8, 2.0, 1.5],
[2.5, 4.0, 0.2],
[1.9, 1.0, 3.3]])
i, j = 2, 3 # the maths counts from 1
print(X[i - 1, j - 1]) # 1.5
print(X[i - 1]) # [0.8 2. 1.5]
print(X[:, j - 1] ** 2) # [ 0.25 2.25 0.04 10.89]5. You’ll see this in
- Core Course chapter 2: one neuron, many inputs where xᵢ and wᵢ first meet
- Mean squared error, read with the seven questions yᵢ and ŷᵢ, one per example
6. Check yourself
Finished this chapter?
What changed in ML architectures this week
New models worth knowing, benchmark moves, and one architecture explained in plain words. Free, once a week, unsubscribe anytime.