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.

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.


Arguments for plt.imshow function.


Matplotlib axis instance.


>>> 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)

Returns tensorflow variables for saliency map.

network : network
image : ndarray