<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Chain-Rule on Sanketh's Blog</title><link>https://sankethbk.github.io/blog/tags/chain-rule/</link><description>Recent content in Chain-Rule on Sanketh's Blog</description><generator>Hugo -- 0.166.0</generator><language>en-us</language><lastBuildDate>Sat, 12 Sep 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://sankethbk.github.io/blog/tags/chain-rule/index.xml" rel="self" type="application/rss+xml"/><item><title>Backpropagation in a Fully-Connected Network, From Scratch</title><link>https://sankethbk.github.io/blog/posts/ml/2026-09-12-3-backpropagation-in-a-fully-connected-network/</link><pubDate>Sat, 12 Sep 2026 00:00:00 +0000</pubDate><guid>https://sankethbk.github.io/blog/posts/ml/2026-09-12-3-backpropagation-in-a-fully-connected-network/</guid><description>&lt;ul&gt;
&lt;li&gt;Why is there no deadlock in the order of corrections?&lt;/li&gt;
&lt;li&gt;Why is this cheap enough to do for billions of parameters?&lt;/li&gt;
&lt;li&gt;What is PyTorch&amp;rsquo;s autograd doing when you call &lt;code&gt;loss.backward()&lt;/code&gt;?&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="1-what-you-will-learn"&gt;1. What you will learn&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;The shape of a fully-connected (dense) network and what &amp;ldquo;fully-connected&amp;rdquo; means.&lt;/li&gt;
&lt;li&gt;How to forward a single training example through every operation, by hand.&lt;/li&gt;
&lt;li&gt;The backward pass as a message-passing process, with the exact algebra at each edge.&lt;/li&gt;
&lt;li&gt;The recursion that lets you go from 2 layers to 100 layers.&lt;/li&gt;
&lt;li&gt;Why nothing breaks due to ordering — the backward pass &lt;em&gt;computes&lt;/em&gt; gradients; it does not &lt;em&gt;apply&lt;/em&gt; updates.&lt;/li&gt;
&lt;li&gt;Why backprop costs about one extra forward pass, not one forward pass per parameter.&lt;/li&gt;
&lt;li&gt;A pseudocode implementation of the whole algorithm.&lt;/li&gt;
&lt;li&gt;What an autograd engine records, and how &lt;code&gt;loss.backward()&lt;/code&gt; / &lt;code&gt;optimizer.step()&lt;/code&gt; / &lt;code&gt;optimizer.zero_grad()&lt;/code&gt; map onto what we do by hand.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="2-the-network-we-are-going-to-train"&gt;2. The network we are going to train&lt;/h2&gt;
&lt;p&gt;Logistic regression is a single layer: input → weighted sum → sigmoid → probability. Its decision boundary is a line (or hyperplane). There is a famous class of problems it cannot solve — XOR is the classic example — where no single line separates the two classes.&lt;/p&gt;</description></item><item><title>Computational Graphs, Part 2: Branching — Why Gradients Add</title><link>https://sankethbk.github.io/blog/posts/ml/2026-09-12-1-branching-why-gradients-add/</link><pubDate>Sat, 12 Sep 2026 00:00:00 +0000</pubDate><guid>https://sankethbk.github.io/blog/posts/ml/2026-09-12-1-branching-why-gradients-add/</guid><description>&lt;h1 id="computational-graphs-part-2-branching--why-gradients-add"&gt;Computational Graphs, Part 2: Branching — Why Gradients Add&lt;/h1&gt;
&lt;p&gt;The &lt;a href="https://sankethbk.github.io/blog/posts/ml/2026-09-09-computational-graphs-and-backpropagation"&gt;previous note&lt;/a&gt; covered the forward pass, the chain rule, and the backward pass on a graph where every input had exactly one path to the output. This note adds the one remaining piece: what happens when an input feeds into &lt;strong&gt;more than one&lt;/strong&gt; operation.&lt;/p&gt;
&lt;p&gt;When that happens, there are multiple paths from the input to the output. The chain rule tells us to &lt;strong&gt;add&lt;/strong&gt; the contributions from those paths.&lt;/p&gt;</description></item><item><title>Computational Graphs and Backpropagation</title><link>https://sankethbk.github.io/blog/posts/ml/2026-09-09-computational-graphs-and-backpropagation/</link><pubDate>Wed, 09 Sep 2026 00:00:00 +0000</pubDate><guid>https://sankethbk.github.io/blog/posts/ml/2026-09-09-computational-graphs-and-backpropagation/</guid><description>&lt;h1 id="computational-graphs-and-backpropagation"&gt;Computational Graphs and Backpropagation&lt;/h1&gt;
&lt;p&gt;This note explains how to compute gradients for any function by breaking it into a graph of simple operations. It is the bridge between the gradient-descent picture from the &lt;a href="https://sankethbk.github.io/blog/posts/ml/2026-09-07-ml-refresher-linear-logistic-regression"&gt;linear and logistic regression note&lt;/a&gt; and the layered functions we will later call neural networks.&lt;/p&gt;
&lt;p&gt;The ideas are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Draw the function as a graph of operations.&lt;/li&gt;
&lt;li&gt;Evaluate the graph from inputs to output: the &lt;strong&gt;forward pass&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use the chain rule to carry sensitivities from the output back to the inputs: the &lt;strong&gt;backward pass&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We build this on one tiny example and walk through every step.&lt;/p&gt;</description></item></channel></rss>