Visualization of Interaction Between Neurons using Lucid
This KietzmannLab package was generated with Cookiecutter using @KietzmannLab's cookiecutter-template template.
Starting from random noise, we optimize an image to activate a particular neuron. A neuron is a certain layer of the trained network at a certain channel. The optimization function used is the negative of the spatial activation map at that layer and channel and after iterating for 512 steps a random noise image is transformed to the features that maximally activate that particular neuron.
Using this approach we can convincingly show that earlier neural network layers maximally activate Gabor like features (edges at different orientation and scale) while the later layers are more feature rich containing object level features.
By visualizing different channles of a certain layer we show the diversity captured by the trained model. In this repository we use pre-trained Alexnet models trained on ecoset. Using any pre-trained model seeds the maximal activations of different layers of AlexNet model can be seen interactively or by iterating over all the layers and saving the results as png files for each layer and channel using this script. Prior to running the notebook or the script please install the package in your virtual environment by following the instructions below.
You can install lucid-kietzmannlab
via pip:
pip install git+https://github.com/KietzmannLab/lucid-kietzmannlab.git
It is recommended to do the installation in a virtual conda environment, if you do not have a conda environment you can create one using:
conda create -n conda_env_name python=3.12
Then activate the environment and install the package using pip as mentioned above.
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
Distributed under the terms of the BSD-3 license, "lucid-kietzmannlab" is free and open source software
If you encounter any problems, please file an issue along with a detailed description.