人工神经网络用到的python库_一个用于可视化人工神经网络(ANN)的Python库

f06b4581db20a704d846195a6d128a1b.pnge8007a446e20400a66a255d179b9d1a7.png

ANN Visualizer

68747470733a2f2f62616467652e667572792e696f2f70792f616e6e5f76697375616c697a65722e73766768747470733a2f2f7472617669732d63692e6f72672f50726f6469636f64652f616e6e2d76697375616c697a65722e7376673f6272616e63683d6d617374657268747470733a2f2f6c69626572617061792e636f6d2f6173736574732f776964676574732f646f6e6174652e737667

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

Download the ann_visualizer folder from the github repository.

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

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: 3fc045fd918d54861da7951a387ba63b.png

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: 8c72653b49f599c382c8b46df4974d30.png

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值