GithubHelp home page GithubHelp logo

whitepoplar022 / ann-visualizer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redaops/ann-visualizer

0.0 2.0 0.0 47 KB

A python library for visualizing Artificial Neural Networks (ANN)

License: MIT License

Python 100.00%

ann-visualizer's Introduction

photo photo

ANN Visualizer

PyPI version

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:

pip install ann_visualizer

Usage

from ann_visualizer.visualize import ann_viz;
#Build your model here
ann_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

import keras;
from keras.models import Sequential;
from keras.layers import Dense;

network = Sequential();
        #Hidden Layer#1
network.add(Dense(units=6,
                  activation='relu',
                  kernel_initializer='uniform',
                  input_dim=11));

        #Hidden Layer#2
network.add(Dense(units=6,
                  activation='relu',
                  kernel_initializer='uniform'));

        #Exit Layer
network.add(Dense(units=1,
                  activation='sigmoid',
                  kernel_initializer='uniform'));

from ann_visualizer.visualize import ann_viz;

ann_viz(network, title="");

This will output: photo

Example CNN

import keras;
from keras.models import Sequential;
from keras.layers import Dense;
from ann_visualizer.visualize import ann_viz
model = build_cnn_model()
ann_viz(model, title="")

def build_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"))

  return model

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, but it should run just fine on any python3.

ann-visualizer's People

Contributors

redaops avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.