This tool allows you to visualize the inner workings of a neural network model. You can load a pre-trained model, input data, and see how the data propagates through the network layers. The tool provides a graphical interface to input data, visualize neuron activations, and connections.
- Load and visualize pre-trained neural network models.
- Input data through a graphical interface (Copy paste supported).
- Visualize neuron activations and connections.
- Cluster neurons for better visualization performance.
- Display feature importance (if feature importance file is available).
Python can be downloaded from the official website: python.org
If you want to use PyTorch with GPU support (recommended), check PyTorch documentation for instructions.
-
Clone the repository:
git clone <repository_url> cd <repository_directory>
-
Create a Python virtual environment using the installed Python version (recommended).
-
Install the required packages:
pip install -r requirements.txt
note: the PyTorch included in the requirements file is for CPU support.
Open your desired Python file:
VisualiseNeuralNetTensor.py
for Tensor models.VisualiseNeuralNetTorch.py
for Torch models.
You will be asked to select what device you want to use.
- If you have installed PyTorch with GPU support, the option to use the GPU will be available.
- If you have multiple GPUs, you can select which one to use.
- Click on the Select Model button to open a file dialog.
- Choose the
.keras
(Tensor) or.pt
(Torch) model file to load.
- Enter values for each feature in the input boxes on the left side of the window.
- For categorical features, a dropdown menu will appear.
Create a MappingValues.csv
file in the same directory as the model file. The MappingValues.csv
file should contain the mapping of feature names to their possible values or ranges. This file is necessary for the tool to correctly interpret the input values for the model.
The format of the file should be as follows:
Feature1 , Feature2 , Feature3 , ...
"[min1, max1]", "[value1, value2, value3]", "[min3, max3]", ...
Example available in model example\
folder.
-
Use the format
"[min, max]"
to specify the range of possible values.Here,
min
will be mapped to 0, andmax
will be mapped to 1. -
Use the format
"[value1, value2, value3]"
to specify the possible values, they will be interpreted from left to right in the range [0, 1].Here,
value1
will be mapped to 0,value2
to 0.5, andvalue3
to 1.
The feature importance file should contain the importance values for each feature in the model. It's only used to adjust the size of the input neurons in the visualization.
The format of the file should be as follows:
Feature , Importance
Feature1, 0.5
Feature2, 0.3
Feature3, 0.2
...
Order does not matter.
-
Colors:
- Positive activations: #5BAFFC (blue)
- Negative activations: #FD4F59 (red)
-
Layout:
- Input boxes are aligned on the left side.
- Visualization area is on the right side.
- The window is resizable (with a min size), and the layout adjusts accordingly.
- Neurons are clustered using hierarchical clustering to improve visualization performance.
- Clustering can be toggled on or off (no clustering can lead to performance issues with large networks).
- The threshold for a layer to be clustered can be adjusted (default is 50 neurons).
- Neurons are displayed as circles.
- Connections between neurons are displayed as lines.
- The color of each connection represents the value transmitted.
- The color alpha of each connection represents the weight of the connection.
- The size of the input neurons represents their importance (if provided).
- Ensure that the model file is in the correct
.keras
format for Tensor or in.pt
for Torch. - Ensure that the mapping file
MappingValues.csv
is available in the same directory as the model file. - Check the console for any error messages.
- If you are still facing issues, you can directly contact me at [email protected].