Skip to content

concept relevance propagation experiments implemented by pytorch

License

Notifications You must be signed in to change notification settings

fxnnxc/crp_pytorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crp_pytorch

Implementation of Concept Relevance Propagation with pytorch. check crp_notebook.ipynb for use case.

File Structure

📦crp_pytorch
 ┣ 📂 src  # includes all python files
 ┃ ┣ 📂 lrp # inclues lrp implementation 
 ┃ ┃ ┣ 📂 modules
 ┃ ┃ ┃ ┣ 🐍 __init__.py
 ┃ ┃ ┃ ┣ 🐍 activation.py
 ┃ ┃ ┃ ┣ 🐍 conv2d.py       # 🚀 CRP is implemented by masking here!
 ┃ ┃ ┃ ┣ 🐍 dropout.py
 ┃ ┃ ┃ ┣ 🐍 flatten.py
 ┃ ┃ ┃ ┣ 🐍 input.py
 ┃ ┃ ┃ ┣ 🐍 linear.py
 ┃ ┃ ┃ ┣ 🐍 pool.py
 ┃ ┃ ┃ ┗ 🐍 utils.py
 ┃ ┃ ┗ 🐍 __init__.py
 ┃ ┣ 🐍 data.py         # ImageNet transform
 ┃ ┗ 🐍 lrp_for_vgg.py # construct lrp model for vgg 16
 ┣ 📜 .gitignore
 ┣ 🪙 LICENSE
 ┣ 📖 README.md
 ┣ 🏙 image.png 
 ┗ 🪐crp_notebook.ipynb

How to use

Find the lines below in crp_notebook.ipynb,

1. ImageNet Validation Path

Download ImageNet dataset or modify it for any other dataset.

# ============================================
# change!
data_path = "/data3/bumjin_data/ILSVRC2012_val"
testset = torchvision.datasets.ImageNet(root=data_path, split="val")
# ============================================

2. VGG16 layer, filter indices, and samples

# ===================================
# Which CNN layer / CNN filter index / samples?
layer = 0
conept_ids = [43,44,45,46]  # CNN filter indexes
samples = [5373, 5568, 5367, 5396, 5357] + [5586,5577,1411,5494,3391] # samples you want to check 
# ===================================

About

concept relevance propagation experiments implemented by pytorch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published