<?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: Ganesh Kumar</title>
    <description>The latest articles on DEV Community by Ganesh Kumar (@ganesh-kumar).</description>
    <link>https://dev.to/ganesh-kumar</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%2F1403545%2F61f1e35c-72dd-4187-a25d-85ee2db0141c.jpeg</url>
      <title>DEV Community: Ganesh Kumar</title>
      <link>https://dev.to/ganesh-kumar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ganesh-kumar"/>
    <language>en</language>
    <item>
      <title>Understanding Multiple Input and Output Neural Network</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Tue, 07 Jul 2026 12:28:28 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-multiple-input-and-output-neural-network-1fpb</link>
      <guid>https://dev.to/ganesh-kumar/understanding-multiple-input-and-output-neural-network-1fpb</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous article, we discussed how ReLU activation function works. Now let's see how multiple input and multiple output neural networks work.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Multiple Input and Output Neural Network works
&lt;/h2&gt;

&lt;p&gt;Until now, we worked with a neural network that had a single input and a single output. In real-world problems, we usually have multiple inputs and multiple outputs.&lt;/p&gt;

&lt;p&gt;In this article, we will build a neural network with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;2 inputs&lt;/strong&gt; (input1 and input2)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1 hidden layer&lt;/strong&gt; with 2 neurons&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3 outputs&lt;/strong&gt; (output1, output2, output3)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ReLU&lt;/strong&gt; as the activation function&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Network Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input1 ──┐
         ├──► hidden_neuron1 ──┬──► output1
input2 ──┤                     ├──► output2
         └──► hidden_neuron2 ──┴──► output3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each input is connected to each hidden neuron, and each hidden neuron is connected to each output neuron.&lt;/p&gt;

&lt;h2&gt;
  
  
  Forward Pass Equations
&lt;/h2&gt;

&lt;p&gt;All weights and biases are assigned based on normal distribution.&lt;br&gt;
&lt;strong&gt;Hidden Layer Calculation&lt;/strong&gt;&lt;br&gt;
For &lt;strong&gt;hidden neuron 1&lt;/strong&gt;:&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;x1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b1&lt;/span&gt;
&lt;span class="n"&gt;y1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReLU&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For &lt;strong&gt;hidden neuron 2&lt;/strong&gt;:&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;x2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b2&lt;/span&gt;
&lt;span class="n"&gt;y2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReLU&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output Layer Calculation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;output1&lt;/strong&gt;:&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;output1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For &lt;strong&gt;output2&lt;/strong&gt;:&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;output2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For &lt;strong&gt;output3&lt;/strong&gt;:&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;output3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;w10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example with Numbers
&lt;/h2&gt;

&lt;p&gt;Let's work through a concrete example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Given inputs:&lt;/strong&gt;&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;input1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="n"&gt;input2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Assume the following initial weights and biases:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hidden layer weights:
  w1 = 0.5,  w2 = -0.3,  b1 = 0.1
  w3 = -0.4, w4 = 0.8,   b2 = 0.2

Output layer weights:
  w5 = 0.6,  w6 = 0.7,  b3 = 0.1
  w7 = -0.5, w8 = 0.4,  b4 = 0.2
  w9 = 0.3,  w10 = -0.6, b5 = 0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Calculate hidden neuron values&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hidden neuron 1:&lt;/strong&gt;&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;x1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;
   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;0.9&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;
   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;

&lt;span class="n"&gt;y1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReLU&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Hidden neuron 2:&lt;/strong&gt;&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;x2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.8&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;2.4&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.8&lt;/span&gt;

&lt;span class="n"&gt;y2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReLU&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Calculate outputs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output 1:&lt;/strong&gt;&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;output1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.8&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;
        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.12&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;1.26&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;
        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.48&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output 2:&lt;/strong&gt;&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;output2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.8&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.10&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.72&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.82&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output 3:&lt;/strong&gt;&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;output3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.8&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.06&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;1.08&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.02&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final Results&lt;/strong&gt;&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;output1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.48&lt;/span&gt;
&lt;span class="n"&gt;output2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.82&lt;/span&gt;
&lt;span class="n"&gt;output3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.02&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why ReLU works here
&lt;/h2&gt;

&lt;p&gt;Notice that x1 = 0.2 and x2 = 1.8 — both are positive, so ReLU passes them through unchanged. &lt;/p&gt;

&lt;p&gt;If any x value were negative (say x1 = -0.5), then:&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;y1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReLU&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That neuron would contribute nothing to the outputs, effectively "turning off" and making the network sparse and efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Matrix Representation
&lt;/h2&gt;

&lt;p&gt;You can think of all the weights as a matrix of connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hidden Layer (2x2 weight matrix + 2 biases):

  w1   w2   b1        w3   w4   b2
[ 0.5  -0.3  0.1 ]  [ -0.4  0.8  0.2 ]


Output Layer (3x2 weight matrix + 3 biases):

  w5   w6   b3
[ 0.6  0.7  0.1 ]   → output1

  w7   w8   b4
[-0.5  0.4  0.2 ]   → output2

  w9  w10   b5
[ 0.3 -0.6  0.0 ]   → output3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each output neuron learns a different combination of the hidden neuron outputs, allowing the network to produce multiple independent predictions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We now understand how a neural network with 2 inputs and 3 outputs works step by step using the ReLU activation function:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Each hidden neuron receives all inputs, computes a weighted sum plus bias, and applies ReLU.&lt;/li&gt;
&lt;li&gt;Each output neuron receives all hidden neuron outputs and computes its own weighted sum plus bias.&lt;/li&gt;
&lt;li&gt;The network can produce multiple distinct outputs simultaneously from the same inputs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding ReLU activation function for Neural Network</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Sun, 05 Jul 2026 17:15:07 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-relu-activation-function-for-neural-network-56fj</link>
      <guid>https://dev.to/ganesh-kumar/understanding-relu-activation-function-for-neural-network-56fj</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous article, we discussed how backpropagation actually works. We also calculated weight and bias for all the layers.&lt;br&gt;
We used soft plus activation function for our small neural network.&lt;/p&gt;

&lt;p&gt;Now in this article let's use ReLU function for the neural network.&lt;/p&gt;

&lt;h2&gt;
  
  
  Defination of ReLU
&lt;/h2&gt;

&lt;p&gt;It is a function which will return the input if the input is positive otherwise it will return 0.&lt;/p&gt;

&lt;p&gt;f(x) = max(0,x)&lt;/p&gt;

&lt;p&gt;In normal expression&lt;/p&gt;

&lt;p&gt;f(x) = 1 if x &amp;gt; 0 &lt;br&gt;
       0 if x &amp;lt;=0&lt;/p&gt;

&lt;h2&gt;
  
  
  Using ReLU in Neural Network
&lt;/h2&gt;

&lt;p&gt;For First Layer we can calculate.&lt;/p&gt;

&lt;p&gt;As we use 2 hidden neurons in the first layer we have to calculate for both the neurons separately.&lt;/p&gt;

&lt;p&gt;x1 = ( input x weight1 ) + bias1&lt;br&gt;
y1 = ReLu(x1)&lt;/p&gt;

&lt;p&gt;Similarly calculating for second hidden neuron.&lt;/p&gt;

&lt;p&gt;x2 = ( input x weight2 ) + bias2&lt;br&gt;
y2 = ReLu(x2)&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;From both equation we can calulate the outputs of first layer and can pass it to the second layer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Backpropagation: Calculating Gradients for Hidden Layer Weights and Biases</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Tue, 30 Jun 2026 18:51:03 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-backpropagation-calculating-gradients-for-hidden-layer-weights-and-biases-3k94</link>
      <guid>https://dev.to/ganesh-kumar/understanding-backpropagation-calculating-gradients-for-hidden-layer-weights-and-biases-3k94</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous article, we derived formulas for updating the output layer weights w3, w4, and bias b3. Now, we will understand how to calculate the gradients for the hidden layer parameters: w1, b1, w2, and b2.&lt;/p&gt;

&lt;h2&gt;
  
  
  How are w1, b1, w2, and b2 connected to the prediction?
&lt;/h2&gt;

&lt;p&gt;To find the gradients of the parameters in the hidden layer, we need to trace how changing these values affects the final prediction and the error (SSR).&lt;/p&gt;

&lt;p&gt;Let's recall the structure of our neural network:&lt;/p&gt;

&lt;p&gt;For the top neuron:&lt;/p&gt;

&lt;p&gt;x1 = input * w1 + b1&lt;/p&gt;

&lt;p&gt;y1 = f(x1) = log(1 + e^x1) &lt;em&gt;(using the softplus function)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For the bottom neuron:&lt;/p&gt;

&lt;p&gt;x2 = input * w2 + b2&lt;/p&gt;

&lt;p&gt;y2 = f(x2) = log(1 + e^x2) &lt;em&gt;(using the softplus function)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Finally, the prediction:&lt;/p&gt;

&lt;p&gt;Predicted = y1 * w3 + y2 * w4 + b3&lt;/p&gt;

&lt;p&gt;And the prediction error:&lt;/p&gt;

&lt;p&gt;SSR = Σ (observed − predicted)²&lt;/p&gt;

&lt;p&gt;Since w1, b1, w2, and b2 are not directly connected to the output prediction, we must use the chain rule to backpropagate the error from the output layer back to the hidden layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Applying the Chain Rule to the Hidden Layer
&lt;/h2&gt;

&lt;p&gt;Let's calculate the gradient for the top neuron's weight w1 first.&lt;/p&gt;

&lt;p&gt;A change in w1 affects x1, which affects the output y1, which affects the predicted value, which finally affects the SSR.&lt;/p&gt;

&lt;p&gt;So, by the chain rule:&lt;/p&gt;

&lt;p&gt;dSSR/dw1 = dSSR/d(predicted) * d(predicted)/dy1 * dy1/dx1 * dx1/dw1&lt;/p&gt;

&lt;p&gt;Let's calculate each of these values:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. dSSR/d(predicted)
&lt;/h3&gt;

&lt;p&gt;As we saw in the previous articles, this is the derivative of SSR with respect to the predicted value:&lt;/p&gt;

&lt;p&gt;dSSR/d(predicted) = -2 * (Observed - Predicted)&lt;/p&gt;

&lt;h3&gt;
  
  
  2. d(predicted)/dy1
&lt;/h3&gt;

&lt;p&gt;Since Predicted = y1 * w3 + y2 * w4 + b3, and all other terms are treated as constants w.r.t y1:&lt;/p&gt;

&lt;p&gt;d(predicted)/dy1 = w3&lt;/p&gt;

&lt;h3&gt;
  
  
  3. dy1/dx1
&lt;/h3&gt;

&lt;p&gt;Since y1 = log(1 + e^x1), the derivative of the softplus function is the logistic sigmoid function:&lt;/p&gt;

&lt;p&gt;dy1/dx1 = e^x1 / (1 + e^x1)&lt;/p&gt;

&lt;h3&gt;
  
  
  4. dx1/dw1
&lt;/h3&gt;

&lt;p&gt;Since x1 = input * w1 + b1, differentiating w.r.t w1 gives:&lt;/p&gt;

&lt;p&gt;dx1/dw1 = input&lt;/p&gt;

&lt;h3&gt;
  
  
  Final formula for dSSR/dw1:
&lt;/h3&gt;

&lt;p&gt;Multiplying these parts together, we get:&lt;/p&gt;

&lt;p&gt;dSSR/dw1 = -2 * (Observed - Predicted) * w3 * (e^x1 / (1 + e^x1)) * input&lt;/p&gt;

&lt;h2&gt;
  
  
  Deriving the Gradient for Bias b1
&lt;/h2&gt;

&lt;p&gt;Similarly, for the top neuron's bias b1:&lt;/p&gt;

&lt;p&gt;dSSR/db1 = dSSR/d(predicted) * d(predicted)/dy1 * dy1/dx1 * dx1/db1&lt;/p&gt;

&lt;p&gt;The only term that changes here is the last one:&lt;/p&gt;

&lt;p&gt;dx1/db1 = 1 (since x1 = input * w1 + b1, derivative w.r.t b1 is 1)&lt;/p&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;p&gt;dSSR/db1 = -2 * (Observed - Predicted) * w3 * (e^x1 / (1 + e^x1)) * 1&lt;/p&gt;

&lt;h2&gt;
  
  
  Deriving the Gradients for the Bottom Neuron (w2 and b2)
&lt;/h2&gt;

&lt;p&gt;Following the same logic, we can find the gradients for the bottom neuron's parameters:&lt;/p&gt;

&lt;h3&gt;
  
  
  For weight w2:
&lt;/h3&gt;

&lt;p&gt;dSSR/dw2 = dSSR/d(predicted) * d(predicted)/dy2 * dy2/dx2 * dx2/dw2&lt;/p&gt;

&lt;p&gt;dSSR/dw2 = -2 * (Observed - Predicted) * w4 * (e^x2 / (1 + e^x2)) * input&lt;/p&gt;

&lt;h3&gt;
  
  
  For bias b2:
&lt;/h3&gt;

&lt;p&gt;dSSR/db2 = dSSR/d(predicted) * d(predicted)/dy2 * dy2/dx2 * dx2/db2&lt;/p&gt;

&lt;p&gt;dSSR/db2 = -2 * (Observed - Predicted) * w4 * (e^x2 / (1 + e^x2)) * 1&lt;/p&gt;

&lt;h2&gt;
  
  
  Improving Prediction with self Learning
&lt;/h2&gt;

&lt;p&gt;Once we calculate all these derivatives (dSSR/dw1, dSSR/db1, dSSR/dw2, dSSR/db2), we can update the hidden layer weights and biases using gradient descent:&lt;/p&gt;

&lt;p&gt;Step size w1 = derivation w1 * Learning rate&lt;br&gt;
New w1 = old w1 - Step size w1&lt;/p&gt;

&lt;p&gt;Step size b1 = derivation b1 * Learning rate&lt;br&gt;
New b1 = old b1 - Step size b1&lt;/p&gt;

&lt;p&gt;Step size w2 = derivation w2 * Learning rate&lt;br&gt;
New w2 = old w2 - Step size w2&lt;/p&gt;

&lt;p&gt;Step size b2 = derivation b2 * Learning rate&lt;br&gt;
New b2 = old b2 - Step size b2&lt;/p&gt;

&lt;p&gt;By doing this repeatedly, the model minimizes the error and converges to the optimal values for all weights and biases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We have successfully derived the formulas to calculate the gradients for w1, b1, w2, and b2. Combined with the output layer derivations, we now have the math for the entire neural network's backpropagation!&lt;/p&gt;

&lt;p&gt;In the next article, we will see how to implement this in code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>deeplearning</category>
      <category>machinelearning</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding Backpropagation: Chain Rule, SSR Gradients, and Weight Updates in Neural Networks</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Tue, 23 Jun 2026 04:02:53 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-backpropagation-chain-rule-ssr-gradients-and-weight-updates-in-neural-networks-hkh</link>
      <guid>https://dev.to/ganesh-kumar/understanding-backpropagation-chain-rule-ssr-gradients-and-weight-updates-in-neural-networks-hkh</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous article, We derived fromula for pridicting b3 now we will understand how to dereive wieghts w3 and w4.&lt;/p&gt;

&lt;h2&gt;
  
  
  How wights are connected to previous output layer?
&lt;/h2&gt;

&lt;p&gt;In previous direvation we considered b3 as variable and w3 and w4 as constants. &lt;/p&gt;

&lt;p&gt;That means we need have w3 and w4 as a variable to find it's value.&lt;/p&gt;

&lt;p&gt;Wieghts w3 and w4 are multiplied to activation function of both top and bottom neurons.&lt;/p&gt;

&lt;p&gt;So, Actication function of top neuron is 1&lt;/p&gt;

&lt;p&gt;As it is soft plus function&lt;/p&gt;

&lt;p&gt;x1 = input x w1 + b1&lt;/p&gt;

&lt;p&gt;y1=f(x1)= log(1+e^x)&lt;/p&gt;

&lt;p&gt;Similarly for bottom neuron&lt;/p&gt;

&lt;p&gt;x2 = input x w2 + b2&lt;/p&gt;

&lt;p&gt;y2=f(x2)= log(1+e^x)&lt;/p&gt;

&lt;p&gt;So, Finaly we get &lt;/p&gt;

&lt;p&gt;Predicted = y1 * w3 + y2 * w4 + b3&lt;/p&gt;

&lt;p&gt;So, finaly we get &lt;/p&gt;

&lt;p&gt;SSR = Σ (observed − predicted)²&lt;/p&gt;

&lt;h2&gt;
  
  
  How Each Values are Calculated?
&lt;/h2&gt;

&lt;p&gt;Now By applying to previous formula by applying direvation w.r.t w3, w4 and b3.&lt;/p&gt;

&lt;p&gt;dSSR/dw3 = dSSR/d(predicted) * d(predicted)/dw3&lt;/p&gt;

&lt;p&gt;dSSR/dw4 = dSSR/d(predicted) * d(predicted)/dw4&lt;/p&gt;

&lt;p&gt;dSSR/db3 = dSSR/d(predicted) * d(predicted)/db3&lt;/p&gt;

&lt;p&gt;We can see dSSR/d(predicted) is common in all three direvation.&lt;/p&gt;

&lt;p&gt;dSSR/d(predicted) = 2 * (Predicted - Observed) * -1&lt;/p&gt;

&lt;p&gt;Now, for d(predicted)/dw3 &lt;/p&gt;

&lt;p&gt;d(predicted)/dw3 = d(y1 * w3 + y2 * w4 + b3)/dw3 = y1&lt;/p&gt;

&lt;p&gt;As remaining all are constant w.r.t w3. &lt;/p&gt;

&lt;p&gt;similarly for d(predicted)/dw4&lt;/p&gt;

&lt;p&gt;d(predicted)/dw4 = d(y1 * w3 + y2 * w4 + b3)/dw4 = y2&lt;/p&gt;

&lt;p&gt;As remaining all are constant w.r.t w4. &lt;/p&gt;

&lt;p&gt;Now, for d(predicted)/db3&lt;/p&gt;

&lt;p&gt;d(predicted)/db3 = d(y1 * w3 + y2 * w4 + b3)/db3 = 1&lt;/p&gt;

&lt;p&gt;As remaining all are constant w.r.t b3. &lt;/p&gt;

&lt;p&gt;Now Finaly we get &lt;/p&gt;

&lt;p&gt;dSSR/dw3 = dSSR/d(predicted) * d(predicted)/dw3 = 2 * (Predicted - Observed) * -1 * y1 = -2 * (Predicted - Observed) * y1&lt;/p&gt;

&lt;p&gt;dSSR/dw4 = dSSR/d(predicted) * d(predicted)/dw4 = 2 * (Predicted - Observed) * -1 * y2 = -2 * (Predicted - Observed) * y2&lt;/p&gt;

&lt;p&gt;dSSR/db3 = dSSR/d(predicted) * d(predicted)/db3 = 2 * (Predicted - Observed) * -1 * 1 = -2 * (Predicted - Observed)&lt;/p&gt;

&lt;h2&gt;
  
  
  Improving Prediction with self Learning
&lt;/h2&gt;

&lt;p&gt;Now we calculate dSSR/dw3, dSSR/dw4, and dSSR/db3.&lt;/p&gt;

&lt;p&gt;Then we try to make the value near to 0 hence making the error minimum.&lt;/p&gt;

&lt;p&gt;Step size = derivation * Learning rate&lt;/p&gt;

&lt;p&gt;New w3 = old w3 - Step size w3&lt;/p&gt;

&lt;p&gt;Do the same thing for w4 and b3&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We got an idea how weights are calculated for a single neuron. Now we can extend this idea to multi layers.&lt;/p&gt;

&lt;p&gt;In next article we will see how to calculate weights for multi layers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to calculate weights using gradient descent</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Fri, 19 Jun 2026 11:29:00 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/how-to-calculate-weights-using-gradient-descent-4caj</link>
      <guid>https://dev.to/ganesh-kumar/how-to-calculate-weights-using-gradient-descent-4caj</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous article, I explained the requirements for finding the weights of the last layer. Now let's see how we actually assign and optimize those weights using gradient descent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selecting Random Weights From a Normal Distribution
&lt;/h2&gt;

&lt;p&gt;First, we assign random numbers (drawn from a normal distribution) to the weights w3 and w4.&lt;/p&gt;

&lt;p&gt;Then we sum up both results along with the bias b3 = 0:&lt;/p&gt;

&lt;p&gt;predicted = (output of top neuron × w3) + (output of bottom neuron × w4) + b3&lt;/p&gt;

&lt;p&gt;This gives us our initial prediction, and we can plot the final graph:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fihfkif6jyy7wrwx0g276.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fihfkif6jyy7wrwx0g276.png" alt=" " width="799" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With these initial random weights, the SSR (Sum of Squared Residuals) is calculated again to measure how far off our predictions are.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gradient Descent Algorithm For Optimal Values
&lt;/h2&gt;

&lt;p&gt;Now we need to find the derivative of SSR with respect to b3 so we can update it.&lt;/p&gt;

&lt;p&gt;Recall our loss function:&lt;/p&gt;

&lt;p&gt;SSR = Σ (observed − predicted)²&lt;/p&gt;

&lt;p&gt;And our predicted value is:&lt;/p&gt;

&lt;p&gt;predicted = (output of top neuron × w3) + (output of bottom neuron × w4) + b3&lt;/p&gt;

&lt;p&gt;This is the same chain rule approach we used for backpropagation when optimizing only b3.&lt;/p&gt;

&lt;p&gt;The key insight here is that the products of w3 and w4 with their respective neuron outputs are treated as constants for a single gradient calculation with respect to b3. Since only b3 is the variable in this expression, the derivative simplifies cleanly — just as we saw in the previous articles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By assigning random weights from a normal distribution and then applying gradient descent with the chain rule, we can iteratively optimize each weight and bias in the network. The same process that worked for b3 alone now extends to w3 and w4 — we just need to carefully apply the chain rule at each step to compute the correct gradients.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Idea behind Full Backpropogation</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Wed, 17 Jun 2026 12:59:48 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-idea-behind-full-backpropogation-3fpg</link>
      <guid>https://dev.to/ganesh-kumar/understanding-idea-behind-full-backpropogation-3fpg</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous article, we learned how to calculate the gradient of the last bias in a neural network.&lt;/p&gt;

&lt;p&gt;Now we will explore how gradients flow through the entire network and how to calculate the weights of previous layers.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to calculate weights
&lt;/h2&gt;

&lt;p&gt;Now we will calculate weights of the previous layer&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiofmkjdlpbvn0qcg2pxz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiofmkjdlpbvn0qcg2pxz.png" alt=" " width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The challenge is that the loss function does not directly depend on these earlier weights.&lt;/p&gt;

&lt;p&gt;For example, consider a weight (w1 and w2 are already calculated ) in a hidden layer.&lt;/p&gt;

&lt;p&gt;Changing (w3 and w4):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Changes the hidden neuron output.&lt;/li&gt;
&lt;li&gt;Changes the output neuron input.&lt;/li&gt;
&lt;li&gt;Changes the final prediction.&lt;/li&gt;
&lt;li&gt;Changes the loss.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So there is an indirect relationship between the weight and the loss.&lt;/p&gt;

&lt;p&gt;This is exactly why we need the chain rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Similar to previous calculation we should also calculate for all weights and biases using chain rule and gradient descent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why Do Neural Networks Need the Chain Rule? How do we apply it?</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Sat, 13 Jun 2026 03:26:39 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/why-do-neural-networks-need-the-chain-rule-how-do-we-apply-it-o4a</link>
      <guid>https://dev.to/ganesh-kumar/why-do-neural-networks-need-the-chain-rule-how-do-we-apply-it-o4a</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous article, we introduced backpropagation and learned that neural networks improve by reducing prediction errors.&lt;/p&gt;

&lt;p&gt;We also saw that backpropagation relies on two fundamental ideas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Chain Rule&lt;/li&gt;
&lt;li&gt;Gradient Descent&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But we haven't yet answered an important question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How does we calculate wieghts and biases to decrease the error?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To answer that, let's look at a very small neural network.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Simple Neural Network
&lt;/h2&gt;

&lt;p&gt;Imagine a neural network with:&lt;br&gt;
Similar to the previous example.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One input neuron&lt;/li&gt;
&lt;li&gt;Two hidden neurons&lt;/li&gt;
&lt;li&gt;One output neuron&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foglgvjmvsnaazyrs0ufr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foglgvjmvsnaazyrs0ufr.png" alt=" " width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Calculating Last Bias In the last layer
&lt;/h2&gt;

&lt;p&gt;Let's asssume we have wieght and bias of all hidden layer and we only want to find last bias b3&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F45skgcm1gm49uvadmhff.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F45skgcm1gm49uvadmhff.png" alt=" " width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now from gradient descent, we can update the last bias b3 using the partial derivative of loss with respect to b3&lt;/p&gt;

&lt;p&gt;The Error rate is done with Residuals.&lt;br&gt;
Residual = Observed - Predicted&lt;/p&gt;

&lt;p&gt;SSR = Sum of (Observed - Predicted)^2&lt;/p&gt;

&lt;p&gt;So, We take 3 samples for training&lt;/p&gt;

&lt;p&gt;Starting, Ending and middle values.&lt;/p&gt;

&lt;p&gt;Finaly By calculating SSR.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use of Chain Rule
&lt;/h2&gt;

&lt;p&gt;We actually calculated b3 only using gradient descent.&lt;/p&gt;

&lt;p&gt;Now Using chain Value generated from the weight and bias of previous layers&lt;/p&gt;

&lt;p&gt;Predicted = Top Layer + Bottom Layer + Bias (b3)&lt;/p&gt;

&lt;p&gt;Using Chain Rule we can write Dirivative of SSR with  &lt;/p&gt;

&lt;p&gt;dssr/db3 = dssr/dpredicted * dpredicted/db3&lt;/p&gt;

&lt;p&gt;dssr/dpredicted = (Observed - Predicted)^2 &lt;/p&gt;

&lt;p&gt;As predicted, it is not constant and we are dirving it.&lt;/p&gt;

&lt;p&gt;dssr/dpredicted = 2*(Observed - Predicted)*(d(Observed - Predicted))/dpredicted)&lt;/p&gt;

&lt;p&gt;dssr/dpredicted = 2*(Observed - Predicted)&lt;em&gt;(-1)&lt;br&gt;
dssr/dpredicted = -2&lt;/em&gt;(Observed - Predicted)&lt;/p&gt;

&lt;p&gt;For dpredicted/db3&lt;/p&gt;

&lt;p&gt;dpredicted = Top Layer + Bottom Layer + Bias (b3)&lt;br&gt;
Both Top Layer and Bottom Layer is constant for this calculation&lt;br&gt;
dpredicted/db3 = 1&lt;/p&gt;

&lt;p&gt;Finaly dssr/db3 = -2*(Observed - Predicted) * 1&lt;/p&gt;

&lt;h2&gt;
  
  
  Slop Calculation and Learning
&lt;/h2&gt;

&lt;p&gt;Now we have 3 values of predicted for 3 samples&lt;/p&gt;

&lt;p&gt;dssr/db3 = Σ(-2*(Observed-Predicted))&lt;/p&gt;

&lt;p&gt;dssr/db3 = -2 * [(Observed1 - Predicted1) * 1 + (Observed2 - Predicted2) * 1 + (Observed3 - Predicted3) * 1]&lt;/p&gt;

&lt;p&gt;dssr/db3 = -2 * [(Residual1) + (Residual2) + (Residual3)]&lt;/p&gt;

&lt;p&gt;dssr/db3 = -2 * (ResidualSum)&lt;/p&gt;

&lt;p&gt;For our training data I got slope = -15.7&lt;/p&gt;

&lt;p&gt;step size = slope x learning rate&lt;/p&gt;

&lt;p&gt;step size = -15.7 x 0.1 = -1.57&lt;/p&gt;

&lt;p&gt;new b3 = old b3 + step size&lt;/p&gt;

&lt;p&gt;new b3 = 0 + (-1.57) = -1.57&lt;/p&gt;

&lt;p&gt;Then again, recalculating SSR with new b3 we got slop.&lt;/p&gt;

&lt;p&gt;slop = -6.26&lt;/p&gt;

&lt;p&gt;step size = -6.26 x 0.1 = -0.626&lt;/p&gt;

&lt;p&gt;new b3 = -1.57 + (-0.626) = -2.196&lt;/p&gt;

&lt;p&gt;Similarly after calculatinng multiple times utile we get step size close to 0.&lt;/p&gt;

&lt;p&gt;Final Result&lt;br&gt;
We found the optimal &lt;br&gt;
b3 = 2.21&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We could able to apply these chain rule, gradient descent and backpropagation in a very small neural network.&lt;/p&gt;

&lt;p&gt;In next article we will discuss how to calculate wieghts and biases in same neural network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Running OpenAPI Validation in GitHub Actions and Showing Findings in Pull Requests</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Wed, 10 Jun 2026 20:39:09 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/running-openapi-validation-in-github-actions-and-showing-findings-in-pull-requests-4n8i</link>
      <guid>https://dev.to/ganesh-kumar/running-openapi-validation-in-github-actions-and-showing-findings-in-pull-requests-4n8i</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In a previous article, I explained what SARIF is and why many security and quality tools use it as a common reporting format.&lt;/p&gt;

&lt;p&gt;In this article, we'll focus on a practical example: validating an OpenAPI specification in GitHub Actions and displaying findings directly inside GitHub Pull Requests.&lt;/p&gt;

&lt;p&gt;By the end, you'll have a workflow that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lints your OpenAPI specification&lt;/li&gt;
&lt;li&gt;Generates a SARIF report&lt;/li&gt;
&lt;li&gt;Uploads results to GitHub Code Scanning&lt;/li&gt;
&lt;li&gt;Shows annotations directly in Pull Requests&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sample OpenAPI Specification
&lt;/h2&gt;

&lt;p&gt;Let's start with a simple OpenAPI file that contains a deliberate issue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;openapi&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3.0.3&lt;/span&gt;

&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;User API&lt;/span&gt;
  &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1.0.0&lt;/span&gt;

&lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="s"&gt;/users/{id}&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;operationId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;getUserById&lt;/span&gt;

      &lt;span class="na"&gt;parameters&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;userId&lt;/span&gt;
          &lt;span class="na"&gt;in&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;path&lt;/span&gt;
          &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
          &lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;string&lt;/span&gt;

      &lt;span class="na"&gt;responses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;200"&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;User found&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that the path is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/users/{id}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but the parameter is named:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;userId
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parameter name should match the path placeholder (&lt;code&gt;id&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;We'll use this mistake to verify that our workflow correctly reports findings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Spectral
&lt;/h2&gt;

&lt;p&gt;For this example, we'll use Spectral, one of the most popular OpenAPI linting tools.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @stoplight/spectral-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;spectral lint openapi.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see an error related to the path parameter mismatch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating a SARIF Report
&lt;/h2&gt;

&lt;p&gt;Instead of printing results to the console, we can generate a SARIF report:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;spectral lint openapi.yaml &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--format&lt;/span&gt; sarif &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--output&lt;/span&gt; results.sarif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This produces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;results.sarif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which GitHub can consume directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub Actions Workflow
&lt;/h2&gt;

&lt;p&gt;Create:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.github/workflows/openapi.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;OpenAPI Validation&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pull_request&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;

&lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;
  &lt;span class="na"&gt;security-events&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;write&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;openapi&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;

    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-node@v4&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;node-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install Spectral&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm install -g @stoplight/spectral-cli&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Generate SARIF Report&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;spectral lint openapi.yaml \&lt;/span&gt;
            &lt;span class="s"&gt;--format sarif \&lt;/span&gt;
            &lt;span class="s"&gt;--output results.sarif&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Upload SARIF&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github/codeql-action/upload-sarif@v3&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;sarif_file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;results.sarif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;The workflow performs four simple steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Checks out the repository&lt;/li&gt;
&lt;li&gt;Installs Spectral&lt;/li&gt;
&lt;li&gt;Generates a SARIF report&lt;/li&gt;
&lt;li&gt;Uploads the SARIF report to GitHub&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The upload step is handled by GitHub's official SARIF uploader:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github/codeql-action/upload-sarif@v3&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;sarif_file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;results.sarif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once uploaded, GitHub automatically processes the findings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Viewing Results in Pull Requests
&lt;/h2&gt;

&lt;p&gt;After opening a Pull Request, GitHub analyzes the uploaded SARIF report and associates findings with the corresponding files and lines.&lt;/p&gt;

&lt;p&gt;For our example, GitHub highlights the parameter definition and reports something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Path parameter "id" is not defined.
Expected parameter name "id" but found "userId".
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Developers can review the issue directly from the Pull Request without searching through GitHub Action logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I Prefer This Approach
&lt;/h2&gt;

&lt;p&gt;Many teams fail OpenAPI validation jobs and require developers to inspect CI logs.&lt;/p&gt;

&lt;p&gt;While this works, it doesn't scale well when repositories contain multiple specifications or many validation rules.&lt;/p&gt;

&lt;p&gt;Uploading SARIF results provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inline annotations&lt;/li&gt;
&lt;li&gt;Better visibility during code review&lt;/li&gt;
&lt;li&gt;Centralized findings in GitHub Code Scanning&lt;/li&gt;
&lt;li&gt;Consistent reporting across different tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same workflow can later be extended to include security scanners, secret scanners, IaC scanners, and custom validation tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Integrating OpenAPI validation into GitHub Actions is straightforward. With Spectral generating SARIF output and GitHub handling the presentation layer, developers receive feedback exactly where they are already reviewing code: inside the Pull Request.&lt;/p&gt;

&lt;p&gt;If your organization already uses SARIF for other security or quality tools, OpenAPI validation can fit naturally into the same workflow with only a few lines of configuration.&lt;br&gt;
&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>automation</category>
      <category>githubactions</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What Is SARIF and How Does It Help Security Tools Work Together?</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Mon, 08 Jun 2026 20:28:21 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/what-is-sarif-and-how-does-it-help-security-tools-work-together-4743</link>
      <guid>https://dev.to/ganesh-kumar/what-is-sarif-and-how-does-it-help-security-tools-work-together-4743</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;If you've ever worked with tools like Semgrep, Trivy, Checkov, Gitleaks, or CodeQL, you've probably noticed that each tool produces results in a different format. Some output JSON, some use XML, while others generate plain text reports.&lt;/p&gt;

&lt;p&gt;This creates a problem: how do you aggregate multiple tools results from multiple tools into a single platform?&lt;/p&gt;

&lt;p&gt;That's where SARIF comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is SARIF?
&lt;/h2&gt;

&lt;p&gt;SARIF stands for &lt;strong&gt;Static Analysis Results Interchange Format&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is an open standard designed to represent findings from static analysis tools, security scanners, linters, and code quality tools in a common format.&lt;/p&gt;

&lt;p&gt;Think of SARIF as a universal translator.&lt;/p&gt;

&lt;p&gt;Instead of every tool speaking its own language:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Semgrep -&amp;gt; Semgrep JSON
Trivy -&amp;gt; Trivy JSON
Checkov -&amp;gt; Checkov JSON
Gitleaks -&amp;gt; Gitleaks JSON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SARIF allows all of them to communicate using a shared structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Semgrep
Trivy
Checkov
Gitleaks
    ↓
   SARIF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why Was SARIF Created?
&lt;/h2&gt;

&lt;p&gt;Imagine a company running 20 different scanners in its CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;Each scanner reports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Different severity levels&lt;/li&gt;
&lt;li&gt;Different file formats&lt;/li&gt;
&lt;li&gt;Different metadata&lt;/li&gt;
&lt;li&gt;Different output structures&lt;/li&gt;
&lt;li&gt;Different CVE&lt;/li&gt;
&lt;li&gt;Different CVSS scores&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Building integrations for every tool becomes difficult and expensive.&lt;/p&gt;

&lt;p&gt;SARIF solves this problem by providing a standardized schema for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rule IDs&lt;/li&gt;
&lt;li&gt;Messages&lt;/li&gt;
&lt;li&gt;Severity&lt;/li&gt;
&lt;li&gt;File locations&lt;/li&gt;
&lt;li&gt;Code snippets&lt;/li&gt;
&lt;li&gt;Security metadata&lt;/li&gt;
&lt;li&gt;Fix suggestions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows platforms to consume results from many tools without writing custom integrations for each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Simple Example
&lt;/h2&gt;

&lt;p&gt;Suppose a security scanner finds a vulnerability:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;File: app.py
Line: 42
Severity: High
Message: Possible SQL Injection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In SARIF, that information becomes structured JSON that any compatible platform can understand.&lt;/p&gt;

&lt;p&gt;The scanner changes, but the format remains the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  How SARIF Helps Developers
&lt;/h2&gt;

&lt;h3&gt;
  
  
  One Format for Many Tools
&lt;/h3&gt;

&lt;p&gt;Instead of handling dozens of output formats:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tool A -&amp;gt; Format A
Tool B -&amp;gt; Format B
Tool C -&amp;gt; Format C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can standardize on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tool A
Tool B
Tool C
   ↓
 SARIF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Better Tool Interoperability
&lt;/h3&gt;

&lt;p&gt;A SARIF file generated by one tool can be consumed by another platform without modification.&lt;/p&gt;

&lt;p&gt;This makes integrations significantly easier.&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub Code Scanning Support
&lt;/h3&gt;

&lt;p&gt;One of the biggest reasons SARIF became popular is GitHub Code Scanning.&lt;/p&gt;

&lt;p&gt;GitHub accepts SARIF uploads and automatically displays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Security findings&lt;/li&gt;
&lt;li&gt;Code quality issues&lt;/li&gt;
&lt;li&gt;Vulnerabilities&lt;/li&gt;
&lt;li&gt;File-level annotations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;directly inside pull requests and repositories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Easier Aggregation
&lt;/h3&gt;

&lt;p&gt;Organizations often run multiple scanners:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Semgrep
Trivy
Checkov
Gitleaks
Bandit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SARIF makes it possible to combine all findings into a single report.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;SARIF is a common language that allows tools to exchange findings in a standard way.&lt;/p&gt;

&lt;p&gt;As the number of security and code analysis tools continues to grow, standards like SARIF help reduce integration complexity and make tool ecosystems work together more effectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Backpropagation: How Neural Networks Learn from Their Mistakes</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Sat, 06 Jun 2026 19:46:43 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-backpropagation-how-neural-networks-learn-from-their-mistakes-27i8</link>
      <guid>https://dev.to/ganesh-kumar/understanding-backpropagation-how-neural-networks-learn-from-their-mistakes-27i8</guid>
      <description>&lt;h2&gt;
  
  
  From Linear Regression to Gradient Descent
&lt;/h2&gt;

&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In previous parts we discussed about linear regression, gradient descent and how to calculate the optimal slope and intercept using Gradient Descent.&lt;/p&gt;

&lt;p&gt;In this article, we'll build an intuition for backpropagation, understand why it is necessary, and explore how the chain rule and gradient descent work together to enable neural network learning.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Backpropagation?
&lt;/h2&gt;

&lt;p&gt;Backpropagation is an algorithm used to train neural networks. &lt;/p&gt;

&lt;p&gt;It is a way to adjust the weights and biases of a neural network to reduce the error between the predicted output and the actual output. &lt;/p&gt;

&lt;p&gt;In simple terms, it is a way for the neural network to learn from its mistakes.&lt;/p&gt;

&lt;p&gt;This learning process is powered by an algorithm called &lt;strong&gt;backpropagation&lt;/strong&gt;, one of the most important concepts in machine learning. Backpropagation provides a systematic way for a neural network to determine which internal parameters contributed to an error and how those parameters should be updated to reduce future mistakes.&lt;/p&gt;

&lt;p&gt;Imagine teaching a student to solve math problems. &lt;/p&gt;

&lt;p&gt;After each attempt, you compare the student's answer with the correct one, identify where mistakes occurred, and provide feedback. Over time, the student adjusts their approach and improves. Backpropagation works in a similar way: the network makes a prediction, calculates the error, traces that error backward through the network, and updates its parameters accordingly.&lt;/p&gt;

&lt;p&gt;At its core, backpropagation combines two fundamental mathematical ideas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Chain Rule&lt;/strong&gt; from calculus, which helps determine how changes in one part of the network affect the final error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gradient Descent&lt;/strong&gt;, an optimization technique that uses those calculations to update the network's parameters in the direction that reduces error.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By repeatedly answering these questions across thousands or millions of training examples, neural networks gradually learn patterns hidden within data and become increasingly accurate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why can't we just use one storage technology for everything?</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Thu, 04 Jun 2026 19:41:14 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/why-cant-we-just-use-one-storage-technology-for-everything-57c7</link>
      <guid>https://dev.to/ganesh-kumar/why-cant-we-just-use-one-storage-technology-for-everything-57c7</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;Modern computers use multiple storage and memory technologies because no single medium can simultaneously provide massive capacity, ultra-low latency, high bandwidth, and low cost. &lt;/p&gt;

&lt;p&gt;Every level of the memory hierarchy represents a tradeoff between these characteristics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is there a memory hierarchy?
&lt;/h2&gt;

&lt;p&gt;This is because each storage technology has its own advantages and disadvantages. We can't use one storage technology for all the purposes. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fks18859at0gs6ki8iaf2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fks18859at0gs6ki8iaf2.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The main characteristics to consider are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Capacity&lt;/li&gt;
&lt;li&gt;Latency&lt;/li&gt;
&lt;li&gt;Bandwidth&lt;/li&gt;
&lt;li&gt;Cost&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each Storage technology is optimized for a specific purpose.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
Imagine you have to travel from one place to another.&lt;br&gt;
You can go with walking, bicycle, car, train, or plane.&lt;/p&gt;

&lt;p&gt;Each mode of transport has its own advantages and disadvantages.&lt;/p&gt;

&lt;p&gt;Another better example is think of using LLM model.&lt;/p&gt;

&lt;p&gt;Depending on task complexity and size of data we can choose the model.&lt;/p&gt;

&lt;p&gt;If we mess up with choosing model we will not get the desired output wheather cost will rise, or response will be very low quality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkbezlinq0263gq2jrs2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkbezlinq0263gq2jrs2.png" alt=" " width="720" height="813"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Memory Hierarchy
&lt;/h2&gt;

&lt;p&gt;Now I have listed down the memory hierarchy From top to bottom.&lt;/p&gt;

&lt;h3&gt;
  
  
  CPU Registers
&lt;/h3&gt;

&lt;p&gt;This is the fastest storage available inside a processor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Role:&lt;/strong&gt; &lt;br&gt;
Stores values currently being operated on by the CPU.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Capacity&lt;/td&gt;
&lt;td&gt;Extremely small (typically 32 × 64-bit registers per core)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency&lt;/td&gt;
&lt;td&gt;~0.3 ns (about one CPU cycle)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bandwidth&lt;/td&gt;
&lt;td&gt;Highest in the system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Highest cost per bit (16 transistors per bit)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  CPU Cache (L1, L2, L3)
&lt;/h3&gt;

&lt;p&gt;A small, ultra-fast memory layer designed to keep frequently used data close to the processor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Role:&lt;/strong&gt; Reduces the need to access slower main memory.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Capacity&lt;/td&gt;
&lt;td&gt;Small (tens of MB total)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency&lt;/td&gt;
&lt;td&gt;~7.5 ns (L3 cache)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bandwidth&lt;/td&gt;
&lt;td&gt;Extremely high&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Very expensive (SRAM, 6 transistors per bit)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  DRAM (Main Memory)
&lt;/h3&gt;

&lt;p&gt;The working memory used by applications and operating systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Role:&lt;/strong&gt; Holds active programs and data currently being used.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Capacity&lt;/td&gt;
&lt;td&gt;Typically 32 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency&lt;/td&gt;
&lt;td&gt;~45 ns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bandwidth&lt;/td&gt;
&lt;td&gt;~48 GB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Higher than storage drives&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  GPU VRAM
&lt;/h3&gt;

&lt;p&gt;Memory optimized for throughput rather than low latency.&lt;br&gt;
&lt;strong&gt;Role:&lt;/strong&gt; Feeds large amounts of data to thousands of GPU cores simultaneously.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Capacity&lt;/td&gt;
&lt;td&gt;~24 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency&lt;/td&gt;
&lt;td&gt;~250 ns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bandwidth&lt;/td&gt;
&lt;td&gt;Extremely high&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Expensive&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  NVMe SSD
&lt;/h3&gt;

&lt;p&gt;High-speed solid-state storage connected through PCIe.&lt;br&gt;
&lt;strong&gt;Role:&lt;/strong&gt; Fast persistent storage for operating systems, applications, and files.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Capacity&lt;/td&gt;
&lt;td&gt;~2 TB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read Latency&lt;/td&gt;
&lt;td&gt;~80 μs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write Latency&lt;/td&gt;
&lt;td&gt;~500 μs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bandwidth&lt;/td&gt;
&lt;td&gt;~5 GB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;~7 cents per GB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  SATA SSD
&lt;/h3&gt;

&lt;p&gt;An older solid-state storage technology using the SATA interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Role:&lt;/strong&gt; Affordable solid-state storage with lower performance than NVMe.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Capacity&lt;/td&gt;
&lt;td&gt;Up to ~4 TB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency&lt;/td&gt;
&lt;td&gt;~120 μs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bandwidth&lt;/td&gt;
&lt;td&gt;Lower than NVMe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Similar to NVMe SSDs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Hard Disk Drive (HDD)
&lt;/h3&gt;

&lt;p&gt;Mechanical storage using spinning magnetic platters.&lt;br&gt;
&lt;strong&gt;Role:&lt;/strong&gt; Lowest-cost local storage for large datasets and archives.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Capacity&lt;/td&gt;
&lt;td&gt;~8 TB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency&lt;/td&gt;
&lt;td&gt;~8.3–10 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bandwidth&lt;/td&gt;
&lt;td&gt;Very low compared to SSDs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;~1–2 cents per GB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  The Fundamental Tradeoff
&lt;/h1&gt;

&lt;p&gt;As we move down the memory hierarchy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Capacity increases.&lt;/li&gt;
&lt;li&gt;Cost per GB decreases.&lt;/li&gt;
&lt;li&gt;Latency increases.&lt;/li&gt;
&lt;li&gt;Access speed decreases.&lt;/li&gt;
&lt;li&gt;Distance from the processor increases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjl30723a19ekijvs2jpj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjl30723a19ekijvs2jpj.png" alt=" " width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By leveraging this trade-off, modern computers use a hierarchy of registers, cache, memory, SSDs, HDDs, and cloud storage instead of relying on a single storage technology.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Credits
&lt;/h2&gt;

&lt;p&gt;Here are the sources that inspired me to write an article on this topic.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=TfhL5kBiQVI&amp;amp;t=145s" rel="noopener noreferrer"&gt;Why Don’t Computers Just Use One Type of Memory?&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>architecture</category>
      <category>computerscience</category>
      <category>performance</category>
      <category>systems</category>
    </item>
    <item>
      <title>From Linear Regression to Gradient Descent</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Thu, 04 Jun 2026 06:14:59 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/from-linear-regression-to-gradient-descent-4k5p</link>
      <guid>https://dev.to/ganesh-kumar/from-linear-regression-to-gradient-descent-4k5p</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous section, we learned that linear regression finds the best-fitting line by determining the optimal slope and intercept.&lt;/p&gt;

&lt;p&gt;In this article, we will discuss how to calculate the optimal slope and intercept using Gradient Descent.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to calculate the optimal slope and intercept using Gradient Descent
&lt;/h2&gt;

&lt;p&gt;The quality of that line is measured using the Sum of Squared Residuals (SSR), which represents the total prediction error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SSR = sum( (y_observed - y_predicted)^2 )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The best regression line is simply the line that produces the smallest SSR.&lt;/p&gt;

&lt;p&gt;When studying linear regression, it's easy to think that the slope and intercept magically appear from a formula. In reality, they are the values that minimize the prediction error. This is where Gradient Descent comes in.&lt;/p&gt;

&lt;p&gt;Instead of calculating the optimal slope and intercept directly using a closed-form equation, Gradient Descent starts with arbitrary values and gradually improves them. After each step, it measures how the SSR changes and adjusts the parameters in the direction that reduces the error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step Gradient Descent Example
&lt;/h2&gt;

&lt;p&gt;Let's illustrate how Gradient Descent works using the exact same dataset of 4 points from Part 10:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The Dataset
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Point 1:&lt;/strong&gt; (1, 2)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Point 2:&lt;/strong&gt; (2, 3)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Point 3:&lt;/strong&gt; (3, 5)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Point 4:&lt;/strong&gt; (4, 4)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Simplifying the Problem
&lt;/h3&gt;

&lt;p&gt;To make the math easy to trace, we will hold the &lt;strong&gt;Slope (m)&lt;/strong&gt; constant at its optimal value of &lt;strong&gt;0.8&lt;/strong&gt; and focus purely on finding the optimal &lt;strong&gt;Intercept (b)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Our prediction equation is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;y_predicted = 0.8 * x + b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We start with an initial guess for the intercept: &lt;code&gt;b = 0&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Calculating the Initial SSR (at b = 0)
&lt;/h3&gt;

&lt;p&gt;Let's find the predicted values and calculate the residuals (&lt;code&gt;observed - predicted&lt;/code&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;For Point 1 (1, 2):&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;y_predicted = 0.8 * 1 + 0 = 0.8&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Residual_1 = 2 - 0.8 = 1.2&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;For Point 2 (2, 3):&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;y_predicted = 0.8 * 2 + 0 = 1.6&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Residual_2 = 3 - 1.6 = 1.4&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;For Point 3 (3, 5):&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;y_predicted = 0.8 * 3 + 0 = 2.4&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Residual_3 = 5 - 2.4 = 2.6&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;For Point 4 (4, 4):&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;y_predicted = 0.8 * 4 + 0 = 3.2&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Residual_4 = 4 - 3.2 = 0.8&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Now, sum the squared residuals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SSR = 1.2^2 + 1.4^2 + 2.6^2 + 0.8^2
    = 1.44 + 1.96 + 6.76 + 0.64
    = 10.8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Derivation of the Gradient (d(SSR)/db)
&lt;/h3&gt;

&lt;p&gt;To know which direction to move the intercept &lt;code&gt;b&lt;/code&gt; and by how much, we take the derivative of SSR with respect to &lt;code&gt;b&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SSR = sum( (y_observed - (0.8 * x_observed + b))^2 )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Applying the chain rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d(SSR)/db = sum( 2 * (y_observed - (0.8 * x_observed + b)) * (-1) )
          = -2 * sum( y_observed - y_predicted )
          = -2 * sum( Residuals )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gradient is simply &lt;strong&gt;-2 times the sum of the residuals&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Updating the Intercept
&lt;/h3&gt;

&lt;p&gt;The update rule is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;b_new = b_old - (Learning Rate * Gradient)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's choose a &lt;strong&gt;Learning Rate (LR)&lt;/strong&gt; of &lt;strong&gt;0.1&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gradient:&lt;/strong&gt; &lt;code&gt;d(SSR)/db = -2 * (1.2 + 1.4 + 2.6 + 0.8) = -2 * 6.0 = -12.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step Size:&lt;/strong&gt; &lt;code&gt;Gradient * LR = -12.0 * 0.1 = -1.2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New Intercept:&lt;/strong&gt; &lt;code&gt;b_new = 0 - (-1.2) = 1.2&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With &lt;code&gt;b = 1.2&lt;/code&gt;, the predictions are closer to the actual values.&lt;/li&gt;
&lt;li&gt;The new residuals are: &lt;code&gt;0.0&lt;/code&gt;, &lt;code&gt;0.2&lt;/code&gt;, &lt;code&gt;1.4&lt;/code&gt;, and &lt;code&gt;-0.4&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSR:&lt;/strong&gt; &lt;code&gt;0.0^2 + 0.2^2 + 1.4^2 + (-0.4)^2 = 2.16&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gradient:&lt;/strong&gt; &lt;code&gt;-2 * (0.0 + 0.2 + 1.4 - 0.4) = -2.4&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step Size:&lt;/strong&gt; &lt;code&gt;-2.4 * 0.1 = -0.24&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New Intercept:&lt;/strong&gt; &lt;code&gt;b_new = 1.2 - (-0.24) = 1.44&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Step 3 (Convergence):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With &lt;code&gt;b = 1.44&lt;/code&gt;, the new residuals are: &lt;code&gt;-0.24&lt;/code&gt;, &lt;code&gt;-0.04&lt;/code&gt;, &lt;code&gt;1.16&lt;/code&gt;, and &lt;code&gt;-0.64&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gradient:&lt;/strong&gt; &lt;code&gt;-2 * (-0.24 - 0.04 + 1.16 - 0.64) = -0.48&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step Size:&lt;/strong&gt; &lt;code&gt;-0.48 * 0.1 = -0.048&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New Intercept:&lt;/strong&gt; &lt;code&gt;b_new = 1.44 - (-0.048) = 1.488&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;We repeat this loop. As we approach the optimal intercept, the residuals sum up closer to 0, which shrinks the gradient and steps.&lt;/li&gt;
&lt;li&gt;After several iterations, the gradient becomes 0, and the intercept converges to the exact optimal value of &lt;strong&gt;1.5&lt;/strong&gt; (where SSR reaches its minimum value of &lt;strong&gt;1.8&lt;/strong&gt;).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We started with an arbitrary intercept of &lt;strong&gt;0&lt;/strong&gt; and adjusted it step-by-step. Each step was guided by the gradient, which told us exactly how much to change the intercept to reduce the prediction error (SSR). We repeated this process until the error reached its minimum.&lt;/p&gt;

&lt;p&gt;While this example focused on a simple linear regression with a single variable, this same principle applies to deep neural networks with millions of parameters. Gradient descent is the engine that drives learning in machine learning.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/4JW4rfheX3U"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png" alt="git-lrc" width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

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