Skip to content
This repository was archived by the owner on Oct 18, 2020. It is now read-only.

Repository files navigation

photophoto

ANN Visualizer

PyPI versionBuild StatusDonate

A great visualization python library used to work with Keras. It uses python's graphviz library to create a presentable graph of the neural network you are building.

Version 2.0 is Out!

Version 2.0 of the ann_visualizer is now released! The community demanded a CNN visualizer, so we updated our module. You can check out an example of a CNN visualization below!

Happy visualizing!

Installation

From Github

  1. Download the ann_visualizer folder from the github repository.
  2. Place the ann_visualizer folder in the same directory as your main python script.

From pip

Use the following command:

pip3 install ann_visualizer

Make sure you have graphviz installed. Install it using:

sudo apt-get install graphviz && pip3 install graphviz

Usage

fromann_visualizer.visualizeimportann_viz;
#Build your model hereann_viz(model)

Documentation

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

  • model - The Keras Sequential model
  • view - If True, it opens the graph preview after executed
  • filename - Where to save the graph. (.gv file format)
  • title - A title for the graph

Example ANN

importkeras;
fromkeras.modelsimportSequential;
fromkeras.layersimportDense;
network=Sequential();
#Hidden Layer#1network.add(Dense(units=6,
activation='relu',
kernel_initializer='uniform',
input_dim=11));
#Hidden Layer#2network.add(Dense(units=6,
activation='relu',
kernel_initializer='uniform'));
#Exit Layernetwork.add(Dense(units=1,
activation='sigmoid',
kernel_initializer='uniform'));
fromann_visualizer.visualizeimportann_viz;
ann_viz(network, title="");

This will output: photo

Example CNN

importkeras;
fromkeras.modelsimportSequential;
fromkeras.layersimportDense;
fromann_visualizer.visualizeimportann_vizmodel=build_cnn_model()
ann_viz(model, title="")
defbuild_cnn_model():
model=keras.models.Sequential()
model.add(
Conv2D(
32, (3, 3),
padding="same",
input_shape=(32, 32, 3),
activation="relu"))
model.add(Dropout(0.2))
model.add(
Conv2D(
32, (3, 3),
padding="same",
input_shape=(32, 32, 3),
activation="relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.2))
model.add(
Conv2D(
64, (3, 3),
padding="same",
input_shape=(32, 32, 3),
activation="relu"))
model.add(Dropout(0.2))
model.add(
Conv2D(
64, (3, 3),
padding="same",
input_shape=(32, 32, 3),
activation="relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.2))
model.add(Flatten())
model.add(Dense(512, activation="relu"))
model.add(Dropout(0.2))
model.add(Dense(10, activation="softmax"))
returnmodel

This will output: photo

Contributions

This library is still unstable. Please report all bug to the issues section. It is currently tested with python3.5 and python3.6, but it should run just fine on any python3.

About

A python library for visualizing Artificial Neural Networks (ANN)

Topics

Resources

Stars

1.2k stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages