chr5tphr / zennit

Zennit is a high-level framework in Python using PyTorch for explaining/exploring neural networks using attribution methods like LRP.
Other
200 stars 32 forks source link

Color-Map Overhaul #52

Closed chr5tphr closed 3 years ago

chr5tphr commented 3 years ago

cmsl are comma-separated hexa-decimal values, with an arbitrary index before each value. If no index is specified, the indices of the colors are evenly spaced from 0 to 255, or between their neighbors with indices.

A color-map from blue to white to red may be specified equivalently as

If the first and last indices are not zero, they are assumed to not change until the respective boundaries, ie. a color map which only shows the sign as either blue or red may be specified as

If indices are supplied, they must be in ascending order from left to right.

Built-in color-maps are implemented as

sources = {
    # black to white
    'gray': '000,fff',
    # white to red
    'wred': 'fff,f00',
    # white to blue
    'wblue': 'fff,00f',
    # black to red to yellow to white
    'hot': '000,f00,ff0,fff',
    # black to blue to cyan
    'cold': '000,00f,0ff',
    # combination of cold (reversed) and hot, centered around black
    'coldnhot': '0ff,00f,80:000,f00,ff0,fff',
    # combination of wblue (reversed) and wred, centered around white
    'bwr': '00f,80:fff,f00',
    # red to white to blue as in the french flag
    'france': '0055a4,80:fff,ef4135',
    # red to white to blue with brightness 0xd0
    'seismic': 'd00000,80:d0d0d0,0000d0',
    # cyan to white to magenta with brightness 0xd0
    'coolio': '00d0d0,80:d0d0d0,d000d0',
    # green to white to magenta with brightness 0xd0
    'coleus': '00d000,80:d0d0d0,d000d0',
}
Here is an example of all built-in color-maps visualized: In order: - `gray` - `wred` - `wblue` - `hot` - `cold` - `coldnhot` - `bwr` - `france` - `seismic` - `coolio` - `coleus` ![image](https://user-images.githubusercontent.com/15217558/137356147-a8d7f6ee-a906-4763-99b3-03ffd58c3afd.png)