gatsby2016 / FeatsVisDL

Attention \ Saliency maps and features visualization for deep learning models in pytorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maps visualization for Deep Learning models in PyTorch

This repository contains some features visualization methods for DL models in PyTorch.

codes/ is the folder of source scripts

data/ is the folder of some samples

model/ is the pretrained ResNet34 model on ImageNet

results/ is the folder for attention / saliency / features maps

Another repo for more techniques: pytorch-cnn-visualizations

CAM (Class Activation Map)

Paper reference: Learning Deep Features for Discriminative Localization

To visualize the model where it focus on by activation maps.

The limitation is that the model must has a Global Pooling followed by one fully connected layer to classes.

Original Images Activation Maps Overlapped Images

Grad-CAM

Paper reference: Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization

This Grad-CAM method is a strict generalization of CAM, which are not limited to GAP and fc.

$$w_{k}^{c}=\sum_{i} \sum_{j} \frac{\partial Y^{c}}{\partial A_{i j}^{k}}$$

Generated attention maps of Grad-CAM is the same as CAM's when the model is ResNet34 with GAP and fc.

Original Images Activation Maps Overlapped Images

Feature maps visualization on Layers

To visualize the features maps after each layer, which can also be viewed as the method for DL features extraction.

Original Image Maps after 1st maxpool Maps after Layer1
Maps after Layer2 Maps after Layer3 Maps after Layer4

Note for myself.

git init
git remote add origin git@github.com:gatsby2016/FeatsVisDL.git
git add README.md
git commit -m "first commit"
git push -u origin master

About

Attention \ Saliency maps and features visualization for deep learning models in pytorch


Languages

Language:Python 100.0%