Logistic Regression Gradient Descent#
Stage 4 · ⚙️ Backprop & Vectorization · Lesson 13 of 17 · intermediate
◀ Previous · Derivatives with a Computation Graph · Next · Gradient Descent on m Training Examples ▶ · ↑ Section
Important
✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.
The neuron’s graph#
The computation-graph machinery now applies to the neuron itself. For a two-feature example the forward graph is
Gradient descent needs \(\partial \mathcal{L}/\partial w_1\), \(\partial \mathcal{L}/\partial w_2\) and \(\partial \mathcal{L}/\partial b\) — found by walking this graph backward.
Backprop, step by step#
Start at the loss and step back. The derivative of the loss with respect to the activation is
The sigmoid contributes \(\partial a / \partial z = a(1 - a)\), so by the chain rule \(\mathrm{d}z = \mathrm{d}a \cdot a(1 - a)\).
The clean result#
Those two pieces multiply out to something remarkably simple:
The gradient of the loss with respect to the pre-activation is just prediction minus truth. From there the parameter gradients fall out immediately:
Then the update#
With the gradients in hand, one gradient-descent step nudges each parameter downhill:
That is a full learning step — for a single example. Real training averages over many, which is the next lesson.
Hint
Related lessons: Derivatives with a Computation Graph · Logistic Regression – Loss Function and Cost Function · Gradient Descent on m Training Examples · Computation Graph
See also
Source article Adapted (context, re-expressed) in our own words from: https://insightful-data-lab.com/2025/04/07/logistic-regression-gradient-descent/ (insightful-data-lab.com).