array([2., 3., 4.])
In this class we’re studying how Tuneable Machines can play Optimization Games.
So far:
“I trained a neural net classifier from scratch.”
numpyaka np, because it’s canonically imported as:
numpyarray data type. Like a list but:
for loops!arange: range that makes arrayszeros / ones / full: make new arraysfor loops!)array plus scalar:
array plus array:
Applying a function to every element:
Reduce the dimensionsionality of an array (e.g., summing over an axis)
Suppose the true values are:
and two model predictions are:
MAE: mean absolute error: average of absolute differences
\[ \text{MAE} = \frac{1}{n} \sum_{i=1}^n |y_i - \hat{y}_i| \]
CS 375:
CS 376:
Check-in question: what loss function is this?
y = x1*w1 + x2*w2 + x3*w3 + by = x @ W + bMatmul (@) so we can process every example of x at once:
x is 100 samples, each with 3 features (x.shape is (100, 3))W gives 4 outputs for each feature (W.shape is (3, 4))x @ W gives 100 samples, each with 4 outputs ((100, 4))b’s shape?W is now a 2-axis array: how much each input contributes to each outputb is now a 1-axis array: a number to add to each outputA measure of relative skill:
Formal definition (Wikipedia):
Pr(A wins) = 1 / (1 + 10^(-EloDiff / 400))
EloDiff = A Elo - B Elo
Suppose we have 3 chess players:
| player | Elo |
|---|---|
| A | 1000 |
| B | 2200 |
| C | 1010 |
A and B play. Who wins?
A and C play. Who wins?
See this Elo ratings table
Pr(A wins) = 1 / (1 + 10^(-EloDiff / 400))
Now try it again by:
Do you get the same result?
logits), which can be any numbers (positive, negative, whatever)xx = exp(logits) (logits.exp() in PyTorch)10 ** logits or 2 ** logitsprobs = xx / xx.sum()logits + constant doesn’t change output.logits * constant does change output.Special case of softmax when you just have one score (binary classification): use logits = [score, 0.0]
Exercise for practice: write this out in math and see if you can get it to simplify to the traditional way that the sigmoid function is written.