<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mayank Kaushik on Medium]]></title>
        <description><![CDATA[Stories by Mayank Kaushik on Medium]]></description>
        <link>https://medium.com/@mayank.utexas?source=rss-44d5d3d113e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BSkls-wVt3F64xxe.jpg</url>
            <title>Stories by Mayank Kaushik on Medium</title>
            <link>https://medium.com/@mayank.utexas?source=rss-44d5d3d113e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 05:03:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mayank.utexas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Part 2: Backpropagation for Convolution with Strides]]></title>
            <link>https://medium.com/@mayank.utexas/backpropagation-for-convolution-with-strides-fb2f2efc4faa?source=rss-44d5d3d113e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb2f2efc4faa</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[backpropagation]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <category><![CDATA[strided-convolution]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mayank Kaushik]]></dc:creator>
            <pubDate>Fri, 03 May 2019 06:06:35 GMT</pubDate>
            <atom:updated>2019-05-04T20:27:42.655Z</atom:updated>
            <content:encoded><![CDATA[<h4>Loss gradient with respect to the filter (weight) tensor</h4><p>There are several examples of Backpropagation with Convolution, but almost all of them assume a stride of 1. This article provides a visual example of Backpropagation with a stride &gt; 1. Along the way, this hopefully exercise also provides some intuition for why the filter needs to be rotated for Backpropagation.</p><p>(<strong><em>Part 1 can be found here: </em></strong><a href="https://medium.com/@mayank.utexas/backpropagation-for-convolution-with-strides-8137e4fc2710"><strong><em>Loss gradient with respect to the Input</em></strong></a><em>)</em></p><p>We’ll use the following example dimensions for our input, filter, and output tensors. Note that we’re using horizontal and vertical strides of 2 here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kjwmx11ofv-IMTwf8r93Yw.png" /><figcaption>Dimensions of the tensors we’re working with</figcaption></figure><p>To set things up, let us first express look at the forward propagation step to express the output pixels as functions of the input activations and filter contents (the weights). This, of course, is quite straightforward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*3l5APR4As-yhTv7HX_kaZw.gif" /><figcaption>Forward propagation</figcaption></figure><p>Here’s what we need to do in the Backpropagation step: given the gradient of the loss with respect to the output pixels, we need to calculate the gradient of the loss with respect to the filter pixels (aka the weight tensor).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*CJ-3eyWUCtWDi122zGcJBQ.png" /><figcaption>Backpropagation of gradients</figcaption></figure><p>Unlike the input pixels <em>x </em>that may only contribute to a few output pixels, each filter pixel <em>f</em> in our example contributes to all output pixels (this is visualized in more detail below). Using the chain rule and partial differentiation principles, the total gradient of the loss with respect to each filter pixel can be expressed in terms of gradients of each output pixel with respect to the filter, multiplied by the gradient of the loss with respect to that output pixel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*MuNYZtlJ6_vsCEOngDVd0Q.png" /></figure><p>We’ll examine the following equations that were generated during forward propagation to determine the filter gradients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*J2UeXtJ38zKgwrJ5av3G6A.png" /></figure><p>With this knowledge, let us calculate the gradients for a few example filter pixels step by step, before we see the full Backpropagation in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-R_ccVcjFrc5RjDYmc9oeQ.png" /><figcaption>Example 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LPjyaCJ5xTZEhfJZsbDKPg.png" /><figcaption>Example 2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6HtD80lqC_l4FAyqkUNVg.png" /><figcaption>Example 3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A5keeUm7Zq0NTv2LJhzNPQ.png" /><figcaption>Example 4</figcaption></figure><p>To uncover the underlying pattern in the values of these filter gradients, we’ll need to modify the output gradient tensor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*luRORFyTmj9mJ7rVhzlbZA.png" /><figcaption>Dilate the output gradient pixels with stride_R — 1 zeroes vertically, and stride_S — 1 zeros horizontally.</figcaption></figure><p>With this modification to the output gradient tensor, we’ll see that the values for the filter gradients we calculated in Examples 1 to 4 above fit into a nice pattern:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7qSxieS0COrbj3zD3vR1RQ.gif" /></figure><p><strong><em>It turns out that the backpropagation operation is identical to a stride = 1 convolution operation of the input tensor with a dilated version of the output gradient tensor!</em></strong></p><p>This concludes Part 2 of the Backpropagation for Convolution with Strides series. I hope this helped enhance your knowledge of Backpropagation for Convolution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb2f2efc4faa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 1: Backpropagation for Convolution with Strides]]></title>
            <link>https://medium.com/@mayank.utexas/backpropagation-for-convolution-with-strides-8137e4fc2710?source=rss-44d5d3d113e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8137e4fc2710</guid>
            <category><![CDATA[backpropagation]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[strided-convolution]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mayank Kaushik]]></dc:creator>
            <pubDate>Thu, 02 May 2019 23:59:27 GMT</pubDate>
            <atom:updated>2019-05-04T20:28:05.538Z</atom:updated>
            <content:encoded><![CDATA[<h4>Loss gradient with respect to the input tensor</h4><p>There are several examples of Backpropagation with Convolution, but almost all of them assume a stride of 1. This article provides a visual example of Backpropagation with a stride &gt; 1. Along the way, this hopefully exercise also provides some intuition for why the filter needs to be rotated for Backpropagation.</p><p>(<strong><em>Part 2 can be found here: </em></strong><a href="https://medium.com/@mayank.utexas/backpropagation-for-convolution-with-strides-fb2f2efc4faa"><strong><em>Loss gradient with respect to the filter</em></strong></a><em>)</em></p><p>We’ll use the following example dimensions for our input, filter, and output tensors. Note that we’re using horizontal and vertical strides of 2 here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kjwmx11ofv-IMTwf8r93Yw.png" /><figcaption>Dimensions of the tensors we’re working with</figcaption></figure><p>To set things up, let us first express look at the forward propagation step to express the output pixels as functions of the input activations and filter contents (the weights). This, of course, is quite straightforward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*3l5APR4As-yhTv7HX_kaZw.gif" /><figcaption>Forward propagation</figcaption></figure><p>Here’s what we need to do in the Backpropagation step: given the gradient of the loss with respect to the output pixels, we need to calculate the gradient of the loss with respect to the input activations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojfVCY_WsElKl6anwCXgYQ.png" /><figcaption>Backpropagation of gradients</figcaption></figure><p>Each input <em>x</em> contributes to one or more output pixels (this is visualized in more detail below). Using the chain rule and partial differentiation principles, the total gradient of the loss with respect to each input pixel can be expressed in terms of gradients of each output pixel with respect to the input, multiplied by the gradient of the loss with respect to that output pixel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*xs1d2JkhY0qH_0x1dRmloA.png" /></figure><p>Remember that the only output pixels <em>y</em> that appear in the above equation for a given <em>x</em> are the ones that <em>x </em>contributes to during forward propagation. This can be inferred from the following equations we calculated during forward propagation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*J2UeXtJ38zKgwrJ5av3G6A.png" /></figure><p>With this knowledge, let us calculate the gradients for a few example inputs step by step, before we see the full Backpropagation in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cs2LtkzPx_uIKK79-IXPrA.png" /><figcaption>Example 1: the input pixel contributes to one output pixel</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DcUWqB7xkeWeIYPb0i9C3A.png" /><figcaption>Example 2: different input pixel contributes to the same output pixel</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWFOe6tl5mbNDWY9MNRLQw.png" /><figcaption>Example 3: this input pixel contributes to two output pixels</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kYneFD-VQLlvcMeQPoqjaw.png" /><figcaption>Example 4: this input pixel contributes to all four output pixels</figcaption></figure><p>At first glance, it might be hard to see a pattern in the values of the these input gradients. But what if we modified the output gradient and filter tensors?</p><p>We’re going to make one modification to the output gradient tensor:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KOHfsOHX5ujcMfr6Xjy6zQ.png" /><figcaption>Pad the output gradient tensor with R-1 zeros at the top and bottom, and S-1 zeros to the left and right. Also dilate the output gradient pixels with stride_R-1 zeroes vertically, and stride_S-1 zeros horizontally. Remember that for our convolution, stride_R = stride_S = 2</figcaption></figure><p>We’re also going to make one modification to the filter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h3Yd9ceAE0jBgq_nWHjtuw.png" /><figcaption>Rotate the filter horizontally and vertically. This is the “flipping” of the filter involved in Backpropagation for Convolutions</figcaption></figure><p>With these modifications to the output gradient tensor and the filter, we’ll see that the values for the input gradient we calculated in Examples 1 to 4 above fit into a nice pattern:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*QvTW-pNwJAlbfj1LrZe8JA.gif" /></figure><p><strong><em>It turns out that the Backpropagation operation is identical to a stride = 1 Convolution of a padded, dilated version of the output gradient tensor with a flipped version of the filter!</em></strong></p><p>I hope this example helped you understand Backpropagation for Convolution with Strides.</p><p><a href="https://medium.com/@mayank.utexas/backpropagation-for-convolution-with-strides-fb2f2efc4faa"><em>In Part 2 we will go over calculating the gradient of the loss with respect to the filter (weights) tensor.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8137e4fc2710" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>