Member-only story
How to Visualize Neural Network Architectures in Python
A quick guide to creating diagrammatic representation of your Neural Networks using Jupyter or Google Colab

1. Introduction
Often while working with Artificial Neural Networks or other variations like Convolution Neural Networks or Recurrent Neural Networks, we want to visualize and create a diagrammatic representation of our compiled model. This can solve two purposes:
- While defining and training multiple models allows us to visualize the depth of our model and compare different layers and how they are sequentially laid down.
- Allows better understanding of the model structure, activation functions used in each layer, shape of each layer (number of neurons), and parameters that need to be trained
There are a few packages readily available in python that can create a visual representation of our Neural Network Models. The first three packages can be used even before a model is trained (the model needs to be defined and compiled only); however, Tensor Boards requires the user to train the model on accurate data before the architecture can be visualized.
2. Quick Guide on Installation
pip install visualkeraspip install ann_visualizerpip install graphviz
We don’t need to install the “Tensor Board” and “Keras Model Plot” separately. This will come with the initial installation of Tensorflow & Keras.
3. Setting Up Tensorflow Packages
We may utilize only a few of the libraries listed below. Most libraries can convert a TensorFlow model to a diagram without explicitly training it on data. You can consider this as a single source of truth. Some libraries, like Pandas, Skimage, and OpenCV, will come in handy when reading structured data or images.
# Import necessary librariesimport pandas as pd