zennit.composites
Composites, registered in a global composite dict.
Functions
Register a composite in the global COMPOSITES dict under name. |
Classes
An explicit composite modifying the gradients of all ReLUs according to DeconvNet [Zeiler and Fergus, 2014]. |
|
An explicit composite using the alpha2-beta1 rule for all convolutional layers and the epsilon rule for all fully connected layers. |
|
An explicit composite using the flat rule for any linear first layer, the alpha2-beta1 rule for all other convolutional layers and the epsilon rule for all other fully connected layers. |
|
An explicit composite using the ZBox rule for the first convolutional layer, gamma rule for all following convolutional layers, and the epsilon rule for all fully connected layers. |
|
An explicit composite using the zplus rule for all convolutional layers and the epsilon rule for all fully connected layers. |
|
An explicit composite using the flat rule for any linear first layer, the zplus rule for all other convolutional layers and the epsilon rule for all other fully connected layers. |
|
An explicit composite implementing the ExcitationBackprop [Zhang et al., 2016]. |
|
An explicit composite modifying the gradients of all ReLUs according to GuidedBackprop [Springenberg et al., 2015]. |
|
A Composite for which hooks are specified by a mapping from module types to hooks. |
|
A Composite for which hooks are specified by a mapping from module types to hooks. |
|
A Composite for which hooks are specified by a mapping from module types to hooks. |
- class zennit.composites.DeconvNet(canonizers=None)[source]
Bases:
LayerMapComposite
An explicit composite modifying the gradients of all ReLUs according to DeconvNet [Zeiler and Fergus, 2014].
- class zennit.composites.EpsilonAlpha2Beta1(canonizers=None)[source]
Bases:
LayerMapComposite
An explicit composite using the alpha2-beta1 rule for all convolutional layers and the epsilon rule for all fully connected layers.
- class zennit.composites.EpsilonAlpha2Beta1Flat(canonizers=None)[source]
Bases:
SpecialFirstLayerMapComposite
An explicit composite using the flat rule for any linear first layer, the alpha2-beta1 rule for all other convolutional layers and the epsilon rule for all other fully connected layers.
- class zennit.composites.EpsilonGammaBox(low, high, canonizers=None)[source]
Bases:
SpecialFirstLayerMapComposite
An explicit composite using the ZBox rule for the first convolutional layer, gamma rule for all following convolutional layers, and the epsilon rule for all fully connected layers.
- Parameters
low (obj:torch.Tensor) – A tensor with the same size as the input, describing the lowest possible pixel values.
high (obj:torch.Tensor) – A tensor with the same size as the input, describing the highest possible pixel values.
- class zennit.composites.EpsilonPlus(canonizers=None)[source]
Bases:
LayerMapComposite
An explicit composite using the zplus rule for all convolutional layers and the epsilon rule for all fully connected layers.
- class zennit.composites.EpsilonPlusFlat(canonizers=None)[source]
Bases:
SpecialFirstLayerMapComposite
An explicit composite using the flat rule for any linear first layer, the zplus rule for all other convolutional layers and the epsilon rule for all other fully connected layers.
- class zennit.composites.ExcitationBackprop(canonizers=None)[source]
Bases:
LayerMapComposite
An explicit composite implementing the ExcitationBackprop [Zhang et al., 2016].
- class zennit.composites.GuidedBackprop(canonizers=None)[source]
Bases:
LayerMapComposite
An explicit composite modifying the gradients of all ReLUs according to GuidedBackprop [Springenberg et al., 2015].
- class zennit.composites.LayerMapComposite(layer_map, canonizers=None)[source]
Bases:
Composite
A Composite for which hooks are specified by a mapping from module types to hooks.
- Parameters
layer_map (list[tuple[tuple[torch.nn.Module, …], Hook]]) – A mapping as a list of tuples, with a tuple of applicable module types and a Hook.
- mapping(ctx, name, module)[source]
Get the appropriate hook given a mapping from module types to hooks.
- Parameters
ctx (dict) – A context dictionary to keep track of previously registered hooks.
name (str) – Name of the module.
module (obj:torch.nn.Module) – Instance of the module to find a hook for.
- Returns
obj – The hook found with the module type in the given layer map, or None if no applicable hook was found.
- Return type
Hook or None
- class zennit.composites.NameMapComposite(name_map, canonizers=None)[source]
Bases:
Composite
A Composite for which hooks are specified by a mapping from module types to hooks.
- Parameters
name_map (list[tuple[tuple[str, …], Hook]]) – A mapping as a list of tuples, with a tuple of applicable module names and a Hook.
- mapping(ctx, name, module)[source]
Get the appropriate hook given a mapping from module names to hooks.
- Parameters
ctx (dict) – A context dictionary to keep track of previously registered hooks.
name (str) – Name of the module.
module (obj:torch.nn.Module) – Instance of the module to find a hook for.
- Returns
obj – The hook found with the module type in the given name map, or None if no applicable hook was found.
- Return type
Hook or None
- class zennit.composites.SpecialFirstLayerMapComposite(layer_map, first_map, canonizers=None)[source]
Bases:
LayerMapComposite
A Composite for which hooks are specified by a mapping from module types to hooks.
- Parameters
layer_map (list[tuple[tuple[torch.nn.Module, …], Hook]]) – A mapping as a list of tuples, with a tuple of applicable module types and a Hook.
first_map (list[tuple[tuple[torch.nn.Module, …], Hook]]) – Applicable mapping for the first layer, same format as layer_map.
- mapping(ctx, name, module)[source]
Get the appropriate hook given a mapping from module types to hooks and a special mapping for the first occurrence in another mapping.
- Parameters
ctx (dict) – A context dictionary to keep track of previously registered hooks.
name (str) – Name of the module.
module (obj:torch.nn.Module) – Instance of the module to find a hook for.
- Returns
obj – The hook found with the module type in the given layer map, in the first layer map if this was the first layer, or None if no applicable hook was found.
- Return type
Hook or None