Skip to main content

Layer-Wise Relevance Propagation

DOI PyPI Version License

PyTorch implementation of Layer-wise Relevance Propagation (LRP) algorithm together with quantitative evaluation metrics to compare heatmap explanations objectively.

Special thanks to Dr. Grégoire Montavon for his insights, which shaped the development of this project.

Features

Explainability:

  • Layer-wise Relevance Propagation (LRP)

Quantitative Evaluation:

  • Pixel Flipping (PF), also known as Region Perturbation (RP)
    • Perturbation modes:
      • inpainting
      • random
    • Sort objectives:
      • most relevant first (MoRF), also known as activation curve
      • least relevant first (LRF), also known as pruning curve
      • random
  • AUC (Area Under the Curve), also known as AUAC (Area Under the Activation Curve) or AU-MSE (Area Under the Mean Squared Error Curve) depending on the sort objective

Showcase

LRP (lrp-tutorial composite) and PF with inpainting perturbation mode and sort objective MoRF.

Classification scores of castle image with inpainting perturbation mode

Number of simultaneous flips per perturbation step during Pixel-Flipping.


PF perturbation mode random

LRP (lrp-tutorial composite) and PF with random perturbation mode and sort objective MoRF.

Classification scores of castle image with random perturbation mode

Requirements

  • python3 >= 3.9

Installation

python3 -m pip install lrp-pf-auc

The PyPI distribution lrp-pf-auc provides the following two packages: lrp and pf.

The name lrp-pf-auc stands for Layer-wise Relevance Propagation (LRP), Pixel Flipping (PF), and Area Under the Curve (AUC) respectively.

Usage

Refer to demo.ipynb for an example of Layer-wise Relevance Propagation (LRP), Pixel-Flipping (PF) and Area under the Curve (AUC).

Feel free to check out the Jupyter notebooks under experiments/notebooks for a chronological overview of the project.

Citation

Cite as:

  • Plaintext:

    Rodrigo Bermúdez Schettino. (2022). rodrigobdz/lrp: v0.1.6 (v0.1.6). Zenodo. https://doi.org/10.5281/zenodo.6821295

  • BibTeX:

    @software{rodrigo_bermudez_schettino_2022_6821295,
      author       = {Rodrigo Bermúdez Schettino},
      title        = {rodrigobdz/lrp: v0.1.6},
      month        = jul,
      year         = 2022,
      publisher    = {Zenodo},
      version      = {v0.1.6},
      doi          = {10.5281/zenodo.6821295},
      url          = {https://doi.org/10.5281/zenodo.6821295}
    }
    

Credits

This implementation is based on insights from:

License

MIT © rodrigobdz

Metadata

Release files for lrp-pf-auc 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lrp-pf-auc 0.1.6
File Size Uploaded Provenance
lrp_pf_auc-0.1.6.tar.gz 37.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lrp-pf-auc 0.1.6
File Interpreter ABI Platform
lrp_pf_auc-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 82.4 kB

Release files / lrp_pf_auc-0.1.6.tar.gz

Download URL lrp_pf_auc-0.1.6.tar.gz
Size 37.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8dbd0c27f66a07005ee7fe0e91215718eb35b86892cf63c054363f5e0116087a
BLAKE2b-256 checksum
How to use checksums
cbe32bfd13f0b437db94e8a635377d66876004cdf32079f8d407bcab2c1c1384
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / lrp_pf_auc-0.1.6-py3-none-any.whl

Download URL lrp_pf_auc-0.1.6-py3-none-any.whl
Size 44.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7b8458c32b4d1936f3638c60bab6bae77d48b6590ff88c565614d5485e0a139
BLAKE2b-256 checksum
How to use checksums
eda6d8ce885fb3364b3008d26678ef1b6fb66b9cb4865aa23982207645cef357
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for lrp-pf-auc 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page