This module contains a convolutional neural network visualization techniques implemented using Guided BackPropagation in Tensorflow. Even if the implementation is in Tensorflow the module inculdes a model convertion class that enables it to support multiple other frameworks, such as, Pytorch, Caffe and Theano.
The implementation here is based on the repo from here
- pytorch
- Tensorflow
- numpy
- matplotlib
- PIL
- onnx
- onnx-tf
- First make sure you have the required packages above
- Clone the repository
- Navigate in to the cloned folder and then to the src subdirectory. Then move into the 'main' folder
- Then run: -$ python setup.py install
pip install CNNFilterVisualizer
open the Python REPL and import CNNFilterVisualizer
After importing the module into your program
-
Create an object of the FilterVisualizer class by passing a pytorch or a tensorflow model
-
Then using the visualize functions in the same class you can visualze each fiter in each layer by passing the appropriate parameters
# first create an object of the class by passing your model
fv = FilterVisualizer(model=your_model, framework='tensorflow')
# call the visualize method passing in the image, layer_index and filter_index
# note: to visualize all the filters in a layer, pass in the string "All" to the
# parameter filter_index
fv.visualize(input_image=image_used_for_visualization,
cnn_layer=model_layer_to_visualize,
filter_pos=filter_of_the_layer_to_visualize,
normalize=bool_value_that_determines_normalization)
You can also checkout the example notebook in this repo to see the activations features of an alexnet model with a picture of a dog.
- Striving for Simplicity: The All Convolutional Net
- @utkuozbulak pytorch-cnn-visualizations repo
- @conan7882 repo
If you want to understand more about the implemtation i recomend that you check out the above references.