neupy.plots.saliency_map module

neupy.plots.saliency_map.saliency_map(network, image, mode='heatmap', sigma=8, ax=None, show=True, **kwargs)[source]

Saliency Map plot.

Parameters:
network : network

Network based on which will be computed saliency map.

image : 3D array-like tensor

Image based on which will be computed saliency map.

mode : {raw, heatmap}
  • raw Visualize raw gradient. White color on the plot defines high gradient values.
  • heatmap Applies gaussian filter to the gradient and visualize as a heatmap plot.

Defaults to heatmap.

sigma : float

Standard deviation for kernel in Gaussian filter. It is used only when mode='heatmap'. Defaults to 8.

ax : object or None

Matplotlib axis object. None values means that axis equal to the current axes instance (the same as ax = plt.gca()). Defaults to None.

show : bool

If parameter is equal to True then plot will be displayed. Defaults to True.

**kwargs

Arguments for plt.imshow function.

Returns:
object

Matplotlib axis instance.

Examples

>>> from neupy import layers, plots
>>>
>>> network = layers.join(
...     layers.Input((3, 28, 28)),
...     layers.Convolution((32, 3, 3)) >> layers.Relu(),
...     layers.Reshape(),
...     layers.Softmax(10),
... )
>>>
>>> dog_image = load_dog_image()
>>> plots.saliency_map(network, dog_image)
neupy.plots.saliency_map.saliency_map_graph(network)[source]

Returns tensorflow variables for saliency map.

Parameters:
network : network
image : ndarray