← 开源
yu4u

convnet-drawer

Python script for illustrating Convolutional Neural Networks (CNN) using Keras-like model definitions

TutorialsML/AI fundamentalsPython
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
608
Star
94
Fork
+0
本周
3
贡献者
创建于 2018-01-01 · 更新于 2026-10-06 · 今日第 16184 名
主要开发者
yu4uwakame1367xsthunder

yu4u/convnet-drawer 排名第 16,184,有 608 个星标。

同类别比较

yu4u/convnet-drawer 排名第 16,184,此处有 8 个同类条目;wookayin/tensorflow-talk-debugging 排名第 16,183。

同类别比较
名称排名指标
huggingface/hub-docs16,153
语言:
Handlebars
星标数:
609
分叉数:
519
简介:
Docs of the Hugging Face Hub
lijqhs/deeplearning-notes16,158
星标数:
609
分叉数:
173
简介:
Notes for Deep Learning Specialization Courses led by Andrew Ng.
Coder-World04/Complete-Machine-Learning-16,167
星标数:
608
分叉数:
100
简介:
This repository contains everything you need to become proficient in Machine Learning
wookayin/tensorflow-talk-debugging16,183
语言:
Python
星标数:
608
分叉数:
144
简介:
💬 Slides and supplementary codes for my talk 'Debugging Tips on TensorFlow' (2016)
NirantK/NLP_Quickbook16,187
语言:
Jupyter Notebook
星标数:
607
分叉数:
231
简介:
NLP in Python with Deep Learning
chsiang426/ML-2021-notes16,192
星标数:
607
分叉数:
52
简介:
臺灣大學 (NTU) 李宏毅教授「機器學習 (Machine Learning) 2021 Spring 」課程筆記
geektutu/tensorflow-tutorial-samples16,219
语言:
Python
星标数:
605
分叉数:
213
简介:
TensorFlow2教程 TensorFlow 2.0 Tutorial 入门教程实战案例
sgugger/Deep-Learning16,222
语言:
Jupyter Notebook
星标数:
605
分叉数:
110
简介:
A few notebooks about deep learning in pytorch
关键参数与规格
关键参数与规格
参数值
语言Python
类别Tutorials
子类别ML/AI fundamentals
关键词Visualization
星标数608
分叉数94
贡献者3
创建日期2018-01-01
更新日期2026-10-06
1 天星标数0
7 天星标数0
排名16,184
上次排名15,970
排名变化-214
7 天星标排名15,387
上次 7 天星标排名15,394
7 天星标排名变化7
总星标排名16,632
上次总星标排名16,606
总星标排名变化-26
国家Japan
README 摘录

ConvNet Drawer Python script for illustrating Convolutional Neural Networks (CNN). Inspired by the draw_convnet project [1]. Models can be visualized via Keras-like (Sequential) model definitions. The result can be saved as SVG file or pptx file! Requirements python-pptx (if you want to save models as pptx) Keras (if you want to convert Keras sequential model) matplotlib (if you want to save models via matplotlib) Usage Write a script to define and save a model. An example of

visualizing AlexNet [2] is as follows. Model Result: The other examples can be found here. Convert Keras sequential model Keras sequential model can be converted to (thanks to @wakamezake). Only Conv2D, MaxPooling2D, GlobalAveragePooling2D, Flatten, Dense layers are supported for this conversion. *GlobalAveragePooling2D* *Flatten* *Dense* - e. Visualization Parameters Visualization Parameters can be found in config. Please adjust these parameters before model definition (see LeNet. This parameter rescale actual channel size to for visualization as: If the maximum channel size is small

(e. Check how the other parameters works: Default Values TODOs [x] Implement padding option for Conv2D and Pooling layers. [x] Add some effects to Dense layer (and Flatten / GlobalAveragePooling2D). [ ] Automatically calibrate the scale of feature maps for better visibility. [x] Move hard-coded parameters to a config file or options. ~~ The model is now directly saved as a pptx file. Results LeNet AlexNet ZFNet VGG16 AutoEncoder AlexNet saved by matplotlib with plt. Hinton, "ImageNet Classification with Deep Convolutional Neural Networks

," in Proc.

常见问题

记录了多少星标和分叉?

yu4u/convnet-drawer 有 608 个星标和 94 个分叉。

仓库排名是多少?

yu4u/convnet-drawer 排名第 16,184。

记录的语言和类别是什么?

yu4u/convnet-drawer 有 608 个星标,语言为 Python,类别为 Tutorials。

哪个仓库排名最接近?

yu4u/convnet-drawer 与 wookayin/tensorflow-talk-debugging 比较,后者排名第 16,183,有 608 个星标。

README

ConvNet Drawer

Python script for illustrating Convolutional Neural Networks (CNN). Inspired by the draw_convnet project [1].

Models can be visualized via Keras-like (Sequential) model definitions. The result can be saved as SVG file or pptx file!

Requirements

python-pptx (if you want to save models as pptx)

pip install python-pptx

Keras (if you want to convert Keras sequential model)

pip install keras

matplotlib (if you want to save models via matplotlib)

pip install matplotlib

Usage

Write a script to define and save a model. An example of visualizing AlexNet [2] is as follows.

Write and save convnet_drawer.Model

from convnet_drawer import Model, Conv2D, MaxPooling2D, Flatten, Dense
from pptx_util import save_model_to_pptx
from matplotlib_util import save_model_to_file

model = Model(input_shape=(227, 227, 3))
model.add(Conv2D(96, (11, 11), (4, 4)))
model.add(MaxPooling2D((3, 3), strides=(2, 2)))
model.add(Conv2D(256, (5, 5), padding="same"))
model.add(MaxPooling2D((3, 3), strides=(2, 2)))
model.add(Conv2D(384, (3, 3), padding="same"))
model.add(Conv2D(384, (3, 3), padding="same"))
model.add(Conv2D(256, (3, 3), padding="same"))
model.add(MaxPooling2D((3, 3), strides=(2, 2)))
model.add(Flatten())
model.add(Dense(4096))
model.add(Dense(4096))
model.add(Dense(1000))

# save as svg file
model.save_fig("example.svg")

# save as pptx file
save_model_to_pptx(model, "example.pptx")

# save via matplotlib
save_model_to_file(model, "example.pdf")

Result:

The other examples can be found here.

Convert Keras sequential model

Keras sequential model can be converted to convnet_drawer.Model (thanks to @wakamezake). Only Conv2D, MaxPooling2D, GlobalAveragePooling2D, Flatten, Dense layers are supported for this conversion.

from keras_util import convert_drawer_model
from keras_models import AlexNet
from pptx_util import save_model_to_pptx
from matplotlib_util import save_model_to_file

# get Keras sequential model
keras_sequential_model = AlexNet.get_model()
model = convert_drawer_model(keras_sequential_model)

# save as svg file
model.save_fig("example.svg")

# save as pptx file
save_model_to_pptx(model, "example.pptx")

# save via matplotlib
save_model_to_file(model, "example.pdf")

Supported Layers

  • Conv2D
    • Conv2D(filters=None, kernel_size=None, strides=(1, 1), padding="valid")
    • e.g. Conv2D(96, (11, 11), (4, 4)))
  • Deconv2D
    • Deconv2D(filters=None, kernel_size=None, strides=(1, 1), padding="valid")
    • e.g. Deconv2D(256, (3, 3), (2, 2)))
  • MaxPooling2D, AveragePooling2D
    • MaxPooling2D(pool_size=(2, 2), strides=None, padding="valid")
    • e.g. MaxPooling2D((3, 3), strides=(2, 2))
    • If strides = None, stride is set to be pool_size.
  • GlobalAveragePooling2D
    • GlobalAveragePooling2D()
  • Flatten
    • Flatten()
  • Dense
    • Dense(units)
    • e.g. Dense(4096)

Visualization Parameters

Visualization Parameters can be found in config.py. Please adjust these parameters before model definition (see LeNet.py). The most important parameter is channel_scale = 3 / 5. This parameter rescale actual channel size c to c_ for visualization as:

c_ = math.pow(c, channel_scale)

If the maximum channel size is small (e.g. 512), please increase channel_scale.

Check how the other parameters works:

Default Values

theta = - math.pi / 6
ratio = 0.7
bounding_box_margin = 10
inter_layer_margin = 50
text_margin = 10
channel_scale = 3 / 5
text_size = 14
one_dim_width = 4
line_color_feature_map = (0, 0, 0)
line_color_layer = (0, 0, 255)
text_color_feature_map = (0, 0, 0)
text_color_layer = (0, 0, 0)

TODOs

  • [x] Implement padding option for Conv2D and Pooling layers.
  • [x] Add some effects to Dense layer (and Flatten / GlobalAveragePooling2D).
  • [ ] Automatically calibrate the scale of feature maps for better visibility.
  • [x] Move hard-coded parameters to a config file or options.
  • [x] Refactor Layer classes.
  • [x] Draw with matplotlib? for other formats. The model is now directly saved as a pptx file.

Results

LeNet

AlexNet

ZFNet

VGG16

AutoEncoder

AlexNet saved by matplotlib with plt.xkcd()

References

[1] https://github.com/gwding/draw_convnet

[2] A. Krizhevsky, I. Sutskever, and G. E. Hinton, "ImageNet Classification with Deep Convolutional Neural Networks," in Proc. of NIPS, 2012.

排名相邻
同类项目