TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Follow publication

How to Visualize Neural Network Architectures in Python

A quick guide to creating diagrammatic representation of your Neural Networks using Jupyter or Google Colab

Angel Das
TDS Archive
Published in
7 min readOct 29, 2022

--

Image Credit — Developed by the author using visualkeras and Jupyter Notebook.

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:

  1. 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.
  2. 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.

  1. ANN Visualizer
  2. Visual Keras
  3. Keras Model Plot
  4. Tensor Board

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

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Angel Das
Angel Das

Written by Angel Das

Data Science Consultant at IQVIA ANZ || Former Data Science Analyst at Novartis AU, Decision Scientist with Mu Sigma || Ex Teaching Associate Monash University

Responses (1)

Write a response