My first note: linear regression. This post is here to confirm that math and code highlighting both render correctly.
The model
We fit a linear model $\hat{y} = \mathbf{w}^\top \mathbf{x} + b$ by minimizing the mean squared error:
$$ J(\mathbf{w}, b) = \frac{1}{2n} \sum_{i=1}^{n} \left( \hat{y}^{(i)} - y^{(i)} \right)^2 $$
The gradient with respect to the weights is:
$$ \nabla_{\mathbf{w}} J = \frac{1}{n} \sum_{i=1}^{n} \left( \hat{y}^{(i)} - y^{(i)} \right) \mathbf{x}^{(i)} $$
Inline math works too: the learning rate $\alpha$ controls the step size.
Implementation
| |
Takeaways
- Gradient descent moves parameters opposite the gradient.
- A learning rate that’s too large diverges; too small is slow.
Next up: logistic regression and the cross-entropy loss.