TorchRay is a PyTorch library of visualization methods for convnets.
Project description
TorchRay
The TorchRay package implements several visualization methods for deep convolutional neural networks using PyTorch. In this release, TorchRay focuses on attribution, namely the problem of determining which part of the input, usually an image, is responsible for the value computed by a neural network.
TorchRay is research oriented: in addition to implementing well known techniques form the literature, it provides code for reproducing results that appear in several papers, in order to support reproducible research.
TorchRay was initially developed to support the paper:
- Understanding deep networks via extremal perturbations and smooth masks. Fong, Patrick, Vedaldi. Proceedings of the International Conference on Computer Vision (ICCV), 2019.
Examples
The package contains several usage examples in the
examples
subdirectory.
Here is a complete example for using GradCAM:
from torchray.attribution.grad_cam import grad_cam
from torchray.benchmark import get_example_data, plot_example
# Obtain example data.
model, x, category_id, _ = get_example_data()
# Grad-CAM backprop.
saliency = grad_cam(model, x, category_id, saliency_layer='features.29')
# Plots.
plot_example(x, saliency, 'grad-cam backprop', category_id)
Requirements
TorchRay requires:
- Python 3.6 or greater
- pytorch 1.1.0 or greater
- matplotlib
For benchmarking, it also requires:
- torchvision 0.3.0 or greater
- pycocotools
- mongodb (suggested)
- pymongod (suggested)
On Linux/macOS, using conda you can install
while read requirement; do conda install \
-c defaults -c pytorch -c conda-forge --yes $requirement; done <<EOF
pytorch>=1.1.0
pycocotools
torchvision>=0.3.0
mongodb
pymongo
EOF
Installing TorchRay
Using pip
:
pip install torchray
From source:
python setup.py install
or
pip install .
Full documentation
The full documentation can be found here.
Changes
See the CHANGELOG.
Join the TorchRay community
See the CONTRIBUTING file for how to help out.
The team
TorchRay has been primarily developed by Ruth C. Fong and Andrea Vedaldi.
License
TorchRay is CC-BY-NC licensed, as found in the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file torchray-1.0.0.2.tar.gz
.
File metadata
- Download URL: torchray-1.0.0.2.tar.gz
- Upload date:
- Size: 376.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bc9ae99c8d0587a9ddf99c17a330585660c59a6fd131b9354c40355955f27d6 |
|
MD5 | 8f2872d149778fa877703dd2e0df736f |
|
BLAKE2b-256 | 6b3e339cd7a0866b0ec501f7507b89d293e1515d4b1e308eeaed0fd75e7d2614 |