AnAppleCore / NN_visualize

Visualizing Neural Networks with graphviz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NN_visualize

Visualizing Neural Networks with graphviz

Introduction

Represent NN as a graph where nodes indicate neurons. It is important that we treate each convolutional channel as one neuron, so the neural network can be visualized in a fully connected way, which is significantlt straightforward.

Here we take the convolutional backend of AlexNet as an example:

alexnet

Problem is, number of channels in CNN is enormous, so we grouped neurons with fixed group cardinality (16 for AlexNet, see vis_alexnet.py for details). Color of neurons here denotes various neuron activity, given a single input image.

Quick Start

    1. Make sure graphviz is installed. For Linux users:
        sudo-apt install graphiviz & pip3 install graphviz
    
    1. Generate .dot graph configuration files
    python vis_alexnet.py
    
    1. Generate output image
    dot -Tpdf -o ./img/alexnet_1.pdf ./configs/alexnet_1.dot
    
    1. We provide extra scripts for plotting neuronal activity curves in plot_curve.py

alexnet

Note

  • The neural network activity record in records are recorded for one given image, specifically we add one global average pooling layer after each convolutional layer of AlexNet, and stored this aggregated features for each layer. Users could write scripts based on vis_alexnet.py for other network architecture.

About

Visualizing Neural Networks with graphviz

License:MIT License


Languages

Language:Python 55.7%Language:Shell 44.3%