<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: yash watwani</title>
    <description>The latest articles on DEV Community by yash watwani (@yash_watwani_53a215d59ea4).</description>
    <link>https://dev.to/yash_watwani_53a215d59ea4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4285855%2Fa758e601-f544-49a7-9d03-c6cadbfef357.jpg</url>
      <title>DEV Community: yash watwani</title>
      <link>https://dev.to/yash_watwani_53a215d59ea4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yash_watwani_53a215d59ea4"/>
    <language>en</language>
    <item>
      <title>Learning rate, explained with real numbers: why 0.1 works and 1.1 explodes</title>
      <dc:creator>yash watwani</dc:creator>
      <pubDate>Sun, 06 Dec 2026 05:53:29 +0000</pubDate>
      <link>https://dev.to/yash_watwani_53a215d59ea4/learning-rate-explained-with-real-numbers-why-01-works-and-11-explodes-52ll</link>
      <guid>https://dev.to/yash_watwani_53a215d59ea4/learning-rate-explained-with-real-numbers-why-01-works-and-11-explodes-52ll</guid>
      <description>&lt;p&gt;The learning rate is the one setting you will tune more than any other in machine learning. It is also the one most explanations rush past. Here is the whole idea with real numbers, in about four minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-line version
&lt;/h2&gt;

&lt;p&gt;Gradient descent updates a weight like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;learning_rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;gradient&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gradient says which way is downhill. The learning rate says &lt;strong&gt;how big a step&lt;/strong&gt; to take. Picture walking down a valley in the dark: the learning rate is your stride length.&lt;/p&gt;

&lt;h2&gt;
  
  
  A tiny experiment you can run
&lt;/h2&gt;

&lt;p&gt;Take the simplest possible loss, &lt;code&gt;loss = (w - 3)^2&lt;/code&gt;. The best answer is &lt;code&gt;w = 3&lt;/code&gt;. Start at &lt;code&gt;w = 0&lt;/code&gt; (loss 9) and take 12 steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;lr&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# gradient of (w - 3)^2 is 2(w - 3)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;lr&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0.01  5.542     # too small: barely moved
0.1   0.0425    # good: almost at the bottom
0.9   0.0425    # same loss, but it got there by bouncing side to side
1.1   715.4716  # too big: every step overshoots more, the run diverges
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three lessons hide in those four lines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Too small&lt;/strong&gt; wastes time. The curve is still sloping down when you stop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Too big&lt;/strong&gt; overshoots the bottom, lands higher on the other side, and the loss explodes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Works" is not the same as "smooth".&lt;/strong&gt; 0.9 reaches the same loss as 0.1, but it zig-zags across the valley on the way. On a real model with noisy gradients, that bouncing is what makes training unstable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How people actually pick it
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Search in multiples of about 3, not small steps.&lt;/strong&gt; Try 0.001, 0.003, 0.01, 0.03, 0.1. Learning rates matter on a log scale, so 0.01 vs 0.03 is a real difference, while 0.03 vs 0.031 is not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pick the largest value whose loss still falls smoothly.&lt;/strong&gt; Bigger trains faster, until it starts bouncing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start big, then slow down.&lt;/strong&gt; A &lt;em&gt;learning-rate schedule&lt;/em&gt; shrinks the step as training goes on: big strides while you are far from the bottom, small careful ones near it. Large models usually add a short warm-up at the start too.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The rule of thumb
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What the loss curve does&lt;/th&gt;
&lt;th&gt;What to change&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Falls, then flattens&lt;/td&gt;
&lt;td&gt;Nothing, this is good&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Falls very slowly&lt;/td&gt;
&lt;td&gt;Raise the learning rate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bounces or goes up&lt;/td&gt;
&lt;td&gt;Lower the learning rate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  See it move
&lt;/h2&gt;

&lt;p&gt;I built a free interactive lesson where you can drag the learning rate and watch the ball roll (or fly out of) the valley, next to the live training curve: &lt;a href="https://stepwiseml.com/learning-rate" rel="noopener noreferrer"&gt;Learning rate on Stepwise ML&lt;/a&gt;. It is part of a free set of 126 short visual ML lessons, no sign-up needed.&lt;/p&gt;

&lt;p&gt;What confused you most when you first met learning rates? I'm collecting the common sticking points to make the lessons better.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
