Skip to main content

TorchXAI is a PyTorch-based toolkit designed for evaluating machine learning models using explainability techniques.

Project description

TorchXAI

TorchXAI is a PyTorch-based toolkit designed for evaluating machine learning models using explainability techniques.

Description

TorchXAI provides efficient implementations of several XAI (Explainable AI) metrics that seamlessly integrate with the Captum library. The primary goal of this toolkit is to offer batch computation and task/data-agnostic implementations of various explainability metrics, enabling scalable evaluation while maintaining compatibility with the established Captum framework.

Installation with Pip

The project can be installed directly with pip:

pip install git+https://github.com/saifullah3396/torchxai.git

Installation from Source

Clone the repository:

git clone https://github.com/saifullah3396/torchxai.git

Install the project with pip on source directory

pip install -e .

Usage

Import the required metric, such as completeness

from torchxai.metrics.axiomatic import completeness
from captum.attr import Saliency

# ImageClassifier takes a single input tensor of images Nx3x32x32,
# and returns an Nx10 tensor of class probabilities.
net = ImageClassifier()

saliency = Saliency(net)
input = torch.randn(2, 3, 32, 32, requires_grad=True)
baselines = torch.zeros(2, 3, 32, 32)

# Computes saliency maps for class 3.
attribution = saliency.attribute(input, target=3)

# define a perturbation function for the input
# Computes completeness score for saliency maps
completeness_score = completeness(net, input, attribution, baselines)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchxai_tools-1.0.0.tar.gz (116.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchxai_tools-1.0.0-py3-none-any.whl (161.6 kB view details)

Uploaded Python 3

File details

Details for the file torchxai_tools-1.0.0.tar.gz.

File metadata

  • Download URL: torchxai_tools-1.0.0.tar.gz
  • Upload date:
  • Size: 116.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for torchxai_tools-1.0.0.tar.gz
Algorithm Hash digest
SHA256 27b91f07d9b2af4c63e6a852a11e6e27f6c8a36d7c9e3bab1278e6221319e6b9
MD5 f713a5cc2450c111b3e14e25c0aa3582
BLAKE2b-256 44102c1e8171b5d0b44a9661bc7b1f391590f15710195a78214b760387d2ecd1

See more details on using hashes here.

File details

Details for the file torchxai_tools-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for torchxai_tools-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dda19633fe55f28bd68d3fa9343b4f6af59f448c99ae61c1386b677c7492877e
MD5 08c19296a76ddf5853cd26f2f0c6bee7
BLAKE2b-256 40515dc02c7053924263a08d894eed92a3f4c5deba2859d24f79329c93d257b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page