Logistic regression is the smallest model that still has every moving part of deep learning in it: a linear score, a squashing function, a loss, and gradient descent. Build the training loop once and the rest of the field looks familiar.
For each example the model predicts p = sigmoid(w·x + b). Training minimises the mean binary cross-entropy, and the gradients come out unusually clean:
dL/dw = (1/n) * Σ (p - y) * xdL/db = (1/n) * Σ (p - y)Task: write train_logistic(features, labels, learning_rate, epochs) that runs full-batch gradient descent and returns [weights, bias], with every number rounded to 4 decimal places.
epochs = 0 returns the starting parameters unchanged.The
(p - y)term is the whole trick. The sigmoid's derivative and the log-loss's derivative cancel almost perfectly, leaving plain prediction error — which is why this loss is paired with this activation and not another.