Notebooks I wrote to get familiar with pytorch, and where I try to implement LRP-gamma.
- Python files in the order of dependency
trainable_net.py
TrainableNet
: A class that can be subclassed instead oftorch.nn.Module
, which implements training and evaluating the accuracy- Some convenience functions like
one_hot
input_times_gradient(net, images, target_pattern)
cifar10_utils.py
<-trainable_net.py
- code of LeNet taken from the pytorch cifar10 tutorial.
- Some convenience methods like
one_hot
- A function to plot heatmaps
layerized_net.py
<-trainable_net.py
- A
Layer
and aLayerizedNet
class that convert existing models to layerized versions. The layer types have to be implemented for the specific use case.
- A
lrp.py
<-layerized_net.py
Layers and a network class that support deep taylor decomposition and LRP gamma.
- Notebooks
save_load_example.ipynb
is a minimal demo of how to use the net. It trains, saves and loads the net.lrp-gamma.ipynb
<-layerized_net.py
,cifar10_utils.py
Implementation and a few tests with deep taylor decomposition and lrp-gamma on cifar10. Here is wherelrp.py
comes frommnist_deeptaylor.ipynb
<-lrp.py
MNIST classifier and DTD usage, example how to uselrp.py
cifar10_adversarial_examples.ipynb
generates adversarial examples. They have been introduced heregradient_times_input.ipynb
<-trainable_net.py
,cifar10_utils.py
Example with cifar10