{"id":187,"date":"2026-11-13T12:33:57","date_gmt":"2026-11-13T04:33:57","guid":{"rendered":"https:\/\/hoho.live\/luda\/index.php\/2026\/11\/13\/how-gradient-descent-steps-against-the-gradient\/"},"modified":"2026-11-13T21:52:06","modified_gmt":"2026-11-13T13:52:06","slug":"how-gradient-descent-steps-against-the-gradient","status":"publish","type":"post","link":"https:\/\/hoho.live\/luda\/index.php\/2026\/11\/13\/how-gradient-descent-steps-against-the-gradient\/","title":{"rendered":"How gradient descent steps against the gradient"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Short answer:<\/strong> <strong>Gradient descent<\/strong> minimizes a differentiable function by repeating x \u2190 x \u2212 \u03b7\u2207f(x). The gradient is the direction of steepest increase, so the minus sign descends. A step size \u03b7 that is too large diverges. A step size that is too small crawls. On a convex function with a Lipschitz gradient, a sufficiently small constant step converges to the global minimum. On a nonconvex function the same loop converges, when it converges, to a stationary point that may be a saddle or a poor local minimum.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>What the problem actually asks<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">The first-order model of f at x is f(x) plus the gradient dotted with the step. Choosing the step opposite the gradient decreases that model. The real function decreases too when the step is small enough that the linear model still dominates the remainder. That is the entire local argument.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Machine-learning training adds stochastic gradients, estimated on a minibatch, and a schedule for \u03b7. The algorithm here is the full-gradient iteration. Stochastic gradient descent is the noisy relative. Newton&#8217;s method uses curvature and is a different update.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>What the algorithm guarantees<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">If \u2207f is Lipschitz with constant L and \u03b7 is in (0, 2\/L), the function values decrease and, for convex f, the iterates approach the set of minimizers at a rate that depends on strong convexity when it holds. Without strong convexity the typical smooth convex rate on the gap is O(1\/t). None of those rates apply to an arbitrary nonconvex loss. Extra memory is the gradient vector. Each iteration costs one gradient evaluation.<\/p>\n\n\n<p class=\"wp-block-paragraph\">A line search or a decreasing schedule can replace a hand-picked \u03b7. Momentum and adaptive methods change the direction or the per-coordinate step. They are not plain gradient descent, and a proof for plain gradient descent does not transfer unchanged.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>The working steps<\/strong><\/h4>\n\n<ol class=\"wp-block-list\">\n<li>Choose a start x and a step \u03b7. If a Lipschitz estimate L is known, take \u03b7 below 2\/L. Otherwise start small and watch the function value.<\/li>\n<li>Compute the full gradient at x. Subtract \u03b7 times the gradient from x.<\/li>\n<li>If the function value rose, the step was too long for the local model. Reduce \u03b7 and do not treat the risen value as progress.<\/li>\n<li>Stop when the gradient norm is near zero, or when a budget ends. A near-zero gradient is a stationary point. On a nonconvex function, compare function values from several starts.<\/li>\n<li>For a convex problem with the step conditions above, the stationary point is a global minimizer. State that hypothesis when you claim it.<\/li>\n<\/ol>\n\n\n<p class=\"wp-block-paragraph\">The minus sign is the descent. Adding the gradient ascends. The global-minimum claim needs convexity. Stochastic minibatches need a different, noisier analysis. A Lipschitz step-size rule needs L. Guessing \u03b7 = 0.01 is a heuristic, not that rule.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Approaches that look simpler and fail<\/strong><\/h4>\n\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>Approach<\/th>\n<th>Why it fails when the gradient is added instead of subtracted<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Step in the direction of the gradient to minimize<\/td>\n<td>The gradient points uphill. The descent step subtracts it.<\/td>\n<\/tr>\n<tr>\n<td>Keep a constant step that increased the loss<\/td>\n<td>The linear model has failed. Continuing amplifies the overshoot. Reduce the step or use a line search.<\/td>\n<\/tr>\n<tr>\n<td>Call the limit a global minimum on a nonconvex loss<\/td>\n<td>It is a stationary point of the iteration that was run. Another basin can be lower.<\/td>\n<\/tr>\n<tr>\n<td>Quote the convex O(1\/t) rate for a stochastic minibatch<\/td>\n<td>That rate is for the full gradient under convexity and a suitable step. Minibatch noise has its own bounds.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n<p class=\"wp-block-paragraph\">A local root of a derivative, with a quadratic phase near the root, is Newton&#8217;s method. A symmetric positive-definite linear system can use conjugate gradients instead of a generic descent. Gradient descent is the first-order subtraction of the gradient.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>A working example<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">This Python fragment steps against the gradient of (x\u22123)\u00b2. The derivative is 2(x\u22123). From 0, with step size 0.4, ten steps land on <code>3<\/code>.<\/p>\n\n<pre><code class=\"language-python\">x = 0.0\nfor _ in range(10):\n    grad = 2 * (x - 3)\n    x = x - 0.4 * grad\nassert abs(x - 3) &lt; 1e-6\nprint(f&quot;{x:.0f}&quot;)\n<\/code><\/pre>\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Where it is used<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">Gradient descent trains neural networks and logistic regression: <strong>PyTorch<\/strong> SGD and its relatives step the parameters against the gradient. A line search or Adam changes the step length, not the direction&#8217;s meaning. Newton&#8217;s method uses the Hessian and is a different update.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>When you can drop this algorithm<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">Drop a fixed step that increases the function. Use a smaller step or a line search. Keep plain gradient descent when the gradient is available and the convexity hypotheses, if you use them, are actually true.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Why this stays published<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">We publish this so a search for gradient descent returns the minus-gradient update and the convexity hypothesis behind a global minimum. <strong>Gradient descent minimizes by subtracting a step times the gradient, and it reaches a global minimum when the function is convex and the step is small enough for the gradient&#8217;s Lipschitz constant.<\/strong><\/p>\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u7531 HoHo \u8207 AI \u5354\u4f5c\u6574\u7406\uff0c\u6700\u5f8c\u66f4\u65b0\u65bc 2026 \u5e74 11 \u6708 13 \u65e5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Short answer: Gradient descent minimizes a differentiable function by repeating x \u2190 x \u2212 \u03b7\u2207f(x). The gradient is the direction of steepest increase, so the minus sign descends. A step size \u03b7 that is too large diverges. A step size that is too small crawls. On a convex function&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,54],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","hentry","category-algorithms","category-optimization"],"_links":{"self":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":2,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":586,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/187\/revisions\/586"}],"wp:attachment":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}