# How to Design and Visualize a Neural Network

I will introduce some tools…

### Tools to Design or Visualize Architecture of Neural Network

1.  [Net2Vis](https://viscom.net2vis.uni-ulm.de/OG1Br2BAkYSwwrV6CADl4X5EfErFjUzvuUwXWDdLbdsIXNhb9L): Net2Vis automatically generates abstract visualizations for convolutional neural networks from Keras code.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834315295/1xsl3EVrL.png)

2.[visualkeras](https://github.com/paulgavrikov/visualkeras/) : Visualkeras is a Python package to help visualize Keras (either standalone or included in tensorflow) neural network architectures. It allows easy styling to fit most needs. As of now it supports layered style architecture generation which is great for CNNs (Convolutional Neural Networks) and a grap style architecture.

import visualkeras

model = ...

visualkeras.layered\_view(model).show() # display using your system viewer  
visualkeras.layered\_view(model, to\_file='output.png') # write to disk  
visualkeras.layered\_view(model, to\_file='output.png').show() # write and show

visualkeras.layered\_view(model)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834316628/56RQw9SmlN.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834317882/AfC1C5s0QY.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834319241/f_cq4jOEc.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834320408/XVBrg0JVA.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834321657/ZSs_MFhzC.png)

3. [draw\_convnet](https://github.com/gwding/draw_convnet) : Python script for illustrating Convolutional Neural Network (ConvNet)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834322924/pfrNDoePd.png)

4.[NNSVG](http://alexlenail.me/NN-SVG/LeNet.html)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834324128/EJ5otBfPq.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834326020/yMoiwS_92.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834327553/M8TsCZKKf.png)

5.[PlotNeuralNet](https://github.com/HarisIqbal88/PlotNeuralNet) : Latex code for drawing neural networks for reports and presentation. Have a look into examples to see how they are made. Additionally, lets consolidate any improvements that you make and fix any bugs to help more people with this code.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834329213/tQuQcmJJY.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834330675/QSsQNfm4w.png)

6.[Tensorboard](https://www.tensorflow.org/tensorboard/graphs) — TensorBoard’s Graphs dashboard is a powerful tool for examining your TensorFlow model.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834332132/Q8d4T0bLV.png)

7.[Caffe](https://github.com/BVLC/caffe/blob/master/python/caffe/draw.py) — In Caffe you can use [caffe/draw.py](https://github.com/BVLC/caffe/blob/master/python/caffe/draw.py) to draw the NetParameter protobuffer:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834333473/fky1UFr-0.png)

8.[Matlab](http://www.mathworks.com/help/nnet/ref/view.html)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834334795/mrwW2PXrM.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834336035/VWjUX-KkO.png)

[https://www.mathworks.com/help/deeplearning/ref/view.html;jsessionid=64c8d808937d17a0ca49be12bc17](https://www.mathworks.com/help/deeplearning/ref/view.html;jsessionid=64c8d808937d17a0ca49be12bc17)

8.[Keras.js](https://transcranial.github.io/keras-js/#/inception-v3)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834337339/rdpkTOfhv.png)

9\. [keras-sequential-ascii](https://github.com/stared/keras-sequential-ascii/) — A library for [Keras](https://keras.io/) for investigating architectures and parameters of sequential models.

VGG 16 Architecture

```
OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)
```

```
 Input   #####      3  224  224  
         InputLayer     |   -------------------         0     0.0%  
                      #####      3  224  224  
      Convolution2D    \|/  -------------------      1792     0.0%  
               relu   #####     64  224  224  
      Convolution2D    \|/  -------------------     36928     0.0%  
               relu   #####     64  224  224  
       MaxPooling2D   Y max -------------------         0     0.0%  
                      #####     64  112  112  
      Convolution2D    \|/  -------------------     73856     0.1%  
               relu   #####    128  112  112  
      Convolution2D    \|/  -------------------    147584     0.1%  
               relu   #####    128  112  112  
       MaxPooling2D   Y max -------------------         0     0.0%  
                      #####    128   56   56  
      Convolution2D    \|/  -------------------    295168     0.2%  
               relu   #####    256   56   56  
      Convolution2D    \|/  -------------------    590080     0.4%  
               relu   #####    256   56   56  
      Convolution2D    \|/  -------------------    590080     0.4%  
               relu   #####    256   56   56  
       MaxPooling2D   Y max -------------------         0     0.0%  
                      #####    256   28   28  
      Convolution2D    \|/  -------------------   1180160     0.9%  
               relu   #####    512   28   28  
      Convolution2D    \|/  -------------------   2359808     1.7%  
               relu   #####    512   28   28  
      Convolution2D    \|/  -------------------   2359808     1.7%  
               relu   #####    512   28   28  
       MaxPooling2D   Y max -------------------         0     0.0%  
                      #####    512   14   14  
      Convolution2D    \|/  -------------------   2359808     1.7%  
               relu   #####    512   14   14  
      Convolution2D    \|/  -------------------   2359808     1.7%  
               relu   #####    512   14   14  
      Convolution2D    \|/  -------------------   2359808     1.7%  
               relu   #####    512   14   14  
       MaxPooling2D   Y max -------------------         0     0.0%  
                      #####    512    7    7  
            Flatten   ||||| -------------------         0     0.0%  
                      #####       25088  
              Dense   XXXXX ------------------- 102764544    74.3%  
               relu   #####        4096  
              Dense   XXXXX -------------------  16781312    12.1%  
               relu   #####        4096  
              Dense   XXXXX -------------------   4097000     3.0%  
            softmax   #####        1000
```

10.[Netron](https://github.com/lutzroeder/Netron)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834338631/Yq_5CAzHR.png)

[https://github.com/lutzroeder/netron](https://github.com/lutzroeder/netron)

Netron is a viewer for neural network, deep learning and machine learning models.

Netron supports ONNX, TensorFlow Lite, Caffe, Keras, Darknet, PaddlePaddle, ncnn, MNN, Core ML, RKNN, MXNet, MindSpore Lite, TNN, Barracuda, Tengine, CNTK, TensorFlow.js, Caffe2 and UFF.

Netron has experimental support for PyTorch, TensorFlow, TorchScript, OpenVINO, Torch, Vitis AI, Arm NN, BigDL, Chainer, Deeplearning4j, MediaPipe, ML.NET and scikit-learn.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834339911/ZPjz1yfKr.png)

11.[DotNet](https://github.com/martisak/dotnets)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834341268/dNm3_O_yf.png)

[https://github.com/Sergio0694/NeuralNetwork.NET](https://github.com/Sergio0694/NeuralNetwork.NET)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834342643/yP2t41gxh.png)

12.[Graphviz](http://www.graphviz.org/)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834343971/hxebzRyWo.png)

[https://graphviz.org/](https://graphviz.org/)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834345240/lG622H4NkG.png)

13.[Keras Visualization](https://keras.io/visualization/)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834346751/5ZqFifXCv.png)

[https://raghakot.github.io/keras-vis/](https://raghakot.github.io/keras-vis/)

The [keras.utils.vis\_utils module](https://keras.io/visualization/) provides utility functions to plot a Keras model (using graphviz)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834348416/meMvqA3bM.png)

14.[Conx](https://conx.readthedocs.io/en/latest/index.html)

The Python package `conx` can visualize networks with activations with the function `net.picture()` to produce SVG, PNG, or PIL Images like this:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834350197/iyy43nv4q.png)

15.[ENNUI](https://math.mit.edu/ennui/) — Working on a drag-and-drop neural network visualizer (and more). Here’s an example of a visualization for a LeNet-like architecture.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834351402/6eEu5JHzB.png)

16.NNet — R Package — [Tutorial](https://beckmw.wordpress.com/2013/03/04/visualizing-neural-networks-from-the-nnet-package/)

```
data(infert, package="datasets")  
plot(neuralnet(case~parity+induced+spontaneous, infert))
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834352655/1WWjcN9mz.png)

17.[GraphCore](https://www.graphcore.ai/posts/what-does-machine-learning-look-like)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834353979/FIgbh_sjp.png)

[https://www.graphcore.ai/](https://www.graphcore.ai/)

These approaches are more oriented towards visualizing neural network operation, however, NN architecture is also somewhat visible on the resulting diagrams.

AlexNet

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834355398/0prD0RMpI.jpeg)

ResNet50

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834357321/gR938ReNF.jpeg)

18.[Neataptic](https://wagenaartje.github.io/neataptic/)

Neataptic offers flexible neural networks; neurons and synapses can be removed with a single line of code. No fixed architecture is required for neural networks to function at all. This flexibility allows networks to be shaped for your dataset through neuro-evolution, which is done using multiple threads.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834358847/CAcbwWDz_.png)

19.[TensorSpace](https://tensorspace.org/) : TensorSpace is a neural network 3D visualization framework built by TensorFlow.js, Three.js and Tween.js. TensorSpace provides Layer APIs to build deep learning layers, load pre-trained models, and generate a 3D visualization in the browser. By applying TensorSpace API, it is more intuitive to visualize and understand any pre-trained models built by TensorFlow, Keras, TensorFlow.js, etc.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834360308/AbwIjJEBB.png)

​

20.[Netscope CNN Analyzer](http://dgschwend.github.io/netscope/quickstart.html)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834361522/oO_MX3DkC.png)

21.[Monial](https://github.com/mlajtos/moniel)

Interactive Notation for Computational Graphs [https://mlajtos.github.io/moniel/](https://mlajtos.github.io/moniel/)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834362756/P7ILdJatR.png)

22.[Texample](http://www.texample.net/tikz/examples/neural-network/)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834364049/QX2-5-Fqk.png)

```
\documentclass{article}
```

```
\usepackage{tikz}  
\begin{document}  
\pagestyle{empty}
```

```
\def\layersep{2.5cm}
```

```
\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep]  
    \tikzstyle{every pin edge}=[<-,shorten <=1pt]  
    \tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]  
    \tikzstyle{input neuron}=[neuron, fill=green!50];  
    \tikzstyle{output neuron}=[neuron, fill=red!50];  
    \tikzstyle{hidden neuron}=[neuron, fill=blue!50];  
    \tikzstyle{annot} = [text width=4em, text centered]
```

```
 % Draw the input layer nodes  
    \foreach \name / \y in {1,...,4}  
    % This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}  
        \node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {};
```

```
 % Draw the hidden layer nodes  
    \foreach \name / \y in {1,...,5}  
        \path[yshift=0.5cm]  
            node[hidden neuron] (H-\name) at (\layersep,-\y cm) {};
```

```
 % Draw the output layer node  
    \node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {};
```

```
 % Connect every node in the input layer with every node in the  
    % hidden layer.  
    \foreach \source in {1,...,4}  
        \foreach \dest in {1,...,5}  
            \path (I-\source) edge (H-\dest);
```

```
 % Connect every node in the hidden layer with the output layer  
    \foreach \source in {1,...,5}  
        \path (H-\source) edge (O);
```

```
 % Annotate the layers  
    \node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer};  
    \node[annot,left of=hl] {Input layer};  
    \node[annot,right of=hl] {Output layer};  
\end{tikzpicture}  
% End of code  
\end{document}
```

23.[Quiver](https://github.com/keplr-io/quiver)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834366140/D9fzYsRnI.gif)

#### Types of Neural Network

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834367936/61wBe703y.png)

#### References :

1.  [https://datascience.stackexchange.com/questions/12851/how-do-you-visualize-neural-network-architectures](https://datascience.stackexchange.com/questions/12851/how-do-you-visualize-neural-network-architectures)
2.  [https://github.com/Python-2030/Tools-to-Design-or-Visualize-Architecture-of-Neural-Network](https://github.com/Python-2030/Tools-to-Design-or-Visualize-Architecture-of-Neural-Network)
3.  [https://datascience.stackexchange.com/questions/2670/visualizing-deep-neural-network-training](https://datascience.stackexchange.com/questions/2670/visualizing-deep-neural-network-training)
