Skip to main content

Library to visualize the activations of the hidden layers of artificial neural networks

Project description

Neural Response Map

Neural Response Map is a tool that allows you to graphically detect the activations of artificial neural networks. To do this, the correlation between neuron activations is calculated and then t-SNE is applied to reduce the dimension. In this way the correlated neurons are plotted close to each other. This process allows observing the activation of neurons and obtaining the response to different stimuli such as the graphs presented by DeepMind in his paper.

Instalation

To install you can use the following command

pip install neural-response-map

Quick Start

To make use of the tool, first import the components

from neural_response_map import NeuralResponseMap

Then you need to instantiate the class. For this you must pass the tensorflow model as a parameter

nrm = NeuralResponseMap(model)

Next you need to train the mapper. This function calculates the correlation between the neurons and performs the dimensionality reduction for subsequent graphs. For this you must pass the inputs as a parameter. The inputs are sample input data of the neural network, for example if your network is a VGG16, the inputs are images of your dataset. Also, if you wish, you can pass the layers you want to view as a parameter. If you don't pass the layers as a parameter, the visualization will use all the layers of the model.

nrm.TrainMap(inputs, model.layers[:2])

Finally you can visualize your Neural Response Map. To perform the visualization you must call GenerateMap and pass as a parameter the input examples that you want to visualize. If you pass more than one example, the display will be the average of all the Neural Response Maps of the input data.

nrm.GenerateMap(inputs[1:2])

GenerateMap allows other optional parameters:

  • method: this parameter controls the display method which can be linear or nearest. The linear method performs a linear interpolation between the values of the neuron's activations. Nearest, on the other hand, does not perform interpolation. The nearest method is the default value.
  • cmap: it is the color map that you want to use, by default it is viridis. If you want to know other visualization maps visit the following link.
  • size: it is the size of the image. This value is a tuple with (5,5) by default.
  • file: is the name and type of file in which you want to save the image (for example 'map.png'). If no path is passed the image is not saved.

Alternatively after the TrainMap call, you can call CircleProjection. This will make the Neural Response Map more circular in shape.

nrm.CircleProjection()
nrm.GenerateMap(inputs[1:2])

Authors

This package has been developed by:

Joan Alberto Cerretani

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

neural_response_map-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

neural_response_map-1.0.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file neural_response_map-1.0.0.tar.gz.

File metadata

  • Download URL: neural_response_map-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.8

File hashes

Hashes for neural_response_map-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e0e1621db8d29986d9d400a1d3b00df0fc1b0c0b063c4615bca8467ca1cc1774
MD5 856dbb4fbc8c4d9471f6d2ae9a4f8298
BLAKE2b-256 71115a1754ab6e901f18b68d3bf1d0c97ddfaadc8ec0fc52d41ad5c5f65181db

See more details on using hashes here.

File details

Details for the file neural_response_map-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for neural_response_map-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7b65c375a281ca8d8d0cf092ada8e09157e1b405f561671a296bb56eaacc251
MD5 7ae64d9a5e7e940bd3c77c1438d6b1bc
BLAKE2b-256 b0538e59969a4a0c0fe94c65e037fde44ae44ca8cddebcb39c70115185da5128

See more details on using hashes here.

Supported by

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