Registry / ai-ml / saliency

saliency

JSON →
library0.2.1pypypi✓ verified 89d ago

Framework-agnostic library for computing saliency maps (e.g., integrated gradients, SmoothGrad, XRAI) for deep learning models. Current version: 0.2.1. Release cadence is low, with updates driven by research contributions.

pip install saliency
INSTALL
IMPORT
SIG · SALIENCY
S
saliency
ai-mlpythonv0.2.1
Install
10.6s avg
Import
1599ms
Disk
307MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 10.4s
py 3.11
✓ —
✓ 10.2s
py 3.12
✓ —
✓ 10.4s
py 3.13
✓ —
✓ 9.9s
py 3.9
✕ build_error
✓ 12s
307MB installed
● package 307MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

core
✓ from saliency import core
✗ import saliency
The top-level module does not expose submodules directly; use explicit import.
IntegratedGradients
✓ from saliency.core import IntegratedGradients
✗ from saliency import IntegratedGradients
Classes are in submodules like core, not directly in saliency.
SmoothGrad
✓ from saliency.core import SmoothGrad
✗ from saliency import SmoothGrad
Same as above; use correct submodule path.
XRAI
✓ from saliency.xrai import XRAI
XRAI is in its own submodule 'xrai', not in core.
visualize
✓ from saliency.core import visualize
✗ from saliency import visualize
Visualization utilities are in core.

Compute integrated gradients on a simple Keras model.

import tensorflow as tf from saliency.core import IntegratedGradients, visualize # Build a simple model model = tf.keras.Sequential([ tf.keras.layers.Dense(10, activation='relu', input_shape=(4,)), tf.keras.layers.Dense(1, activation='sigmoid') ]) # Dummy input and baseline x_input = tf.constant([[1.0, 2.0, 3.0, 4.0]]) baseline = tf.zeros_like(x_input) # Call model wrapper def model_fn(x): return model(x) # Compute integrated gradients ig = IntegratedGradients() attributions = ig.GetMask(x_input, model_fn, baseline, x_steps=25) print(attributions)
Debug
Known issues
breakingIn version 0.2.0, the API was overhauled: previous methods like `saliency.IntegratedGradients` moved to `saliency.core`. Code using old import paths will break.
fix
Update imports: from saliency.core import IntegratedGradients (and others). Also update method calls (e.g., GetMask instead of GetMask).
affects: <0.2.0
deprecatedThe method `GetMask` in IntegratedGradients may be deprecated in future in favor of `compute_saliency` or similar naming. Check CHANGELOG.
fix
Monitor repository for updated API; aim to use any newer method names once released.
affects: >=0.2.0
gotchaXRAI method requires both positive and negative attributions; using only positive attributions will produce incorrect masks.
fix
Ensure you pass the full attributions tensor (including negative values) to XRAI, not a rectified version.
affects: all
gotchaThe library expects models to output logits (pre-softmax) for gradient calculations. Using softmax outputs may lead to vanishing gradients.
fix
Always use a model that returns logits, or modify the model function to return logits before activation.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'saliency.core'
Older version installed (<0.2.0) where core module didn't exist.
fix
Upgrade to latest: pip install --upgrade saliency
AttributeError: module 'saliency' has no attribute 'IntegratedGradients'
Importing directly from top-level saliency instead of submodule.
fix
Use: from saliency.core import IntegratedGradients
TypeError: GetMask() missing 1 required positional argument: 'x_steps'
x_steps parameter is required since version 0.2.0 (old default removed).
fix
Provide x_steps explicitly, e.g., GetMask(..., x_steps=25)
Upgrade
Version history
0.2.1latest on PyPI · released Mar 20, 2024
Audit
Dependencies
numpyrequiredCore dependency for array operations.
pillowrequiredImage loading and visualization.
tensorflowoptionalDefault backend for model integration.
torchoptionalAlternative backend for PyTorch models.
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
saliency — pip install saliency · libregistry