# Grad-cam cnn vs hybrid-swin transformer

**URL:** <https://discuss.ai.google.dev/t/grad-cam-cnn-vs-hybrid-swin-transformer/32172>\
**Category:** Show and Tell\
**Tags:** keras\
**Created:** [January 15, 2022, 3:08pm UTC](https://discuss.ai.google.dev/t/grad-cam-cnn-vs-hybrid-swin-transformer/32172 "2022-01-15T15:08:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![innat](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/innat/32/13542_2.png) [@innat](https://discuss.ai.google.dev/u/innat)\
**Post date:** [January 15, 2022, 3:08pm UTC](https://discuss.ai.google.dev/t/grad-cam-cnn-vs-hybrid-swin-transformer/32172/1 "2022-01-15T15:08:26Z")

</div>

I was checking the grad-cam of a pure cnn and a hybrid model (cnn+swin\_transformer). Now, after passing an intermediate layer from CNN to Swin-transformer, it looks like the transformer blocks are able to refine the feature activation globally across the relevant object; unlike CNN which is more interested to operate locally.

![image](https://d3qe71uytubmmx.cloudfront.net/original/2X/4/4d28d3a44e106625ad8bd9913155a167b55c6f1b.gif)  
( **left:** input, – **middle** : CNN, – **right** : CNN + Transformer / Hybrid).

Code example: [TF: Hybrid EfficientNet Swin-Transformer : GradCAM | Kaggle](https://www.kaggle.com/ipythonx/tf-hybrid-efficientnet-swin-transformer-gradcam)

---

<div class="post-metadata">

**Author:** ![Bhack](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/bhack/32/6388_2.png) [@Bhack](https://discuss.ai.google.dev/u/Bhack)\
**Post date:** [January 15, 2022, 3:36pm UTC](https://discuss.ai.google.dev/t/grad-cam-cnn-vs-hybrid-swin-transformer/32172/2 "2022-01-15T15:36:00Z")

</div>

Nice, It could be interesting to visualize also:

> **[GitHub - google-research/vmoe](https://github.com/google-research/vmoe)**
>
> Contribute to google-research/vmoe development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Bhack](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/bhack/32/6388_2.png) [@Bhack](https://discuss.ai.google.dev/u/Bhack)\
**Post date:** [January 15, 2022, 3:40pm UTC](https://discuss.ai.google.dev/t/grad-cam-cnn-vs-hybrid-swin-transformer/32172/3 "2022-01-15T15:40:45Z")

</div>

P.s. see also:

[![](https://d3qe71uytubmmx.cloudfront.net/original/3X/2/4/246cc4082dbaffdac38f01861d45ced5159642e5.jpeg "Do Vision Transformers See Like Convolutional Neural Networks? | Paper Explained") ](https://www.youtube.com/watch?v=rk9bhIRInC0)

---

<div class="post-metadata">

**Author:** ![innat](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/innat/32/13542_2.png) [@innat](https://discuss.ai.google.dev/u/innat)\
**Post date:** [January 15, 2022, 11:06pm UTC](https://discuss.ai.google.dev/t/grad-cam-cnn-vs-hybrid-swin-transformer/32172/5 "2022-01-15T23:06:16Z")

</div>

Thanks for sharing this info.  
The paper that was explained in the video is super interesting. (printout 📑)

Ref. [Do Vision Transformers See Like Convolutional Neural](https://arxiv.org/pdf/2108.08810.pdf)
