【画图】基于Python的神经网络可视化工具
【摘要】 项目链接:
https://github.com/Prodicode/ann-visualizer?utm_source=mybridge&utm_medium=blog&utm_campaign=read_more
A python library for visualizing Artificial Neural Networks (ANN)
如何安装
Fro...
项目链接:
https://github.com/Prodicode/ann-visualizer?utm_source=mybridge&utm_medium=blog&utm_campaign=read_more
A python library for visualizing Artificial Neural Networks (ANN)
如何安装
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
人工神经网络绘图示例
-
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="");
卷积神经网络绘图示例
-
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
文章来源: kings.blog.csdn.net,作者:人工智能博士,版权归原作者所有,如需转载,请联系作者。
原文链接:kings.blog.csdn.net/article/details/89891005
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)