<?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 Mohamed Chetoui on Medium]]></title>
        <description><![CDATA[Stories by Mohamed Chetoui on Medium]]></description>
        <link>https://medium.com/@mohamedchetoui?source=rss-fd28ededda7c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7-e25beSMGANodAl8K0l2A.jpeg</url>
            <title>Stories by Mohamed Chetoui on Medium</title>
            <link>https://medium.com/@mohamedchetoui?source=rss-fd28ededda7c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:41:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohamedchetoui/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[Grad-CAM- Gradient-weighted Class Activation Mapping]]></title>
            <link>https://medium.com/@mohamedchetoui/grad-cam-gradient-weighted-class-activation-mapping-ffd72742243a?source=rss-fd28ededda7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffd72742243a</guid>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Mohamed Chetoui]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 23:03:42 GMT</pubDate>
            <atom:updated>2019-03-29T02:13:55.446Z</atom:updated>
            <content:encoded><![CDATA[<h3>Gradient-weighted Class Activation Mapping - Grad-CAM-</h3><h3>Introduction</h3><p>A technique for making Convolutional Neural Network (CNN)-based models more transparent by visualizing the regions of input that are “important” for predictions from these models — or visual explanations</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*U1VdM0WeXHVzVFLyj1ePzw.jpeg" /></figure><p>This visualization is both high-resolution (when the class of interest is ‘tiger cat’, it identifies important ‘tiger cat’ features like stripes, pointy ears and eyes) and class-discriminative (it shows the ‘tiger cat’ but not the ‘boxer (dog)’).</p><h3>Proposed approach</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*hHPn81BbKEl7xDsHr5aSIA.png" /></figure><h3>Backpropagation</h3><p>The gradient of the loss (for category cat) wrt the input pixels gives,</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*fCJONk4bfNdVZpuR.png" /></figure><p>It’s pretty noisy!</p><h3>Deconv and Guided Backprop</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*xdQAaH_zHrNYZCfC.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*bXLATSY0ZjMj1o8Q.png" /></figure><p>This gives much cleaner results</p><p>Now lets take a different picture, which contains 2 categories</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ovzzzGKMZCd1es-f.jpg" /></figure><p>lets visualize the important regions for each of these 2 categories using Guided Propagation, which gives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*OQDVFRHi0oXehcbt.png" /></figure><p>This is bad. The visualization is unable to distinguish between pixels of cat and dog. In other words, <strong>the visualization is not class-discriminative.</strong></p><h4>CAM</h4><p>Modifying the base network to remove all fully-connected layers at the end, and including a tensor product (followed by softmax), which takes as input the Global-Average-Pooled convolutional feature maps, and outputs the probability for each class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*8iyCBSx6i2lRpnKLe5bIrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nE5_ZjRhOcslpvXI.png" /><figcaption><a href="https://alexisbcook.github.io/2017/global-average-pooling-layers-for-object-localization/">https://alexisbcook.github.io/2017/global-average-pooling-layers-for-object-localization/</a></figcaption></figure><p>Note that this modification of architecture forces us<strong> to retrain the network.</strong></p><p>Can we get these visualizations <strong>without changing the base model, and without <em>any</em> re-training?</strong></p><p>Let’s see how Grad-CAM discovers these weight of importance without any training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*hHPn81BbKEl7xDsHr5aSIA.png" /></figure><p>To obtain the class-discriminative localization map, <strong>Grad-CAM</strong> computes the gradient of <strong>yc </strong>(score for class c) with respect to feature maps <strong>A </strong>of a convolutional layer. these gradients flowing back are global-average-pooled to obtain the importance weights <strong>αck</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*ATzleTWhhnC9kvSb4GStow.png" /></figure><p>Similar to CAM, Grad-CAM heat-map is a weighted combination of feature maps, but followed by a ReLU:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*EagKCAdsdKHwSSvZwdDuww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/0*D4FATkIeWp61o9zo.jpg" /><figcaption>results in a coarse heat-map of the same size as the convolutional feature maps (14×1414×14 in the case of last convolutional layers of VGG and AlexNet networks)</figcaption></figure><p>If the architecture is already CAM compatible — the weights learned in CAM are precisely the weights computed in Grad-CAM. Other than the ReLU, this makes Grad-CAM a generalization of CAM. This generalization is what allows Grad-CAM to be applicable to <strong><em>any CNN-based architecture</em></strong>.</p><h3>Guided Grad-CAM</h3><p>While Grad-CAM visualizations are class-discriminative and localize relevant image regions well, they lack the ability to show fine-grained importance like pixel-space gradient visualization methods (Guided Backpropagation and Deconvolution). For example take the case of the left image in the above figure, Grad-CAM can easily localize the cat region; however, it is unclear from the low-resolutions of the heat-map why the network predicts this particular instance is ‘tiger cat’. In order to combine the best aspects of both, we can fuse Guided Backpropagation and the Grad-CAM visualizations via a pointwise multiplication. GradCAM overview figure above illustrates this fusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/0*eGO6G0Im-vDTzWBy.jpg" /></figure><h3><strong>Code</strong></h3><p><strong>Original </strong>source code : <a href="https://github.com/ramprs/grad-cam">https://github.com/ramprs/grad-cam</a> (<strong>pytorch</strong>)</p><p><strong>Keras</strong> version : <a href="https://github.com/eclique/keras-gradcam">https://github.com/eclique/keras-gradcam</a> (Jupyter Notebook)</p><p><strong>Tensorflow </strong>: <a href="https://github.com/insikk/Grad-CAM-tensorflow">https://github.com/insikk/Grad-CAM-tensorflow</a> (VGG ,resnet50,resnet101)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*a06G9ljSI2FchEqVi_kJjg.png" /><figcaption>an example of grad-cam code with keras</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/0*Gc-4stuXzf8_unyl.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*NTANj1Nbq1jh_FWrbk16ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*TbXy-eh2tvyLhdjuAcajDA.png" /></figure><h3>Demo</h3><p>A live demo on Grad-CAM applied to image classification can be found at <a href="http://gradcam.cloudcv.org/classification">http://gradcam.cloudcv.org/classification</a>.</p><p>a quick video showing some of its functionalities.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCOjUB9Izk6E%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCOjUB9Izk6E&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCOjUB9Izk6E%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/766c6073703c31926899c573aefe2401/href">https://medium.com/media/766c6073703c31926899c573aefe2401/href</a></iframe><p><strong>Arxiv Paper link: </strong><a href="https://arxiv.org/abs/1610.02391">https://arxiv.org/abs/1610.02391</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffd72742243a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>