<?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 Kartikeya Bhardwaj on Medium]]></title>
        <description><![CDATA[Stories by Kartikeya Bhardwaj on Medium]]></description>
        <link>https://medium.com/@kartikeyabhardwaj98?source=rss-a10680f069c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*5kMot70wS2RWvDbtu2vz-A.jpeg</url>
            <title>Stories by Kartikeya Bhardwaj on Medium</title>
            <link>https://medium.com/@kartikeyabhardwaj98?source=rss-a10680f069c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:02:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kartikeyabhardwaj98/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[A Minimal Stacked Autoencoder from scratch in PyTorch]]></title>
            <link>https://medium.com/analytics-vidhya/a-minimal-stacked-autoencoder-from-scratch-in-pytorch-da236dbf9345?source=rss-a10680f069c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/da236dbf9345</guid>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[autoencoder]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Kartikeya Bhardwaj]]></dc:creator>
            <pubDate>Thu, 21 May 2020 12:52:46 GMT</pubDate>
            <atom:updated>2020-06-29T17:05:22.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*DDqPvS6TWokAzyFY73rNFA.jpeg" /></figure><h3>A Minimal Stacked Autoencoder in PyTorch</h3><p>Autoencoders are amazing. They are capable of learning ‘compressed’ encodings that have a much lower dimension than the input data. This ability of learning dense representations of the input is very useful for tasks like Dimensionality reduction, feature detection for unsupervised tasks, generative modelling etc.</p><p>This is how you can build a minimal autoencoder in PyTorch. We will be using the good old MNIST dataset.</p><h4>Architecture</h4><p>We will build a 5 layer stacked autoencoder (including the input layer). The first part of our network, where the input is tapered down to a smaller dimension (<strong>encoding)</strong> is called the <strong>Encoder</strong>. The second part is where this dense encoding maps back to the output, having the same dimension as the input. This part is called the <strong>Decoder</strong>.</p><blockquote><strong>flow — input(784)&gt; Encoder(128) &gt; hidden(64) &gt; Decoder(128) &gt; out(784)</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*P7aFcjaMGLwzTvjW3sD-5Q.jpeg" /></figure><h4>Downloading MNIST</h4><p>Let’s quickly download MNIST dataset and load the pickle file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a77f9500f7cf68b8daa85d52511eb1b4/href">https://medium.com/media/a77f9500f7cf68b8daa85d52511eb1b4/href</a></iframe><h4>Building the Model</h4><p>Here we setup the Autoencoder class. We inherit the Torch’s nn.module. Our class has an encoder and a decoder list, both containing linear and activation layers. Notice, our final activation layer in the decoder part, is a Sigmoid layer. We need our outputs to be in the [0,1] range.</p><p>We use the Binary Cross Entropy loss function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38e3afb18fb40f2e496cde4c8dd72a9b/href">https://medium.com/media/38e3afb18fb40f2e496cde4c8dd72a9b/href</a></iframe><h4>Train Loop</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fd9399451e20018c65dfcdbebb920ad/href">https://medium.com/media/5fd9399451e20018c65dfcdbebb920ad/href</a></iframe><p><strong>Visualising Predictions</strong></p><p>After the model is trained, we visualise the predictions on the x_valid data set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfadf71bacffa5efaaa26de78d0e3c94/href">https://medium.com/media/dfadf71bacffa5efaaa26de78d0e3c94/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*q8VWINSZFYJvmchwaa2z0A.png" /><figcaption><strong>Left col is the input, Right col is the Reconstructed Output</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*b282lw7ZabMWjdprc0eERg.png" /></figure><p>Nice! Our model has generalised pretty well. The decoder is able to map the dense encodings generated by the encoder, back to the input.</p><p>You can add dropout in the input layer of the encoder part, and repeat the process. This will result in the model learning the mapping from noisy inputs to normal inputs <em>(since inputs are the labels) </em>. This way we can create a Denoising Autoencoder! I will be posting more about different architectures of autoencoders and how they can be used for unsupervised pre-training soon.</p><p>Thanks for reading, You can find the notebook <a href="https://gist.github.com/kartikeyab/5852adc5032cd94b68d52574b9048560">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da236dbf9345" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/a-minimal-stacked-autoencoder-from-scratch-in-pytorch-da236dbf9345">A Minimal Stacked Autoencoder from scratch in PyTorch</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrated Gradients for Deep Neural Networks]]></title>
            <link>https://medium.com/@kartikeyabhardwaj98/integrated-gradients-for-deep-neural-networks-c114e3968eae?source=rss-a10680f069c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c114e3968eae</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[convolution-neural-net]]></category>
            <category><![CDATA[gradient-descent]]></category>
            <dc:creator><![CDATA[Kartikeya Bhardwaj]]></dc:creator>
            <pubDate>Sat, 01 Jun 2019 14:51:05 GMT</pubDate>
            <atom:updated>2019-09-05T01:27:44.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*dHOil0s7aOpOrNKDldu8Kw.jpeg" /></figure><h3>The Black Box Problem</h3><p>Interpretability in Deep Learning is a big challenge tackled by researchers since the inception of it. The question asked today is <em>,‘Why did the CNN make this prediction?’’</em> rather than <em>“How did the CNN make this prediction?”</em></p><p>Considering the fact that the use of Deep Neural Networks is prevalent in sensitive domains like Healthcare (for e.g Chest disease detection), the ‘interpretability’ of such networks matters a lot. The ‘why’ of the diagnosis is of the prime importance. The slow acceptance of Deep neural networks in the domain of Finance is also due to less interpretability. Since Financial companies, banks etc follow a proper structure and regulations, a preference is given to classical machine learning techniques like tree-based models, Bayesian models which are easy to interpret.</p><p>Solving the problem of Interpretability also opens new doors for improving such networks. To change this notion that <em>“Deep learning models are </em><strong><em>Black Boxes</em></strong><em>”, </em>many methods have surfaced up. One of the techniques is Integrated Gradients.</p><h3>Integrated Gradients</h3><p>Let’s start of with an example of this image. A pre-trained inception model correctly classifies the following image as a ‘fireboat’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*cV9KiRbrS_2bPbbIjCWQXQ.jpeg" /></figure><p><em>“What pixels in this image are responsible for this classification?”</em></p><p>Here is the Integrated Gradients technique-</p><ol><li>Consider a black image (each pixel 0) as a baseline image.</li><li>Now , interpolate a series of images , increasing in intensity, between the baseline image and the original image.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*73zZv66FLpHmQFc_kwMf9Q.png" /></figure><p>3. The scores of these images (softmax output ) when plotted , will look like the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FM1npGt_RLRLSpWlJoF3sQ.png" /></figure><p>4. Our region of interest lies where the slope of the score vs intensity graph doesn&#39;t remain stagnant . We call these gradients <em>-interesting gradients.</em></p><p>5. Gradients of the output with respect to these series of interpolated images , when calculated gives us the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkYrYSBkfVksd19VjI4FtQ.png" /></figure><p>6. The integration of these series of gradients give us the Integrated gradients of the image.</p><p>Following is the implementation -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*429m9da6zUdf1M6GjUGDRA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o1ULT6us9ygUcU48fb01Wg.png" /></figure><h3>Improvements</h3><p>While the <a href="https://arxiv.org/abs/1703.01365">paper</a> supports the usage of a black image as a baseline image , I tried out a series of experiments with different baseline images . These were mostly noisy images having low intensity and in some of the cases , the noisy baseline proved to be better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*0tpwxW7yQT3RgBAhsESYHA.png" /><figcaption>Black Baseline</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*iGjOPe0NvISfeAOpaTng-g.png" /><figcaption>Noisy baseline</figcaption></figure><p>The Integrated gradients with the noisy baseline are more spread-out than the black baseline case. This can provide a better insight in some of the cases.</p><p>Therefore, averaging out the gradients computed using different baselines can provide a more ‘robust’ output.</p><p><em>Thanks for reading! Follow me on GitHub — </em><a href="https://github.com/kartikeyab"><em>https://github.com/kartikeyab</em></a><em> for repos and paper implementations.</em></p><p><em>Cheers!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c114e3968eae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>