# However, you need to have a function that is named get_model and returns a Keras Model.
import json
import sys
import os
from keras.models import Sequential
from keras.layers import Conv2D, Dense, Dropout, Flatten, MaxPooling2D, AveragePooling2D

def get_model():
num_classes = 25
model = Sequential()

model.add(Conv2D(filters=6, kernel_size=(3, 3), activation='relu', padding="same", input_shape=(32,32,1)))
model.add(AveragePooling2D())

model.add(Conv2D(filters=16, kernel_size=(3, 3), activation='relu',padding="same"))
model.add(AveragePooling2D())

model.add(Flatten())

model.add(Dense(units=120, activation='relu'))

model.add(Dense(units=84, activation='relu'))

model.add(Dense(units=num_classes, activation = 'softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

return model

效果如下:

2. Visualkeras

Visualkeras:是一個Python包,用于幫助可視化Keras(獨立或包含在TensorFlow中)神經網絡架構。它允許輕松地進行樣式設置以適應大多數需求。目前,它支持分層樣式架構生成,非常適合CNN(卷積神經網絡),以及圖形樣式架構。

地址:https://github.com/paulgavrikov/visualkeras

效果如下:

import visualkerasmodel = ...visualkeras.layered_view(model).show() # display using your system viewervisualkeras.layered_view(model, to_file='output.png') # write to diskvisualkeras.layered_view(model, to_file='output.png').show() # write and showvisualkeras.layered_view(model)

3. draw_convnet

draw_convnet:是一個用于繪制卷積神經網絡結構圖的Python腳本。它可以幫助您可視化卷積神經網絡的結構,包括卷積層、池化層、全連接層等。該腳本是由GitHub用戶gwding開發的,是一個開源項目,可以在GitHub上找到其源代碼和使用說明。

地址:https://github.com/gwding/draw_convnet

效果如下:

4. NN-SVG

NN-SVG:有FCNN、AlexNet、LeNet三種類型。

地址:http://alexlenail.me/NN-SVG/AlexNet.html

FCNN 類型

AlexNet 類型

LeNet 類型:

5. PlotNeuralNet

PlotNeuralNet:用于繪制報告和演示文稿中的神經網絡的LaTeX代碼。查看示例可以了解它們的制作方式。

地址:https://github.com/HarisIqbal88/PlotNeuralNet

效果如下:

6. TensorBoard

TensorBoard:Graphs儀表板是用于檢查TensorFlow模型的強大工具。

地址:https://www.tensorflow.org/tensorboard?hl=zh-cn

效果如下:

7. Caffe

Caffe:可以使用caffe/draw.py來繪制NetParameter protobuffer。

地址:https://github.com/BVLC/caffe

效果如下:

8. Matlab

地址:https://www.mathworks.com/?s_tid=gn_logo

效果如下:

9. Keras.js

地址:https://transcranial.github.io/keras-js/#/

效果如下:

10. keras-sequential-ascii

keras-sequential-ascii:用于研究序列模型的架構和參數的Keras

地址:https://github.com/stared/keras-sequential-ascii/

VGG 16 的網絡結構如下:

11. Netron

Netron:可以可視化神經網絡、深度學習機器學習模型。Netron支持ONNX、TensorFlow Lite、Core ML、Keras、Caffe、Darknet、MXNet、PaddlePaddle、ncnn、MNN和TensorFlow.js。還支持實驗性的PyTorch、TorchScript、TensorFlow、OpenVINO、RKNN、MediaPipe、ML.NET和scikit-learn。

地址:https://github.com/lutzroeder/Netron

效果如下:

12. DotNet

DotNet:這是一個簡單的Python腳本,用于使用Python和Graphviz生成前饋神經網絡的圖片。

地址:https://github.com/martisak/dotnets

效果如下:

13.Graphviz

Graphviz:是一個開源的圖可視化軟件,它可以用抽象的圖形和網絡圖來表示結構化信息。

地址:https://www.graphviz.org/

效果如下:

14. Keras Visualization

Keras Visualization:keras.utils.vis_utils模塊提供了繪制Keras模型(使用graphviz)的實用函數。

地址:https://keras.io/api/utils/model_plotting_utils/

效果如下:

15. Conx

Conx:Python第三方庫 conx 可以使用 net.picture() 函數來實現具有激活函數網絡的可視化,以生成SVG、PNG或PIL。

地址:https://conx.readthedocs.io/en/latest/index.html

效果如下:

16. ENNUI

ENNUI:致力于開發拖拽式神經網絡可視化工具。

地址:https://math.mit.edu/ennui/

以下是一個LeNet-like 架構的可視化示例:

17. NNet

教程:https://beckmw.wordpress.com

R工具包示例及效果:

data(infert, package="datasets")plot(neuralnet(case~parity+induced+spontaneous, infert))

18. GraphCore

GraphCore:主要是展示神經網絡中操作的可視化結果,但也包括了網絡結構的內容,比如每層的網絡參數等。

地址:https://www.graphcore.ai/posts/

下面展示了兩個網絡結構的可視化效果:

AlexNet

ResNet50

19. Neataptic

Neataptic:提供了非常靈活的神經網絡可視化形式;神經元和突觸可以通過一行代碼進行刪除。神經網絡運行不需要固定的結構。允許通過神經進化(neuro-evolution)的方式為數據集調整網絡結構的形狀,并通過多線程來實現

地址:https://wagenaartje.github.io/neataptic/

效果如下:

20. TensorSpace

TensorSpace:是一個由TensorFlow.js、Three.js和Tween.js構建的神經網絡3D可視化框架。它提供Layer API以構建深度學習層、加載預訓練模型,并在瀏覽器中生成3D可視化。通過它的API接口,可以更直觀地可視化并理解任何由TensorFlow、Keras、TensorFlow.js等構建的預訓練模型。

地址:https://tensorspace.org/index_zh.html

效果如下:

21. Netscope CNN Analyzer

Netscope CNN Analyzer:一個基于網絡的工具,用于可視化和分析卷積神經網絡架構(或者從技術角度講,任何有向無環圖)。目前支持Caffe的prototxt格式。

地址:http://dgschwend.github.io/netscope/quickstart.html

效果如下:

22. Monial

Monial:計算圖的交互式表示法,左邊是輸入,右側就是對應結構的可視化結果。

地址:https://github.com/mlajtos/moniel

效果如下:

23. Texample

Texample:可以通過 LaTex 來實現一個神經網絡結構的可視化。

地址:https://texample.net/tikz/examples/neural-network/

LaTex 示例及效果圖如下:

\documentclass{article}

\usepackage{tikz}
\begin{document}
\pagestyle{empty}

\def\layersep{2.5cm}

\begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep]
\tikzstyle{every pin edge}=[<-,shorten <=1pt]
\tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\tikzstyle{input neuron}=[neuron, fill=green!50];
\tikzstyle{output neuron}=[neuron, fill=red!50];
\tikzstyle{hidden neuron}=[neuron, fill=blue!50];
\tikzstyle{annot} = [text width=4em, text centered]

% Draw the input layer nodes
\foreach \name / \y in {1,...,4}
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
\node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {};

% Draw the hidden layer nodes
\foreach \name / \y in {1,...,5}
\path[yshift=0.5cm]
node[hidden neuron] (H-\name) at (\layersep,-\y cm) {};

% Draw the output layer node
\node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {};

% Connect every node in the input layer with every node in the
% hidden layer.
\foreach \source in {1,...,4}
\foreach \dest in {1,...,5}
\path (I-\source) edge (H-\dest);

% Connect every node in the hidden layer with the output layer
\foreach \source in {1,...,5}
\path (H-\source) edge (O);

% Annotate the layers
\node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer};
\node[annot,left of=hl] {Input layer};
\node[annot,right of=hl] {Output layer};
\end{tikzpicture}
% End of code
\end{document}

24. Quiver

Quiver:Keras 的一款交互式卷積神經網絡特征可視化的一個工具。

地址:https://github.com/keplr-io/quiver

效果如下:

25. cnn-explainer

cnn-explainer:通過加載預訓練模型以進行CNN可視化,只需要瀏覽器就可了解CNN的預測過程!

地址:https://poloclub.github.io/cnn-explainer/

效果如下:

26. ML Visuals

ML Visuals :包含神經網絡的圖形和模板,可以重復使用和自定義用于神經網絡結構的展示。

地址:https://github.com/dair-ai/ml-visuals

效果如下:

文章轉自微信公眾號@算法進階

上一篇:

深度學習知識蒸餾的研究綜述

下一篇:

一文概覽神經網絡模型
#你可能也喜歡這些API文章!

我們有何不同?

API服務商零注冊

多API并行試用

數據驅動選型,提升決策效率

查看全部API→
??

熱門場景實測,選對API

#AI文本生成大模型API

對比大模型API的內容創意新穎性、情感共鳴力、商業轉化潛力

25個渠道
一鍵對比試用API 限時免費

#AI深度推理大模型API

對比大模型API的邏輯推理準確性、分析深度、可視化建議合理性

10個渠道
一鍵對比試用API 限時免費