Learn everything about Analytics

This Python Library Visualizes Artificial Neural Networks (ANNs) with just One Line of Code

SHARE
, / 0

Overview

  • Visualize your ANN with just a line of code, using the ‘ANN Visualizer’ python library
  • It works with Keras and makes use of the ‘graphviz’ library
  • Check out the installation instructions and a sneak peak of how the visualization looks like below

 

Introduction

Vizualizing data lies at the core of any good data scientist’s skillset. It gives a holistic view of what could be hidden in the data. But with advanced in deep learning, you can visualise the entire deep learning process or just the Convolutional Neural Network you’ve built.

Now, you can even visualize an Artificial Neural Network using just a line of code. ANN Visualizer is a visualization library used to work with Keras. It makes use of python’s ‘graphviz’ library to create a neat and presentable graph of the neural network you’re building.

You can install the library using the below command:

pip install ann_visualizer

To generate the visualization, you need to follow the below command structure:

ann_viz(model, view=True, filename=”network.gv”, title=”MyNeural Network”)

  • model – Your Keras sequential model
  • view – If set to true, it opens the graph preview after the command has been executed
  • filename – Where to save the graph. (it’s saved in a ‘.gv’ file format)
  • title – The title for the visualized ANN

Below is an example of what the final visualization looks like:

Beautifully done, isn’t it? You can go through this GitHub repository here to look at a demo of how a model is created and visualized.

 

Our take on this

This is useful in a lot of ways. It can be used for teaching purposes when you want to explain how your NN looks like without having to run a lot of code. There have been previous efforts in this area but with the ease of effort and the beautifully optimised output, this is a library worth checking out.

It currently only visualizes dense layers but the developers has indicated that convolution and LSTM layers might be added soon. Keep in mind that this is still an unstable release so you might encounter a bug here and there but don’t let that put you off from trying it out!

 

Subscribe to AVBytes here to get regular data science, machine learning and AI updates in your inbox!