我画了方块,但我不知道如何添加带有 x15 的框。也欢迎任何使其更美观的其他想法。
\documentclass[border=7pt,10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,positioning,chains,calc}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered,thick, draw=black, fill=gray!30]
\tikzstyle{conv} = [rectangle, minimum width=4cm, minimum height=1cm, text centered,thick, draw=black, fill=yellow!30]
\tikzstyle{relu} = [conv,fill=red!30]
\tikzstyle{bn} = [conv,fill=cyan!30]
\tikzstyle{drop} = [conv,fill=green!30]
\tikzstyle{pool} = [conv,fill=purple!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=1cm]
\node (start) [startstop,fill=gray!20] {Input};
\node (conv1) [conv, below of=start,node distance=2cm] {Convolutoin layer};
\node (bn1) [bn, below of=conv1] {BN};
\node (RELU1) [relu, below of=bn1] {ReLU function};
\node (conv2) [conv, below of=RELU1,node distance=2cm] {Convolutoin layer};
\node (bn2) [bn, below of=conv2] {Batch normalization};
\node (RELU2) [relu, below of=bn2] {ReLU function};
\node (pool1) [pool, right of=RELU2, node distance=5cm] {Max pooling layer};
\node (drop1) [drop, below of=RELU2] {Dropout layer};
\node (conv3) [conv , below of=drop1] {Convolutoin layer};
\node (bn3) [bn, below of=conv3,node distance=3cm] {Batch normalization};
\node (RELU3) [relu , below of=bn3] {ReLU function};
\node (drop2) [drop, below of=RELU3] {Dropout layer};
\node (conv4) [conv, below of=drop2] {Convolutoin layer};
\node (bn4) [bn , below of=conv4] {Batch normalization};
\node (RELU4) [relu, below of=bn4] {ReLU function};
\node (pool2) [pool, right of=bn4, node distance=5cm] {Max pooling layer};
\node (drop3) [drop, below of=RELU4] {Dropout layer};
\node (conv5) [conv , below of=drop3] {Convolutoin layer};
\node (bn5) [bn, below of=conv5,node distance=2cm] {Batch normalization};
\node (RELU5) [relu , below of=bn5] {ReLU function};
\node (dense) [conv, below of=RELU5] {Dense layer};
\node (softmax) [conv, below of=dense,fill=gray!50] {Softmax layer};
%arrows
\draw [arrow] (start) -- (conv1);
\draw [arrow] (RELU1) -- (conv2);
\draw [arrow] ($(RELU1)!0.5!(conv2)$) -| (pool1);
\draw [arrow] (pool1) |- ($(conv3)!0.35!(bn3)$);
\draw [arrow] (conv3) -- (bn3);
\draw [arrow] ($(conv3)!0.65!(bn3)$) -| (pool2);
\draw [arrow] (pool2)|-($(conv5)!0.5!(bn5)$);
\draw [arrow] (conv5) -- (bn5);
\end{tikzpicture}
\end{document}
答案1
我不知道我是否理解得很好我在返回循环的交叉点添加了 tikz 2 坐标的库“fit”,并添加了最后一个节点
\documentclass[border=7pt,10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,positioning,chains,calc,fit}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered,thick, draw=black, fill=gray!30]
\tikzstyle{conv} = [rectangle, minimum width=4cm, minimum height=1cm, text centered,thick, draw=black, fill=yellow!30]
\tikzstyle{relu} = [conv,fill=red!30]
\tikzstyle{bn} = [conv,fill=cyan!30]
\tikzstyle{drop} = [conv,fill=green!30]
\tikzstyle{pool} = [conv,fill=purple!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=1cm]
\node (start) [startstop,fill=gray!20] {Input};
\node (conv1) [conv, below of=start,node distance=2cm] {Convolutoin layer};
\node (bn1) [bn, below of=conv1] {BN};
\node (RELU1) [relu, below of=bn1] {ReLU function};
\node (conv2) [conv, below of=RELU1,node distance=2cm] {Convolutoin layer};
\node (bn2) [bn, below of=conv2] {Batch normalization};
\node (RELU2) [relu, below of=bn2] {ReLU function};
\node (pool1) [pool, right of=RELU2, node distance=5cm] {Max pooling layer};
\node (drop1) [drop, below of=RELU2] {Dropout layer};
\node (conv3) [conv , below of=drop1] {Convolutoin layer};
\node (bn3) [bn, below of=conv3,node distance=3cm] {Batch normalization};
\node (RELU3) [relu , below of=bn3] {ReLU function};
\node (drop2) [drop, below of=RELU3] {Dropout layer};
\node (conv4) [conv, below of=drop2] {Convolutoin layer};
\node (bn4) [bn , below of=conv4] {Batch normalization};
\node (RELU4) [relu, below of=bn4] {ReLU function};
\node (pool2) [pool, right of=bn4, node distance=5cm] {Max pooling layer};
\node (drop3) [drop, below of=RELU4] {Dropout layer};
\node (conv5) [conv , below of=drop3] {Convolutoin layer};
\node (bn5) [bn, below of=conv5,node distance=2cm] {Batch normalization};
\node (RELU5) [relu , below of=bn5] {ReLU function};
\node (dense) [conv, below of=RELU5] {Dense layer};
\node (softmax) [conv, below of=dense,fill=gray!50] {Softmax layer};
%arrows
\draw [arrow] (start) -- (conv1);
\draw [arrow] (RELU1) -- (conv2);
\draw [arrow] ($(RELU1)!0.5!(conv2)$) -| (pool1);
\draw [arrow] (pool1) |- ($(conv3)!0.35!(bn3)$);
\draw [arrow] (conv3) -- (bn3);
\draw [arrow] ($(conv3)!0.65!(bn3)$)coordinate(int1) -| (pool2);
\draw [arrow] (pool2)|-($(conv5)!0.5!(bn5)$) coordinate(int2);
\draw [arrow] (conv5) -- (bn5);
\node[fit = (bn3) (conv5) (pool2) (int1) (int2), draw, dashed, ultra thick, gray, ,rounded corners=10,inner sep=1em, label={[below right]:X15}]{};
\end{tikzpicture}
\end{document}