Official Pytorch/Tensorflow implementation of Cross-Domain Saliency Maps. The method does not require any model model retraining or modications.
Install using pip:
pip install cross-domain-saliency-maps
Get started with our PyTorch/TensorFlow examples (one-click run)
- Pytorch getting started
- Tensorflow getting started
- What does your model see in your EEG? (with MNE)
- Explaining time-series forecasts (with skforecast)
The library supports generating saliency maps for any domain which can be formulated as an invertible transformation with a differentiable inverse transformation.
To generate maps expressed in a domain, a corresponding Domain
object needs to be defined. This describes the operations performed
during the forward and inverse transformations.
Implementations for the Frequency and Independent Component Analysis (ICA) transformations are already implemented and can be directly deployed. Additionally, the libraryprovides the flexibility of defining new transformations.
The following domains are already implemented and can be directly used to generate saliency maps:
-
Time Domain. This is the original Integrated Gradients, expressing saliency maps in the raw input domain (time). The corresponding
Domainobject isTimeDomain. The map can be directly generated:timeIG = TimeIG(model, n_iterations, output_channel = 0) -
Frequency Domain. Each point in the map corresponds to the importance of the corresponding frquency component. The Fourier transform is used to transform the time-domain to the frequency domain. The corresponding
Domainobject isFourierDomain. The map can be directly generated:fourierIG = FourierIG(model, n_iterations, output_channel = 0) -
Independent Component Domain. Each point in the map corresponds to an independent component (IC) of the ICA decomposition. Any ICA implementation can be used as long as it complies with
sklearn.decomposition.FastICA. The domain is defined byICADomain. Before generating the map aFastICAneeds to be fitted to the input sample (see example). The map can be directly generated:icaIG = ICAIG(model, fastICA, n_iterations, output_channel = 0)
The library supports extending the Cross-domain Integrated Gradients for any invertible domain with a differentiable inverse transform. This requires:
-
Creating the propert
Domainobject describing the corresponding transform.Domainobjects need to inherit fromDomainBaseand implement the required functions. More details can be found in the implementation of theFourierDomainandICADomain( tensorflow, pytorch). -
Calling
CrossDomainIGwith the new domain as the input. This can be done either by creating aCrossDomainIG, initializing it with the new domain, or by implementing a new dedicated class inheritingCrossDomainIG. For more details check the implementations ofFourierIGandICAIG( tensorflow, pytorch).
BibTeX
@article{kechris2025time,
title={Time series saliency maps: Explaining models across multiple domains},
author={Kechris, Christodoulos and Dan, Jonathan and Atienza, David},
journal={arXiv preprint arXiv:2505.13100},
year={2025}
}