Skip to main content

visualization tool for tensor in CNN

Project description

visactivation

Written by YudeWang

A simple visualization tool for tensor activation in CNN.

Install

pip install visactivation

Document

visactivation.Tensor2Color(tensor, input_type=None, image=None, image_weight=0.3, colormap=cv2.COLORMAP_JET, act_type='max', norm_type='all')

Coloring the feature map in CNN to visualize the corresponding activation intensity.

Parameters:

  • tensor (numpy.ndarray) - the input tensor for visualization
  • input_type (str) - 'NCHW', 'NHW','CHW','HW'. When tensor.ndim == 3, input_type must be given.
  • image (numpy.ndarray, optional) - corresponding image with size NHW3 or HW3
  • image_weight (float, optional) - weight of image when visualization activation
  • colormap (int, str)
    • int - cv2.COLORMAP_xxx can be used here
    • str - 'voc' PASCAL VOC colormap, 'random' Random colormap
  • act_type (str) - 'sum', 'max', 'mean', 'none'.
    • 'sum' - choose the sum value in channel dimension for each spatial pixel
    • 'max' - choose the max value in channel dimension for each spatial pixel
    • 'mean' - choose the mean value in channel dimension for each spatial pixel
    • 'none' - preseve the activation of C channels and visualize them independently.
  • norm_type (str) - 'relu','all'.
    • 'relu' - tensor[tensor<0]=0, tensor/max(tensor)
    • 'all' - (tensor-min)/(max-min)

Return:

N x C x H x W x 3 size numpy ndarray

visactivation.Prob2Color(tensor, input_type=None, image=None, image_weight=0.3, colormap=cv2.COLORMAP_JET, act_type='max')

Coloring the probability map in CNN to visualize the corresponding activation intensity.

Parameters:

  • tensor (numpy.ndarray) - the input tensor for visualization, the value should in range [0,1]
  • input_type (str) - 'NCHW', 'NHW','CHW','HW'. When tensor.ndim == 3, input_type must be given.
  • image (numpy.ndarray, optional) - corresponding image with size NHW3 or HW3
  • image_weight (float, optional) - weight of image when visualization activation
  • colormap (int, str)
    • int - cv2.COLORMAP_xxx can be used here
    • str - 'voc' PASCAL VOC colormap, 'random' Random colormap
  • act_type (str) - 'sum', 'max', 'mean', 'none'.
    • 'sum' - choose the sum value in channel dimension for each spatial pixel. The result larger than 1 is cut off to 1.
    • 'max' - choose the max value in channel dimension for each spatial pixel
    • 'mean' - choose the mean value in channel dimension for each spatial pixel
    • 'none' - preseve the activation of C channels and visualize them independently.

Return:

N x C x H x W x 3 size numpy ndarray

visactivation.Label2Color(tensor, image=None, image_weight=0.3, colormap='random')

Coloring the label map predicted by to visualize the corresponding activation intensity.

Parameters:

  • tensor (numpy.ndarray) - the input label for visualization, the value should in be positive integer in [0, 255].
  • image (numpy.ndarray, optional) - corresponding image with size NHW3 or HW3
  • image_weight (float, optional) - weight of image when visualization activation
  • colormap (str) - 'voc' PASCAL VOC colormap, 'random' Random colormap

Return:

N x H x W x 3 size numpy ndarray

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visactivation-0.0.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

visactivation-0.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file visactivation-0.0.1.tar.gz.

File metadata

  • Download URL: visactivation-0.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.12

File hashes

Hashes for visactivation-0.0.1.tar.gz
Algorithm Hash digest
SHA256 34c96af4ba51a0225fdea8adb0dbd03fbd1dc9907023c47637c10a2958b4aebd
MD5 5911ee67af0d8d84c37e0321dbef556a
BLAKE2b-256 eaf9d88e288f4f80f40d65150ba6bfe241367f91a9bd134f04799fff1b2fcbd9

See more details on using hashes here.

File details

Details for the file visactivation-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: visactivation-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.12

File hashes

Hashes for visactivation-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d219a957db8ed5e86abd67b783483c6514a8dfe0955a94569db3b1fa6a9188a5
MD5 fe8b370de260fd2240692d971dcb20b0
BLAKE2b-256 dec17d41bf00ae58dacefef08299f0411c0c78aa02924ae06912c56030a25fe9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page