<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged weights</title>
<link>https://coderlegion.com/tag/weights</link>
<description>Powered by Question2Answer</description>
<item>
<title>Understanding Idea behind Full Backpropogation</title>
<link>https://coderlegion.com/21634/understanding-idea-behind-full-backpropogation</link>
<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=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&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 rel=&quot;nofollow&quot; href=&quot;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&quot; class=&quot;article-body-image-wrapper&quot;&gt;&lt;img src=&quot;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&quot; alt=&quot;&quot; width=&quot;800&quot; height=&quot;486&quot;&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=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;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&quot; alt=&quot;git-lrc&quot; width=&quot;360&quot; height=&quot;540&quot;&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&amp;#11088; &lt;a href=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;
</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/21634/understanding-idea-behind-full-backpropogation</guid>
<pubDate>Thu, 02 Jul 2026 18:14:45 +0000</pubDate>
</item>
<item>
<title>How to calculate weights using gradient descent</title>
<link>https://coderlegion.com/21633/how-to-calculate-weights-using-gradient-descent</link>
<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=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&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 &amp;times; w3) + (output of bottom neuron &amp;times; 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 rel=&quot;nofollow&quot; href=&quot;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&quot; class=&quot;article-body-image-wrapper&quot;&gt;&lt;img src=&quot;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&quot; alt=&quot;&quot; width=&quot;799&quot; height=&quot;326&quot;&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 = &amp;Sigma; (observed &amp;minus; predicted)&amp;sup2;&lt;/p&gt;

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

&lt;p&gt;predicted = (output of top neuron &amp;times; w3) + (output of bottom neuron &amp;times; 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 &amp;mdash; 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 &amp;mdash; 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=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;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&quot; alt=&quot;git-lrc&quot; width=&quot;360&quot; height=&quot;540&quot;&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;&amp;#11088; &lt;a href=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;
</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/21633/how-to-calculate-weights-using-gradient-descent</guid>
<pubDate>Thu, 02 Jul 2026 02:57:30 +0000</pubDate>
</item>
</channel>
</rss>