├── .gitignore ├── LICENSE ├── README.md ├── activation_leakyrelu.tex ├── activation_relu.tex ├── activation_sigmoid.tex ├── activation_tanh.tex ├── block_dense.tex ├── block_inception.tex ├── block_residual.tex ├── block_residual2.tex ├── cell_gru.tex ├── cell_lstm.tex ├── cell_rnn.tex ├── chainrule.tex ├── demo ├── convert_to_png.sh └── demo_network.tex ├── legend.tex ├── legend2.tex ├── model_alexnet.tex ├── model_crnn.tex ├── model_dsodsl.tex ├── model_ssd.tex ├── model_ssd_noacti.tex ├── model_ssd_old.tex ├── model_vgg16.tex ├── multiscale_prediction.tex ├── network_cnn.tex ├── network_cnn_receptivefield.tex ├── network_cnn_stide.tex ├── network_cnn_stide2.tex ├── network_init.tex ├── network_layer_conv.tex ├── network_layer_fc.tex ├── network_mlp.tex ├── network_mlp2.tex ├── network_unfolding.tex ├── pooling_2.tex ├── pooling_average.tex ├── pooling_both.tex ├── pooling_max.tex ├── precision.tex ├── recall.tex ├── sets.tex └── test └── test_network.tex /.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.log 3 | *.pdf 4 | *.synctex.gz 5 | *.png 6 | *.jpg 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Markus Völk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Artificial Neural Network related TikZ Graphics 2 | 3 | If you like TikZ and need some 'inspiration' for your Artificial Neural Network related graphics, then this could be what you are looking for. 4 | I initially wanted editable versions of the images I found on [olah's blog](http://colah.github.io/posts/2015-08-Understanding-LSTMs) that I could use later for my [master's thesis](http://46.163.79.21/thesis/thesis.pdf), so I started playing around with TikZ. The results are now contained in this repository. 5 | 6 | ## [Some Examples](http://46.163.79.21/nn_graphics) ([PDF](http://46.163.79.21/nn_graphics/demo_network.pdf)) 7 | ![image_07.png](http://46.163.79.21/nn_graphics/image_07.png) 8 | ![image_12.png](http://46.163.79.21/nn_graphics/image_12.png) 9 | ![image_14.png](http://46.163.79.21/nn_graphics/image_14.png) 10 | ![image_16.png](http://46.163.79.21/nn_graphics/image_16.png) 11 | ![image_24.png](http://46.163.79.21/nn_graphics/image_24.png) 12 | ![image_28.png](http://46.163.79.21/nn_graphics/image_28.png) 13 | ![image_32.png](http://46.163.79.21/nn_graphics/image_32.png) 14 | ![image_34.png](http://46.163.79.21/nn_graphics/image_34.png) 15 | 16 | 17 | -------------------------------------------------------------------------------- /activation_leakyrelu.tex: -------------------------------------------------------------------------------- 1 | % Leaky ReLU 2 | \begin{tikzpicture}[] 3 | \begin{axis}[ 4 | %title=$\tanh(x)$, 5 | axis x line=middle, xmin=-4, xmax=4, xtick={-3,...,3}, xlabel=$x$, 6 | axis y line=middle, ymin=-2, ymax=2, ytick={-1,...,1}, ylabel=$f(x)$, 7 | legend pos=north west, 8 | legend style={empty legend, draw=none}, 9 | scale only axis=true, 10 | width=8cm, height=4cm, 11 | thick, 12 | samples=101] 13 | \addplot[blue, very thick] {(\x < 0) * (0.3 * \x) + (\x > 0) * (\x)}; 14 | %\addlegendentry{$\tanh(x)$} 15 | \end{axis} 16 | \end{tikzpicture} 17 | -------------------------------------------------------------------------------- /activation_relu.tex: -------------------------------------------------------------------------------- 1 | % ReLU 2 | \begin{tikzpicture}[] 3 | \begin{axis}[ 4 | %title=$\tanh(x)$, 5 | axis x line=middle, xmin=-4, xmax=4, xtick={-3,...,3}, xlabel=$x$, 6 | axis y line=middle, ymin=-2, ymax=2, ytick={-1,...,1}, ylabel=$f(x)$, 7 | legend pos=north west, 8 | legend style={empty legend, draw=none}, 9 | scale only axis=true, 10 | width=8cm, height=4cm, 11 | thick, 12 | samples=101] 13 | \addplot[blue, very thick] {(\x < 0) * (0) + (\x > 0) * (\x)}; 14 | %\addlegendentry{$\tanh(x)$} 15 | \end{axis} 16 | \end{tikzpicture} 17 | -------------------------------------------------------------------------------- /activation_sigmoid.tex: -------------------------------------------------------------------------------- 1 | % sigmoid 2 | \begin{tikzpicture}[] 3 | \begin{axis}[ 4 | %title=$\tanh(x)$, 5 | axis x line=middle, xmin=-4, xmax=4, xtick={-3,...,3}, xlabel=$x$, 6 | axis y line=middle, ymin=-2, ymax=2, ytick={-1,...,1}, ylabel=$f(x)$, 7 | legend pos=north west, 8 | legend style={empty legend, draw=none}, 9 | scale only axis=true, 10 | width=8cm, height=4cm, 11 | thick, 12 | samples=101] 13 | \addplot[blue, very thick] {1/(1+exp(-x))}; 14 | %\addlegendentry{$\tanh(x)$} 15 | \end{axis} 16 | \end{tikzpicture} 17 | -------------------------------------------------------------------------------- /activation_tanh.tex: -------------------------------------------------------------------------------- 1 | % tanh 2 | \begin{tikzpicture}[] 3 | \begin{axis}[ 4 | %title=$\tanh(x)$, 5 | axis x line=middle, xmin=-4, xmax=4, xtick={-3,...,3}, xlabel=$x$, 6 | axis y line=middle, ymin=-2, ymax=2, ytick={-1,...,1}, ylabel=$f(x)$, 7 | legend pos=north west, 8 | legend style={empty legend, draw=none}, 9 | scale only axis=true, 10 | width=8cm, height=4cm, 11 | thick, 12 | samples=101] 13 | \addplot[blue, very thick] {tanh(x))}; 14 | %\addlegendentry{$\tanh(x)$} 15 | \end{axis} 16 | \end{tikzpicture} 17 | -------------------------------------------------------------------------------- /block_dense.tex: -------------------------------------------------------------------------------- 1 | % Dense Block 2 | 3 | \begin{tikzpicture}[thick, node distance=\vlayerheight, on grid] 4 | 5 | \coordinate (labelcoord) at (\vlayerwidth/2-2pt, 6pt); 6 | 7 | \coordinate (n0) at (0,0); 8 | \coordinate (n1) at ($(n0) +(0pt, -4pt)$); 9 | \node[anchor=north west] at ($(n1) +(-2pt, 6pt)$) {\tiny wxhxc}; 10 | 11 | \foreach \y in {1,...,8} { 12 | \begin{scope} [start chain=going below, every node/.style={on chain}] 13 | \node[bn, vlayer] (n3) at ($(n1) +(0.8*\vlayerwidth, -20pt)$) {}; 14 | \node[activation, vlayer] {}; 15 | \node[conv, vlayer] (n4) {}; 16 | \node[bn, vlayer] {}; 17 | \node[activation, vlayer] {}; 18 | \node[conv, vlayer] (n2) {}; 19 | \end{scope} 20 | 21 | \node[anchor=north west] at ($(n4) +(labelcoord)$) {\tiny 1,1,4k}; 22 | \node[anchor=north west] at ($(n2) +(labelcoord)$) {\tiny 3,1,k}; 23 | \draw[signal] (n1) |- +(8pt, -8pt) -| (n3); 24 | \coordinate (n1) at ($(n2) +(-0.8*\vlayerwidth, -16pt)$); 25 | \draw[signal, -] (n2) |- +(-8pt, -8pt) -| (n1); 26 | \node[anchor=north west] at ($(n1) +(-2pt, 6pt)$) {\tiny wxhx(c+\y k)}; 27 | } 28 | 29 | \draw[signal] (n0) -- ($(n1) +(0pt, -12pt)$); 30 | 31 | \end{tikzpicture} 32 | -------------------------------------------------------------------------------- /block_inception.tex: -------------------------------------------------------------------------------- 1 | % Inception Block 2 | 3 | \begin{tikzpicture}[start chain=main going below, node distance=12pt, 4 | point/.append style={on chain, join=by {signal}}, 5 | layer/.append style={on chain, join=by {signal}}, 6 | branch/.append style={on chain, join=by {signal, -}}, 7 | ] 8 | \def\branchy{70pt} 9 | 10 | \node[point] {Input}; 11 | \node[branch] {}; 12 | {[start branch=b1 going below] 13 | \node[conv, xshift=-\layerwidth*1.5-24pt, yshift=-\branchy-26pt] {Conv 1x1}; 14 | \node[activation] {ReLU}; 15 | } 16 | {[start branch=b2 going below] 17 | \node[conv, xshift=-\layerwidth*0.5-8pt, yshift=-\branchy] {Conv 1x1}; 18 | \node[activation] {ReLU}; 19 | \node[conv] {Conv 3x3}; 20 | \node[activation] {ReLU}; 21 | } 22 | {[start branch=b3 going below] 23 | \node[conv, xshift=\layerwidth*0.5+8pt, yshift=-\branchy] {Conv 1x1}; 24 | \node[activation] {ReLU}; 25 | \node[conv] (foo) {Conv 5x5}; 26 | \node[activation] {ReLU}; 27 | } 28 | \node[pool, xshift=\layerwidth*1.5+24pt, yshift=-\branchy-13pt] {MaxPool 3x3}; 29 | \node[conv] {Conv 1x1}; 30 | \node[activation] {ReLU}; 31 | \node[layer, xshift=-\layerwidth*1.5-24pt, yshift=-\branchy, 32 | join=with main/b1-end by signal, 33 | join=with main/b2-end by signal, 34 | join=with main/b3-end by signal] {Concatenation}; 35 | \node[point] {Output}; 36 | \end{tikzpicture} 37 | -------------------------------------------------------------------------------- /block_residual.tex: -------------------------------------------------------------------------------- 1 | % Residual Block 2 | 3 | \begin{tikzpicture}[start chain=going below, node distance=12pt, 4 | point/.append style={on chain, join=by {signal}}, 5 | layer/.append style={on chain, join=by {signal}}, 6 | branch/.append style={on chain, join=by {signal, -}}, 7 | ] 8 | \def\branchy{30pt} 9 | 10 | \node[point] {Input}; 11 | \node[branch] (input) {}; 12 | \node[conv, xshift=\layerwidth/2+16pt, yshift=-\branchy] {Conv}; 13 | \node[bn] {BatchNorm}; 14 | \node[activation] {ReLU}; 15 | \node[conv] {Conv}; 16 | \node[bn] {BatchNorm}; 17 | \node[layer, xshift=-\layerwidth/2-16pt, yshift=-\branchy] (add) {Addition}; 18 | \node[activation] {ReLU}; 19 | \node[point] {Output}; 20 | \draw[signal] (input) -- (add); 21 | \end{tikzpicture} 22 | -------------------------------------------------------------------------------- /block_residual2.tex: -------------------------------------------------------------------------------- 1 | % Residual Block 2 2 | 3 | \begin{tikzpicture}[start chain=going below, node distance=12pt, 4 | point/.append style={on chain, join=by {signal}}, 5 | layer/.append style={on chain, join=by {signal}}, 6 | branch/.append style={on chain, join=by {signal, -}}, 7 | ] 8 | \def\branchy{30pt} 9 | 10 | \node[point] {Input}; 11 | \node[branch] (input) {}; 12 | \node[bn, xshift=\layerwidth/2+16pt, yshift=-\branchy] {BatchNorm}; 13 | \node[activation] {ReLU}; 14 | \node[conv] {Conv}; 15 | \node[bn] {BatchNorm}; 16 | \node[activation] {ReLU}; 17 | \node[conv] {Conv}; 18 | \node[layer, xshift=-\layerwidth/2-16pt, yshift=-\branchy] (add) {Addition}; 19 | \node[point] {Output}; 20 | \draw[signal] (input) -- (add); 21 | \end{tikzpicture} 22 | -------------------------------------------------------------------------------- /cell_gru.tex: -------------------------------------------------------------------------------- 1 | % GRU 2 | \begin{tikzpicture}[thick, node distance=30pt and 30pt, on grid] 3 | \node[cell, minimum width=200pt, minimum height=110pt, anchor=north west] (b) at (-2pt,0pt) {}; 4 | 5 | \coordinate (hin) at (0pt,-20pt); 6 | \draw[signal] (hin) +(-\iolen, 0pt) node[above] {$h_{t-1}$} -- (hin); 7 | \coordinate (hout) at (200pt,-20pt); 8 | \draw[signal] (hout) -- +(\iolen,0pt) node[above left] {$h_{t}$}; 9 | \coordinate (h) at (184pt,0pt); 10 | \draw[signal] (h) -- +(0,\iolen) node[left] {$h_{t}$}; 11 | \coordinate (x) at (14pt,-110pt); 12 | \draw[signal, -] (x) +(0pt,-\iolen) node[left] {$x_{t}$} -- (x); 13 | 14 | \node[celllayer] (r) at (68pt,-80pt) {$\sigm$}; 15 | \node[celllayer, right=58pt of r] (z) {$\sigm$}; 16 | \node[celllayer, right=34pt of z] (ht) {$\tanh$}; 17 | 18 | \node[pointwise, above=30pt of ht] (htm) {$\times$}; 19 | \draw[signal] (ht) edge node[pos=0.5,left] {$\tilde{h}_t$} (htm); 20 | \node[pointwise, above=30pt of htm] (htmp) {$+$}; 21 | \draw[signal] (htm) -- (htmp); 22 | \draw[signal, -] (htmp) -- (hout); 23 | 24 | \node[pointwise, above left=30pt and 30pt of z] (z1) {$-1$}; 25 | \draw[signal] (z) |- (z1) node[pos=0.2,left] {$z_t$}; 26 | \node[pointwise, above=30pt of z1] (z1m) {$\times$}; 27 | \draw[signal] (z1) -- (z1m); 28 | \draw[signal, -] (z1m) -- (htmp); 29 | \draw[signal] (z) |- (htm); 30 | \draw[signal, -] (hout -| h) +(-10pt,0pt) -| (h); 31 | 32 | \draw[signal, -] (hin) +(-10pt,0pt) -- (z1m); 33 | 34 | \node[pointwise, above left=30pt and 30pt of r] (rm) {$\times$}; 35 | \draw[signal] (r) |- (rm) node[pos=0.2,left] {$r_t$}; 36 | \draw[signal] (hin -| rm) +(-10pt,0pt) -| (rm); 37 | 38 | \coordinate (hx) at (60pt,-94pt); 39 | \draw[signal, -] (x) |- (hx); 40 | \draw[signal, -] (hin) +(-10pt,0pt) -| (x |- r) |- (hx) +(10pt,0pt); 41 | \draw[signal, -] (hx) -| (r); 42 | \draw[signal, -] (hx) -| (z); 43 | 44 | \coordinate (rx) at (60pt,-102pt); 45 | \draw[signal, -] (x) |- (rx); 46 | \draw[signal, -] (rx) -| (ht); 47 | 48 | \draw[signal, -, shorten >=\intergape] (rm) |- (rm |- hx); 49 | \draw[signal, -, shorten <=\intergape] (rm |- hx) |- (z |- rx); 50 | \end{tikzpicture} 51 | -------------------------------------------------------------------------------- /cell_lstm.tex: -------------------------------------------------------------------------------- 1 | % LSTM 2 | \begin{tikzpicture}[thick, node distance=30pt and 30pt, on grid] 3 | \node[cell, minimum width=200pt, minimum height=110pt, anchor=north west] (b) at (-2pt,0pt) {}; 4 | 5 | \coordinate (cin) at (0pt,-20pt); 6 | \draw[signal] (cin) +(-\iolen, 0pt) node[above] {$c_{t-1}$} -- (cin); 7 | \coordinate (cout) at (200pt,-20pt); 8 | \draw[signal] (cout) -- +(\iolen,0pt) node[above left] {$c_{t}$}; 9 | \coordinate (hin) at (0pt,-100pt); 10 | \draw[signal] (hin) +(-\iolen, 0pt) node[above] {$h_{t-1}$} -- (hin); 11 | \coordinate (hout) at (200pt,-100pt); 12 | \draw[signal] (hout) -- +(\iolen,0pt) node[above left] {$h_{t}$}; 13 | \coordinate (h) at (184pt,0pt); 14 | \draw[signal] (h) -- +(0,\iolen) node[left] {$h_{t}$}; 15 | \coordinate (x) at (14pt,-110pt); 16 | \draw[signal, -] (x) +(0pt,-\iolen) node[left] {$x_{t}$} -- (x); 17 | 18 | \node[celllayer] (f) at (32pt,-80pt) {$\sigm$}; 19 | \node[celllayer, right=34pt of f] (i) {$\sigm$}; 20 | \node[celllayer, right=34pt of i] (c) {$\tanh$}; 21 | \node[celllayer, right=34pt of c] (o) {$\sigm$}; 22 | 23 | \node[pointwise, above=60pt of f] (fm) {$\times$}; 24 | 25 | \node[pointwise, above=30pt of c] (cm) {$\times$}; 26 | \node[pointwise, above=30pt of cm] (cmp) {$+$}; 27 | 28 | \node[pointwise, above right=20pt and 20 pt of o] (om) {$\times$}; 29 | \node[pointwise, above=20pt of om] (omt) {$\tanh$}; 30 | 31 | \draw[signal] (f) edge node[near start,left] {$f_t$} (fm); 32 | 33 | \draw[signal, -] (c) edge node[pos=0.5,left] {$\tilde{c}_t$} (cm); 34 | \draw[signal] (cm) to (cmp); 35 | \draw[signal] (i) |- (cm) node[near start,left] {$i_t$}; 36 | 37 | \draw[signal] (o) |- (om) node[pos=0.3,left] {$o_t$}; 38 | 39 | \draw[signal, -] (fm) -- (cmp); 40 | 41 | \draw[signal, -] (cmp) -| (omt); 42 | \draw[signal, -] (omt) -- (om); 43 | 44 | \draw[signal] (cin) +(-\iolen, 0) node[above] {$c_{t-1}$} -- +(0,0); 45 | 46 | \draw[signal, -] (cin) +(-10pt,0) -- (fm); 47 | 48 | \draw[signal] (hin) +(-\iolen, 0) node[above] {$h_{t-1}$} -- +(0,0); 49 | 50 | \draw[signal, -] (hin) +(-10pt,0) -| (o); 51 | \draw[signal, -] (hin) -| (c); 52 | \draw[signal, -] (hin) -| (i); 53 | \draw[signal, -] (hin) -| (f); 54 | 55 | \draw[signal] (cout) -- +(\iolen,0) node[above left] {$c_{t}$}; 56 | 57 | \draw[signal, -] (cmp) -- (cout); 58 | 59 | \draw[signal] (hout) -- +(\iolen,0) node[above left] {$h_{t}$}; 60 | 61 | \draw[signal, -] (om) |- (hout); 62 | 63 | \draw[signal, -, shorten >=\intergape] (h |- hout) +(-10pt,0) -| (h |- cout); 64 | \draw[signal, shorten <=\intergape] (h |- cout) -- +(0,\iolen+20pt) node[left] {$h_{t}$}; 65 | 66 | \draw[signal, -] (x) |- (f |- hin); 67 | \end{tikzpicture} 68 | -------------------------------------------------------------------------------- /cell_rnn.tex: -------------------------------------------------------------------------------- 1 | % RNN 2 | \begin{tikzpicture}[thick, node distance=30pt and 30pt, on grid] 3 | \node[cell, minimum width=200pt, minimum height=110pt, anchor=north west] (b) at (-2pt,0pt) {}; 4 | 5 | \coordinate (hin) at (0pt,-20pt); 6 | \draw[signal] (hin) +(-\iolen, 0pt) node[above] {$h_{t-1}$} -- (hin); 7 | \coordinate (hout) at (200pt,-20pt); 8 | \draw[signal] (hout) -- +(\iolen,0pt) node[above left] {$h_{t}$}; 9 | \coordinate (h) at (184pt,0pt); 10 | \draw[signal] (h) -- +(0,\iolen) node[left] {$h_{t}$}; 11 | \coordinate (x) at (14pt,-110pt); 12 | \draw[signal, -] (x) +(0pt,-\iolen) node[left] {$x_{t}$} -- (x); 13 | 14 | \node[celllayer] at (b) (a) {$\tanh$}; 15 | 16 | \draw[signal, -] (a) |- (hout); 17 | \draw[signal, -] (hout -| h) +(-10pt,0pt) -| (h); 18 | \coordinate (hx) at (60pt,-100pt); 19 | \draw[signal, -] (x) |- (hx); 20 | \draw[signal, -] (hx) -| (a); 21 | \draw[signal, -] (hin) +(-10pt,0pt) -| +(50pt,-50pt) |- (hx) +(10pt,0pt); 22 | \end{tikzpicture} 23 | -------------------------------------------------------------------------------- /chainrule.tex: -------------------------------------------------------------------------------- 1 | % Chain rule, Forward-, Backwardpass 2 | \begin{tikzpicture}[] 3 | \def\pindist{35pt} 4 | \def\nodesize{38pt} 5 | 6 | \tikzstyle{every pin edge}=[signal] 7 | \tikzstyle{annot} = [text width=4em, text centered] 8 | 9 | \node[hiddennode, text width=\nodesize, minimum size=\nodesize, 10 | pin={[pin edge={latex-}, pin distance=\pindist]above left:$x_1$}, 11 | pin={[pin edge={latex-}, pin distance=\pindist]below left:$x_2$}, 12 | pin={[pin edge={-latex}, pin distance=\pindist]right:$y_1$} 13 | ] (N1) at (-100pt,0) {$f(x)$}; 14 | 15 | \node[hiddennode, text width=\nodesize, minimum size=\nodesize, 16 | pin={[pin edge={-latex}, pin distance=\pindist]above left:$\frac{\partial L}{\partial x_1}=\frac{\partial L}{\partial y_1}\frac{\partial y_1}{\partial x_1}$}, 17 | pin={[pin edge={-latex}, pin distance=\pindist]below left:$\frac{\partial L}{\partial x_2}=\frac{\partial L}{\partial y_1}\frac{\partial y_1}{\partial x_2}$}, 18 | pin={[pin edge={latex-}, pin distance=\pindist]right:$\frac{\partial L}{\partial y_1}$} 19 | ] (N2) at (+120pt,0) {$\diff f$}; 20 | 21 | \node[annot, text width=200pt, align=center, above=40pt of N1] (l1) {Forwardpass}; 22 | \node[annot, text width=200pt, align=center, above=40pt of N2] (l2) {Backwardpass}; 23 | 24 | \draw[signal, -] (0,-70pt) -- (0,+80pt); 25 | \end{tikzpicture} 26 | -------------------------------------------------------------------------------- /demo/convert_to_png.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # convert produces unwanted artefacts 4 | #convert -density 200 -background white demo_network.pdf _%02d.png 5 | #ls -1 _*.png | xargs -i convert -flatten {} image{} 6 | #rm _*.png 7 | 8 | pdftoppm -png -r 200 demo_network.pdf image 9 | perl-rename 's/\-/_/' image*.png 10 | -------------------------------------------------------------------------------- /demo/demo_network.tex: -------------------------------------------------------------------------------- 1 | \documentclass[tikz]{standalone} 2 | %\documentclass[tikz]{article} 3 | 4 | \usepackage{pgfplots} 5 | \usepackage{ifthen} 6 | 7 | \usepackage{amsmath} 8 | \DeclareMathOperator{\sigm}{sigm} 9 | \newcommand{\diff}{\mathop{}\!\mathrm{d}} 10 | 11 | \begin{document} 12 | 13 | \input{../network_init.tex} 14 | 15 | \input{../chainrule.tex} 16 | 17 | \input{../activation_tanh.tex} 18 | \input{../activation_sigmoid.tex} 19 | \input{../activation_relu.tex} 20 | \input{../activation_leakyrelu.tex} 21 | 22 | \input{../network_mlp.tex} 23 | \input{../network_mlp2.tex} 24 | 25 | \input{../network_layer_fc.tex} 26 | \input{../network_layer_conv.tex} 27 | 28 | \input{../network_cnn.tex} 29 | \input{../network_cnn_stide.tex} 30 | \input{../network_cnn_stide2.tex} 31 | \input{../network_cnn_receptivefield.tex} 32 | 33 | \input{../network_unfolding.tex} 34 | 35 | \input{../cell_rnn.tex} 36 | \input{../cell_lstm.tex} 37 | \input{../cell_gru.tex} 38 | 39 | \input{../legend.tex} 40 | \input{../legend2.tex} 41 | 42 | \input{../pooling_max.tex} 43 | \input{../pooling_average.tex} 44 | \input{../pooling_2.tex} 45 | 46 | \input{../pooling_both.tex} 47 | 48 | \input{../block_residual.tex} 49 | \input{../block_residual2.tex} 50 | \input{../block_inception.tex} 51 | \input{../block_dense.tex} 52 | 53 | \input{../model_alexnet.tex} 54 | \input{../model_vgg16.tex} 55 | \input{../model_ssd.tex} 56 | \input{../model_crnn.tex} 57 | \input{../model_dsodsl.tex} 58 | 59 | \input{../multiscale_prediction.tex} 60 | 61 | \input{../sets.tex} 62 | \input{../precision.tex} 63 | \input{../recall.tex} 64 | 65 | \end{document} 66 | -------------------------------------------------------------------------------- /legend.tex: -------------------------------------------------------------------------------- 1 | % RNN legend 2 | \begin{tikzpicture} 3 | \def\labeldist{30pt} 4 | \def\nodedist{60pt} 5 | 6 | \node[celllayer, minimum width=40pt] (l) at (0pt,0pt) {}; 7 | \node[align=center] at ($(l) +(0pt,-\labeldist)$) {Network\\Layer}; % trainable 8 | \node[pointwise] (p) at ($(l) +(\nodedist, 0pt)$) {}; 9 | \node[align=center] at ($(p) +(0pt,-\labeldist)$) {Pointwise\\Operation}; 10 | \coordinate (v) at ($(p) +(\nodedist, 0pt)$); 11 | \draw[signal] (v) +(-20pt,0pt) -- +(20pt, 0pt); 12 | \node[align=center] at ($(v) +(0pt,-\labeldist)$) {Vector\\Transfer}; 13 | \coordinate (m) at ($(v) +(\nodedist, 0pt)$); 14 | \draw[signal] (m) +(-10pt,10pt) |- +(10pt, 0pt); 15 | \draw[signal] (m) +(-10pt,-10pt) |- +(10pt, 0pt); 16 | \node[align=center] at ($(m) +(0pt,-\labeldist)$) {Concatenate}; 17 | \coordinate (c) at ($(m) +(\nodedist, 0pt)$); 18 | \draw[signal] (c) +(-10pt,0pt) -| +(10pt, 12pt); 19 | \draw[signal] (c) +(-10pt,0pt) -| +(10pt, -12pt); 20 | \node[align=center] at ($(c) +(0pt,-\labeldist)$) {Copy}; 21 | \end{tikzpicture} 22 | -------------------------------------------------------------------------------- /legend2.tex: -------------------------------------------------------------------------------- 1 | % RNN legend, horizontal 2 | \begin{tikzpicture} 3 | \def\nodedist{170pt} 4 | 5 | \node[celllayer, minimum width=40pt] (l) at (0pt,0pt) {}; 6 | \node[anchor=west] at ($(l) +(30pt, 0pt)$) {Network Layer}; % trainable 7 | \node[pointwise] (p) at ($(l) +(\nodedist, 0pt)$) {}; 8 | \node[anchor=west] at ($(p) +(16pt, 0pt)$) {Pointwise Operation}; 9 | \coordinate (v) at ($(p) +(\nodedist, 0pt)$); 10 | \draw[signal] (v) +(-20pt,0pt) -- +(20pt, 0pt); 11 | \node[anchor=west] at ($(v) +(30pt, 0pt)$) {Vector Transfer}; 12 | \coordinate (m) at ($(v) +(\nodedist, 0pt)$); 13 | \draw[signal] (m) +(-10pt,10pt) |- +(10pt, 0pt); 14 | \draw[signal] (m) +(-10pt,-10pt) |- +(10pt, 0pt); 15 | \node[anchor=west] at ($(m) +(20pt, 0pt)$) {Concatenate}; 16 | \coordinate (c) at ($(m) +(\nodedist, 0pt)$); 17 | \draw[signal] (c) +(-10pt,0pt) -| +(10pt, 12pt); 18 | \draw[signal] (c) +(-10pt,0pt) -| +(10pt, -12pt); 19 | \node[anchor=west] at ($(c) +(20pt, 0pt)$) {Copy}; 20 | \end{tikzpicture} 21 | -------------------------------------------------------------------------------- /model_alexnet.tex: -------------------------------------------------------------------------------- 1 | % AlexNet 2 | \begin{tikzpicture}[start chain=going below, node distance=12pt, 3 | point/.append style={on chain, join=by {signal}}, 4 | layer/.append style={on chain, join=by {signal}}, 5 | ] 6 | \node[point] {Input Image}; 7 | \node[conv] {Conv 11x11/4, 96}; 8 | \node[activation] {ReLU}; 9 | \node[pool] {MaxPool 2x2/2}; 10 | % local contrast norm 11 | \node[conv] {Conv 5x5, 256}; 12 | \node[activation] {ReLU}; 13 | % local contrast norm 14 | \node[pool] {MaxPool 2x2/2}; 15 | \node[conv] {Conv 3x3, 384}; 16 | \node[activation] {ReLU}; 17 | \node[conv] {Conv 3x3, 384}; 18 | \node[activation] {ReLU}; 19 | \node[conv] {Conv 3x3, 256}; 20 | \node[activation] {ReLU}; 21 | \node[pool] {MaxPool 2x2/2}; 22 | \node[layer] {Flatten}; 23 | \node[fc] {FC 4096}; 24 | \node[activation] {ReLU}; 25 | \node[layer] {Dropout}; 26 | \node[fc] {FC 4096}; 27 | \node[activation] {ReLU}; 28 | \node[layer] {Dropout}; 29 | \node[fc] {FC 1000}; 30 | \node[softmax] {Softmax}; 31 | \node[point] {Classification Output}; 32 | \end{tikzpicture} 33 | -------------------------------------------------------------------------------- /model_crnn.tex: -------------------------------------------------------------------------------- 1 | % CRNN 2 | 3 | \begin{tikzpicture} 4 | \begin{scope} [start chain=going below, node distance=12pt, 5 | every node/.style={on chain}, 6 | layer/.append style={join=by {signal}}, 7 | point/.append style={join=by {signal}}, 8 | ] 9 | \node[point] (input) {Input}; 10 | \node[conv] {Conv 3x3, 64}; 11 | \node[pool] {MaxPool 2x2/2}; 12 | \node[conv] {Conv 3x3, 128}; 13 | \node[pool] {MaxPool 2x2/2}; 14 | \node[conv] {Conv 3x3, 256}; 15 | \node[conv] {Conv 3x3, 256}; 16 | \node[pool] {MaxPool 1x2/2}; 17 | \node[conv] {Conv 3x3, 512}; 18 | \node[bn] {BatchNorm}; 19 | \node[conv] {Conv 3x3, 512}; 20 | \node[bn] {BatchNorm}; 21 | \node[pool] {MaxPool 1x2/2}; 22 | \node[conv] {Conv 2x2, 512}; 23 | \node[layer] {Map-to-Sequence}; 24 | \node[recurrent] {Bidirectional-LSTM}; 25 | \node[recurrent] {Bidirectional-LSTM}; 26 | %\node[layer] {Transcription}; 27 | \node[point] {Output}; 28 | \end{scope} 29 | \end{tikzpicture} -------------------------------------------------------------------------------- /model_dsodsl.tex: -------------------------------------------------------------------------------- 1 | % SegLink with Dense Blocks 2 | 3 | \begin{tikzpicture}[thick, node distance=\vlayerheight, on grid] 4 | 5 | \tikzstyle{vblocklink}=[node distance=(\vblockheight+\vlayerheight)/2+10pt, on chain, join=by {signal}] 6 | 7 | \pgfmathsetlengthmacro\d{\vlayerheight/2+6pt} 8 | 9 | \coordinate (labelcoord) at (\vlayerwidth/2-2pt, 6pt); 10 | %\coordinate (shapecoord) at (2*\vlayerwidth-20pt, +2pt); 11 | \coordinate (shapecoord) at (2*\vlayerwidth-22pt, -\d+10pt); 12 | 13 | \begin{scope} [start chain=going below, every node/.style={on chain}] 14 | \node[point] (a1) {Input Image}; 15 | \node[conv, vlayer, node distance=26pt, on chain, join=by {signal}] (c1) {}; 16 | \node[bn, vlayer] {}; 17 | \node[activation, vlayer] {}; 18 | \node[conv, vlayer] (c2) {}; 19 | \node[bn, vlayer] {}; 20 | \node[activation, vlayer] {}; 21 | \node[conv, vlayer] (c3) {}; 22 | \node[bn, vlayer] {}; 23 | \node[activation, vlayer] {}; 24 | \node[pool, vlayer] (p1) {}; 25 | \node[layer, vblock, vblocklink] (d1) {Dense\\6 48}; 26 | \node[bn, vlayer, vblocklink] {}; 27 | \node[activation, vlayer] {}; 28 | \node[conv, vlayer] (c4) {}; 29 | \node[pool, vlayer] (p2) {}; 30 | \node[layer, vblock, vblocklink] (d2) {Dense\\8 48}; 31 | \node[bn, vlayer, vblocklink] {}; 32 | \node[activation, vlayer] {}; 33 | \node[conv, vlayer] (S1) {}; 34 | \end{scope} 35 | 36 | \node[anchor=north west] at ($(a1) +(shapecoord)$) {\tiny 512x512x3}; 37 | \node[anchor=north west] at ($(c1) +(labelcoord)$) {\tiny 3,2,64}; 38 | \node[anchor=north west] at ($(c2) +(labelcoord)$) {\tiny 3,1,64}; 39 | \node[anchor=north west] at ($(c3) +(labelcoord)$) {\tiny 3,1,128}; 40 | \node[anchor=north west] at ($(c4) +(labelcoord)$) {\tiny 1,1,416}; 41 | \node[anchor=north west] at ($(S1) +(labelcoord)$) {\tiny 1,1,800}; 42 | \node[anchor=north west] at ($(p1) +(labelcoord)$) {\tiny 2,2}; 43 | \node[anchor=north west] at ($(p2) +(labelcoord) +(0pt, -2pt)$) {\tiny 2,2}; 44 | 45 | \begin{scope} [start chain=going below, every node/.style={on chain}] 46 | \node[pool, vlayer] (n2) at ($(S1) +(0pt, -\vlayerheight-18pt)$) {}; 47 | \node[layer, vblock, 48 | node distance=(\vblockheight+\vlayerheight)/2+18pt, on chain, join=by {signal} 49 | ] {Dense\\8 48}; 50 | \node[conv, vlayer, vblocklink] (c6) {}; 51 | \node[bn, vlayer] {}; 52 | \node[activation, vlayer] {}; 53 | \node[layer, vblock, vblocklink] {Dense\\8 48}; 54 | \node[conv, vlayer, vblocklink] (n6) {}; 55 | \node[bn, vlayer] {}; 56 | \node[activation, vlayer] (n3) {}; 57 | \end{scope} 58 | 59 | \begin{scope} [start chain=going below, every node/.style={on chain}] 60 | \node[conv, vlayer] (n4) at ($(n6) +(-2*\vlayerwidth, 0pt)$) {}; 61 | \node[bn, vlayer] {}; 62 | \node[activation, vlayer] (n5) {}; 63 | \end{scope} 64 | 65 | \node[anchor=north west] at ($(c6) +(labelcoord)$) {\tiny 1,1,1148}; 66 | \node[anchor=north west] at ($(n6) +(labelcoord)$) {\tiny 1,1,256}; 67 | \node[anchor=north west] at ($(n4) +(labelcoord)$) {\tiny 1,1,256}; 68 | \node[anchor=north west] at ($(n2) +(labelcoord)$) {\tiny 2,2}; 69 | 70 | \coordinate (n11) at ($(n3) +(0pt, -2*\d-12pt)$); 71 | \coordinate (S2) at (n11); 72 | 73 | \draw[signal] (S1) -- (n2); 74 | \draw[signal, -] (n3) -- (n11); 75 | \draw[signal, -] (n5) |- +(+\d,-\d) -| (n11); 76 | \draw[signal] (n2) |- +(-\d, -\d) -| (n4); 77 | 78 | \def\filters{{256,128,128,128,128}} 79 | 80 | \foreach \y in {3,...,7} { 81 | \begin{scope} [start chain=going below, every node/.style={on chain}] 82 | \node[bn, vlayer] (n7) at ($(n11) +(0pt, -0.5*\vlayerheight-22pt)$) {}; 83 | \node[activation, vlayer] {}; 84 | \node[conv, vlayer] (c7) {}; 85 | \node[bn, vlayer] {}; 86 | \node[activation, vlayer] {}; 87 | \node[conv, vlayer] (n8) {}; 88 | \end{scope} 89 | 90 | \begin{scope} [start chain=going below, every node/.style={on chain}] 91 | \node[pool, vlayer] (n9) at ($(n11) +(-2*\vlayerwidth, -2.5*\vlayerheight-22pt)$) {}; 92 | \node[bn, vlayer] {}; 93 | \node[activation, vlayer] {}; 94 | \node[conv, vlayer] (n10) {}; 95 | \end{scope} 96 | 97 | \draw[signal] (n11) -- (n7); 98 | \draw[signal] (n11) |- +(-\d, -\d) -| (n9); 99 | 100 | \coordinate (n11) at ($(n8) +(0pt, -2*\d-6pt)$); 101 | 102 | \draw[signal, -] (n8) -- (n11); 103 | \draw[signal, -] (n10) |- +(+\d,-\d) -| (n11); 104 | 105 | \coordinate (S\y) at (n11); 106 | 107 | \node[anchor=north west] at ($(n10) +(labelcoord)$) {\tiny 1,1,\pgfmathparse{\filters[\y-3]}\pgfmathresult}; 108 | 109 | \node[anchor=north west] at ($(c7) +(labelcoord)$) {\tiny 1,1,\pgfmathparse{int(\filters[\y-3]*4)}\pgfmathresult}; 110 | \node[anchor=north west] at ($(n8) +(labelcoord)$) {\tiny 3,1,\pgfmathparse{\filters[\y-3]}\pgfmathresult}; 111 | 112 | \node[anchor=north west] at ($(n9) +(labelcoord)$) {\tiny 2,2}; 113 | } 114 | 115 | \coordinate (n35) at ($(n11) +(0pt, -54pt-4.5*\vlayerheight-3*\d)$); 116 | 117 | \coordinate (n15) at ($(n35) +(2.5*\vlayerwidth, -12pt)$); 118 | \coordinate (n16) at ($(n15) +(2.5*\vlayerwidth, -12pt)$); 119 | \coordinate (n28) at ($(n16) +(2.5*\vlayerwidth, -12pt)$); 120 | \coordinate (n29) at ($(n28) +(2.5*\vlayerwidth, -12pt)$); 121 | 122 | \node[anchor=south] at ($(n15) +(-1.5*\vlayerwidth, -2pt)$) {\tiny 5461x2}; 123 | \node[anchor=south] at ($(n16) +(-1.0*\vlayerwidth, -2pt)$) {\tiny 5461x5}; 124 | \node[anchor=south] at ($(n28) +(-0.5*\vlayerwidth, -2pt)$) {\tiny 5461x16}; 125 | \node[anchor=south] at ($(n29) +(-0.0*\vlayerwidth, -2pt)$) {\tiny 5461x8}; 126 | 127 | \def\mapsize{{64,32,16,8,7,2,1}} 128 | \def\filters{{800,512,512,256,256,256,256}} 129 | 130 | \foreach \y in {1,...,7} { 131 | \begin{scope} [start chain=going below, every node/.style={on chain}] 132 | \ifthenelse{\y=1}{ 133 | \node[layer, vlayer] (n12) at ($(n3) +(2*\vlayerwidth, 0pt)$) {}; 134 | }{ 135 | \node[layer, vlayer] (n12) at ($(S\y) +(2*\vlayerwidth, -5.5*\vlayerheight-22pt)$) {}; 136 | } 137 | \end{scope} 138 | 139 | \draw[signal] (S\y) |- +(+\d, -\d) -| (n12); 140 | 141 | \begin{scope} [start chain=going below, every node/.style={on chain}] 142 | \node[bn, vlayer] (n13) 143 | at ($(n12) +({(0.5+\y*0.75)*\vlayerwidth}, -8pt-2*\d)$) {}; 144 | \node[activation, vlayer] {}; 145 | \node[conv, vlayer] (n37) {}; 146 | \node[layer, vlayer] (n17) {}; 147 | \end{scope} 148 | 149 | \begin{scope} [start chain=going below, every node/.style={on chain}] 150 | \node[bn, vlayer] (n14) 151 | at ($(n12) +({(0.5+(8+\y)*0.75)*\vlayerwidth}, -8pt-2*\d)$) {}; 152 | \node[activation, vlayer] {}; 153 | \node[conv, vlayer] (n38) {}; 154 | \node[layer, vlayer] (n18){}; 155 | \end{scope} 156 | 157 | \begin{scope} [start chain=going below, every node/.style={on chain}] 158 | \node[bn, vlayer] (n24) 159 | at ($(n12) +({(0.5+(16+\y)*0.75)*\vlayerwidth}, -8pt-2*\d)$) {}; 160 | \node[activation, vlayer] {}; 161 | \node[conv, vlayer] (n39) {}; 162 | \node[layer, vlayer] (n26){}; 163 | \end{scope} 164 | 165 | \begin{scope} [start chain=going below, every node/.style={on chain}] 166 | \node[bn, vlayer] (n25) 167 | at ($(n12) +({(0.5+(24+\y)*0.75)*\vlayerwidth}, -8pt-2*\d)$) {}; 168 | \node[activation, vlayer] {}; 169 | \node[conv, vlayer] (n40) {}; 170 | \node[layer, vlayer] (n27){}; 171 | \end{scope} 172 | 173 | \draw[signal] (n12) |- +(+\d, -\d) -| (n13); 174 | \draw[signal] (n12) |- +(+\d, -\d) -| (n14); 175 | 176 | \draw[signal] (n12) |- +(+\d, -\d) -| (n24); 177 | \draw[signal] (n12) |- +(+\d, -\d) -| (n25); 178 | 179 | \draw[signal, -] (n17) |- (n15); 180 | \draw[signal, -] (n18) |- (n16); 181 | 182 | \draw[signal, -] (n26) |- (n28); 183 | \draw[signal, -] (n27) |- (n29); 184 | 185 | \node[anchor=north west] at ($(n37) +(labelcoord)$) {\tiny 3,1,2}; 186 | \node[anchor=north west] at ($(n38) +(labelcoord)$) {\tiny 3,1,5}; 187 | \node[anchor=north west] at ($(n39) +(labelcoord)$) {\tiny 3,1,16}; 188 | \node[anchor=north west] at ($(n40) +(labelcoord)$) {\tiny 3,1,8}; 189 | 190 | \node[anchor=north west] at ($(S\y) +(shapecoord)$) {\tiny \pgfmathparse{\mapsize[\y-1]}\pgfmathresult x\pgfmathparse{\mapsize[\y-1]}\pgfmathresult x\pgfmathparse{\filters[\y-1]}\pgfmathresult}; 191 | } 192 | 193 | \coordinate (n36) at ($(n35) +(0pt, -40pt-2*\vlayerheight-2*\d)$); 194 | 195 | \begin{scope} [start chain=going below, every node/.style={on chain}] 196 | \node[layer, vlayer] (n19) at ($(n36) +(0pt, 0pt)$) {}; 197 | \node[softmax, vlayer] (n21) {}; 198 | \end{scope} 199 | 200 | \begin{scope} [start chain=going below, every node/.style={on chain}] 201 | \node[layer, vlayer] (n20) at ($(n36) +(3*\vlayerwidth, -\vlayerheight)$) {}; 202 | \end{scope} 203 | 204 | \begin{scope} [start chain=going below, every node/.style={on chain}] 205 | \node[layer, vlayer] (n30) at ($(n36) +(6*\vlayerwidth, 0pt)$) {}; 206 | \node[softmax, vlayer] (n31) {}; 207 | \end{scope} 208 | 209 | \begin{scope} [start chain=going below, every node/.style={on chain}] 210 | \node[layer, vlayer] (n32) at ($(n36) +(9*\vlayerwidth, 0pt)$) {}; 211 | \node[softmax, vlayer] (n33) {}; 212 | \end{scope} 213 | 214 | \draw[signal] (n15) -| (n19); 215 | \draw[signal] (n16) -| (n20); 216 | \draw[signal] (n28) -| (n30); 217 | \draw[signal] (n29) -| (n32); 218 | 219 | \node[point] (n23) at ($(n21) +(0pt, -46pt)$) {Output}; 220 | 221 | \draw[signal] (n21) -- (n23); 222 | \draw[signal] (n20) |- +(-\d,-20pt) -| (n23); 223 | \draw[signal] (n31) |- +(-\d,-20pt) -| (n23); 224 | \draw[signal] (n33) |- +(-\d,-20pt) -| (n23); 225 | 226 | \node[anchor=north west, text width=5cm, align=left] at ($(n21) +(0pt, -2pt)$) {\tiny segment \\ confidence\par}; 227 | \node[anchor=north west, text width=5cm, align=left] at ($(n20) +(0pt, -2pt)$) {\tiny segment \\ offsets\par}; 228 | \node[anchor=north west, text width=5cm, align=left] at ($(n31) +(0pt, -2pt)$) {\tiny within layer link \\ confidence\par}; 229 | \node[anchor=north west, text width=5cm, align=left] at ($(n33) +(0pt, -2pt)$) {\tiny cross layer link \\ confidence\par}; 230 | 231 | \node[anchor=north west] at ($(n23) +(shapecoord)$) {\tiny 5461x31}; 232 | 233 | % Dense Block 234 | 235 | \def\blockx{400pt} 236 | \def\blocky{-0pt} 237 | \def\blockw{90pt} 238 | \def\blockh{264pt} 239 | 240 | \draw[draw=black, fill=black!20!white] (\blockx,\blocky) rectangle (\blockx+\blockw,\blocky-\blockh); 241 | \draw[dotted] (d1.north east) -- (\blockx, \blocky); 242 | \draw[dotted] (d1.south east) -- (\blockx, \blocky-\blockh); 243 | 244 | \node[anchor=north west, text width=\blockw, align=center] at (\blockx,\blocky-8pt) {Dense Block\\n=6, k=48\par}; 245 | 246 | \coordinate (n0) at (\blockx+18pt,\blocky-40pt); 247 | \coordinate (n1) at ($(n0) +(0pt, -4pt)$); 248 | \node[anchor=north west] at ($(n1) +(-2pt, 6pt)$) {\tiny 128x128x128}; 249 | 250 | \foreach \y in {1,...,2} { 251 | \begin{scope} [start chain=going below, every node/.style={on chain}] 252 | \node[bn, vlayer] (n3) at ($(n1) +(0.8*\vlayerwidth, -20pt)$) {}; 253 | \node[activation, vlayer] {}; 254 | \node[conv, vlayer] (n4) {}; 255 | \node[bn, vlayer] {}; 256 | \node[activation, vlayer] {}; 257 | \node[conv, vlayer] (n2) {}; 258 | \end{scope} 259 | 260 | \node[anchor=north west] at ($(n4) +(labelcoord)$) {\tiny 1,1,4k}; 261 | \node[anchor=north west] at ($(n2) +(labelcoord)$) {\tiny 3,1,k}; 262 | \draw[signal] (n1) |- +(+\d, -\d) -| (n3); 263 | \coordinate (n1) at ($(n2) +(-0.8*\vlayerwidth, -16pt)$); 264 | \draw[signal, -] (n2) |- +(-\d, -\d) -| (n1); 265 | \node[anchor=north west] at ($(n1) +(-2pt, 6pt)$) {\tiny 128x128x(128+\y k)}; 266 | } 267 | 268 | \draw[signal, -] (n0) -- ($(n1) +(0pt, -12pt)$); 269 | 270 | \coordinate (n0) at ($(n1) +(0pt, -40pt)$); 271 | 272 | \draw[signal, -, loosely dotted] (n1) -- (n0); 273 | \coordinate (n1) at ($(n0) +(0pt, -4pt)$); 274 | 275 | \begin{scope} [start chain=going below, every node/.style={on chain}] 276 | \node[bn, vlayer] (n3) at ($(n1) +(0.8*\vlayerwidth, -20pt)$) {}; 277 | \node[activation, vlayer] {}; 278 | \node[conv, vlayer] (n4) {}; 279 | \node[bn, vlayer] {}; 280 | \node[activation, vlayer] {}; 281 | \node[conv, vlayer] (n2) {}; 282 | \end{scope} 283 | 284 | \node[anchor=north west] at ($(n4) +(labelcoord)$) {\tiny 1,1,4k}; 285 | \node[anchor=north west] at ($(n2) +(labelcoord)$) {\tiny 3,1,xk}; 286 | \draw[signal] (n1) |- +(+\d, -\d) -| (n3); 287 | \coordinate (n1) at ($(n2) +(-0.8*\vlayerwidth, -16pt)$); 288 | \draw[signal, -] (n2) |- +(-\d, -\d) -| (n1); 289 | \node[anchor=north west] at ($(n1) +(-2pt, 6pt)$) {\tiny 128x128x(128+nk)}; 290 | 291 | \draw[signal] (n0) -- ($(n1) +(0pt, -12pt)$); 292 | 293 | % Legend 294 | 295 | \def\legendx{560pt} 296 | \def\legendy{-20pt} 297 | \def\legendd{18pt} 298 | 299 | \coordinate (n1) at (\legendx,\legendy); 300 | \node[conv, vlayer, label=east:Convolution] at (n1) {}; 301 | \node[bn, vlayer, label=east:Batch Normalization] (n1) at ($(n1) +(0pt, -\legendd)$) {}; 302 | \node[activation, vlayer, label=east:ReLU] (n1) at ($(n1) +(0pt, -\legendd)$) {}; 303 | \node[pool, vlayer, label=east:Max Pooling] (n1) at ($(n1) +(0pt, -\legendd)$) {}; 304 | \node[layer, vlayer, label=east:{L2 Normalization, Flatten, Reshape, ...}] (n1) at ($(n1) +(0pt, -\legendd)$) {}; 305 | \node[softmax, vlayer, label=east:Softmax] (n1) at ($(n1) +(0pt, -\legendd)$) {}; 306 | 307 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 308 | \draw[signal] (n1) +(-\vlayerwidth/2, 0pt) -- +(\vlayerwidth/2, 0pt); 309 | \node[minimum width=\vlayerwidth, label=east:Vector Transfer] at (n1) {}; 310 | 311 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 312 | \draw[signal] (n1) +(-\vlayerwidth/2+4pt,+10pt) |- +(\vlayerwidth/2-4pt, 0pt); 313 | \draw[signal] (n1) +(-\vlayerwidth/2+4pt,-10pt) |- +(\vlayerwidth/2-4pt, 0pt); 314 | \node[minimum width=\vlayerwidth, label=east:Concatenate] at (n1) {}; 315 | 316 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 317 | \draw[signal] (n1) +(-\vlayerwidth/2+4pt,0pt) -| +(\vlayerwidth/2-4pt, +12pt); 318 | \draw[signal] (n1) +(-\vlayerwidth/2+4pt,0pt) -| +(\vlayerwidth/2-4pt, -12pt); 319 | \node[minimum width=\vlayerwidth, label=east:Copy] at (n1) {}; 320 | 321 | \end{tikzpicture} 322 | -------------------------------------------------------------------------------- /model_ssd.tex: -------------------------------------------------------------------------------- 1 | % SSD 2 | 3 | \begin{tikzpicture} 4 | 5 | \def\d{10pt} 6 | \def\nd{12pt} 7 | 8 | \coordinate (shapecoord) at (\layerwidth/2+4pt, -\d+6pt); 9 | 10 | \tikzstyle{stack}=[start chain=going below, 11 | node distance=\nd, 12 | every node/.style={on chain}, 13 | layer/.append style={join=by {signal}}, 14 | point/.append style={join=by {signal}}, 15 | ] 16 | 17 | \begin{scope} [stack] 18 | \node[point] (n0) {Input Image}; 19 | \node[conv] {Conv 3x3, 64}; % conv_1_1 20 | \node[activation] {ReLU}; 21 | \node[conv] {Conv 3x3, 64}; % conv_1_2 22 | \node[activation] {ReLU}; 23 | \node[pool] {MaxPool 2x2/2}; 24 | \node[conv] {Conv 3x3, 128}; % conv_2_1 25 | \node[activation] {ReLU}; 26 | \node[conv] {Conv 3x3, 128}; % conv_2_2 27 | \node[activation] {ReLU}; 28 | \node[pool] {MaxPool 2x2/2}; 29 | \node[conv] {Conv 3x3, 256}; % conv_3_1 30 | \node[activation] {ReLU}; 31 | \node[conv] {Conv 3x3, 256}; % conv_3_2 32 | \node[activation] {ReLU}; 33 | \node[conv] {Conv 3x3, 256}; % conv_3_3 34 | \node[activation] {ReLU}; 35 | \node[pool] {MaxPool 2x2/2}; 36 | \node[conv] {Conv 3x3, 512}; % conv_4_1 37 | \node[activation] {ReLU}; 38 | \node[conv] {Conv 3x3, 512}; % conv_4_2 39 | \node[activation] {ReLU}; 40 | \node[conv] {Conv 3x3, 512}; % conv_4_3 41 | \node[activation] (s1) {ReLU}; 42 | \node[pool, yshift=-\d] {MaxPool 2x2/2}; 43 | \node[conv] {Conv 3x3, 512}; % conv_5_1 44 | \node[activation] {ReLU}; 45 | \node[conv] {Conv 3x3, 512}; % conv_5_2 46 | \node[activation] {ReLU}; 47 | \node[conv] {Conv 3x3, 512}; % conv_5_3 48 | \node[activation] {ReLU}; 49 | \node[pool] {MaxPool 2x2/2}; 50 | \node[conv] {Conv 3x3, 1024}; % fc6 51 | \node[activation] {ReLU}; 52 | \node[conv] {Conv 1x1, 1024}; % fc7 53 | \node[activation] (s2) {ReLU}; 54 | \node[conv, yshift=-\d] {Conv 1x1, 256}; % conv_6_1 55 | \node[activation] {ReLU}; 56 | \node[conv] {Conv 3x3, 512}; % conv_6_2 57 | \node[activation] (s3) {ReLU}; 58 | \node[conv, yshift=-\d] {Conv 1x1, 128}; % conv_7_1 59 | \node[activation] {ReLU}; 60 | \node[conv] {Conv 3x3, 256}; % conv_7_2 61 | \node[activation] (s4) {ReLU}; 62 | \node[conv, yshift=-\d] {Conv 1x1, 128}; % conv_8_1 63 | \node[activation] {ReLU}; 64 | \node[conv] {Conv 3x3, 256}; % conv_8_2 65 | \node[activation] (s5) {ReLU}; 66 | \node[conv, yshift=-\d] {Conv 1x1, 128}; % conv_9_1 67 | \node[activation] {ReLU}; 68 | \node[conv] {Conv 3x3, 256}; % conv_9_2 69 | \node[activation] (s6) {ReLU}; 70 | \end{scope} 71 | 72 | \node[anchor=north west] at ($(n0) +(shapecoord)$) {\footnotesize 300x300x3}; 73 | \def\mapsizes{{"38x38x512", "19x19x1024", "10x10x512", "5x5x256", "3x3x256", "1x1x256"}} 74 | \def\priors{{4,6,6,6,4,4}} 75 | 76 | \coordinate (c3) at ($(s6) +(0pt, -3.5*\layerheight-3*\nd-2*\d)$); 77 | 78 | \foreach \y in {1,...,6} { 79 | 80 | \coordinate (c1) at ($(s\y) +(1.5*\layerwidth, -\d-\nd-\layerheight)$); 81 | 82 | \node[anchor=north west] at ($(s\y) +(shapecoord)$) {\footnotesize \pgfmathparse{\mapsizes[\y-1]}\pgfmathresult}; 83 | 84 | \ifthenelse{\y=1}{ 85 | \node[layer] (n1) at (c1) {L2 Normalize}; 86 | \coordinate (c2) at ($(n1) +({(\y-1)*\layerwidth}, {-8*(\layerheight+\nd)})$); 87 | \begin{scope} [stack] 88 | \node[conv] (n5) at (c2) 89 | {Conv 3x3, \pgfmathparse{int(\priors[\y-1]*21)}\pgfmathresult}; 90 | \node[activation] {ReLU}; 91 | \node[layer] (n2) {Flatten}; 92 | \end{scope} 93 | \draw[signal] (n1) -- (n5); 94 | 95 | \begin{scope} [stack] 96 | \node[conv] (n3) at ($(c2) +(6*\layerwidth, -0pt)$) 97 | {Conv 3x3, \pgfmathparse{int(\priors[\y-1]*4)}\pgfmathresult}; 98 | \node[activation] {ReLU}; 99 | \node[layer] (n4) {Flatten}; 100 | \end{scope} 101 | 102 | \draw[signal] (n1.south) |- +(\d, {-7*(\layerheight+\nd)}) -| (n3.north); 103 | }{ 104 | \coordinate (c2) at ($(c1) +({(\y-1)*\layerwidth}, -0pt)$); 105 | \begin{scope} [stack] 106 | \node[conv] (n1) at (c2) 107 | {Conv 3x3, \pgfmathparse{int(\priors[\y-1]*21)}\pgfmathresult}; 108 | \node[activation] {ReLU}; 109 | \node[layer] (n2) {Flatten}; 110 | \end{scope} 111 | 112 | \begin{scope} [stack] 113 | \node[conv] (n3) at ($(c2) +(6*\layerwidth, -0pt)$) 114 | {Conv 3x3, \pgfmathparse{int(\priors[\y-1]*4)}\pgfmathresult}; 115 | \node[activation] {ReLU}; 116 | \node[layer] (n4) {Flatten}; 117 | \end{scope} 118 | 119 | \draw[signal] (s\y.south) |- +(\d,-\d) -| (n3.north); 120 | } 121 | 122 | \coordinate (c4) at ($(c3) +(0pt, -0.5*\layerheight-\nd-\d)$); 123 | 124 | \begin{scope} [stack] 125 | \node[layer] (n6) at ($(c4) +(0pt, 0pt)$) {Reshape}; 126 | \node[softmax] (n8) {Softmax}; 127 | \end{scope} 128 | 129 | \begin{scope} [stack] 130 | \node[layer] (n7) at ($(c4) +(1.5*\layerwidth, -\layerheight-\nd)$) {Reshape}; 131 | \end{scope} 132 | 133 | \draw[signal] (s\y.south) |- +(\d,-\d) -| (n1.north); 134 | \draw[signal, -] (n2.south) |- ($(c3) +(1*\layerwidth, -0pt)$); 135 | \draw[signal, -] (n4.south) |- ($(c3) +(2.5*\layerwidth, -\nd)$); 136 | 137 | } 138 | 139 | \draw[signal] ($(c3) +(1*\layerwidth, -0pt)$) -| (n6); 140 | \draw[signal] ($(c3) +(2.5*\layerwidth, -\nd)$) -| (n7); 141 | 142 | \node[point] (n9) at ($(n8) +(0pt, -\layerheight-2*\d-\nd-10pt)$) {Output}; 143 | \draw[signal] (n8) -- (n9); 144 | \draw[signal] (n7.south) |- +(-\d, -\d-10pt) -| (n9); 145 | 146 | \node[anchor=north west, text width=5cm, align=left] at ($(n8) +(0pt, -0.5*\layerheight)$) {classification\par}; 147 | \node[anchor=north west, text width=5cm, align=left] at ($(n7) +(0pt, -0.5*\layerheight)$) {bounding box regression\par}; 148 | 149 | % Legend 150 | 151 | \def\legendx{940pt} 152 | \def\legendy{-40pt} 153 | \def\legendd{24pt} 154 | 155 | \def\w{30pt} 156 | 157 | \coordinate (n1) at (\legendx,\legendy); 158 | 159 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 160 | \draw[signal] (n1) +(-\w/2, 0pt) -- +(\w/2, 0pt); 161 | \node[minimum width=\w, label=east:Vector Transfer] at (n1) {}; 162 | 163 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 164 | \draw[signal] (n1) +(-\w/2+4pt,+10pt) |- +(\w/2-4pt, 0pt); 165 | \draw[signal] (n1) +(-\w/2+4pt,-10pt) |- +(\w/2-4pt, 0pt); 166 | \node[minimum width=\w, label=east:Concatenate] at (n1) {}; 167 | 168 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 169 | \draw[signal] (n1) +(-\w/2+4pt,0pt) -| +(\w/2-4pt, +12pt); 170 | \draw[signal] (n1) +(-\w/2+4pt,0pt) -| +(\w/2-4pt, -12pt); 171 | \node[minimum width=\w, label=east:Copy] at (n1) {}; 172 | 173 | \end{tikzpicture} -------------------------------------------------------------------------------- /model_ssd_noacti.tex: -------------------------------------------------------------------------------- 1 | % SSD 2 | 3 | \begin{tikzpicture} 4 | 5 | \def\d{10pt} 6 | \def\nd{13pt} 7 | 8 | \coordinate (shapecoord) at (\layerwidth/2+0pt, -\d+4pt); 9 | 10 | \tikzstyle{stack}=[start chain=going below, 11 | node distance=\nd, 12 | every node/.style={on chain}, 13 | layer/.append style={join=by {signal}}, 14 | point/.append style={join=by {signal}}, 15 | ] 16 | 17 | \begin{scope} [stack] 18 | \node[point] (n0) {Input Image}; 19 | \node[conv] {Conv 3x3, 64}; % conv_1_2 20 | \node[pool] {MaxPool 2x2/2}; 21 | \node[conv] {Conv 3x3, 64}; % conv_2_1 22 | \node[conv] {Conv 3x3, 64}; % conv_2_2 23 | \node[pool] {MaxPool 2x2/2}; 24 | \node[conv] {Conv 3x3, 256}; % conv_3_1 25 | \node[conv] {Conv 3x3, 256}; % conv_3_2 26 | \node[conv] {Conv 3x3, 256}; % conv_3_3 27 | \node[pool] {MaxPool 2x2/2}; 28 | \node[conv] {Conv 3x3, 512}; % conv_4_1 29 | \node[conv] {Conv 3x3, 512}; % conv_4_2 30 | \node[conv] (s1) {Conv 3x3, 512}; % conv_4_3 31 | \node[pool, yshift=-\d] {MaxPool 2x2/2}; 32 | \node[conv] {Conv 3x3, 512}; % conv_5_1 33 | \node[conv] {Conv 3x3, 512}; % conv_5_2 34 | \node[conv] {Conv 3x3, 512}; % conv_5_3 35 | \node[pool] {MaxPool 2x2/2}; 36 | \node[conv] {Conv 3x3, 1024}; % fc6 37 | \node[conv] (s2) {Conv 1x1, 1024}; % fc7 38 | \node[conv, yshift=-\d] {Conv 1x1, 256}; % conv_6_1 39 | \node[conv] (s3) {Conv 3x3, 512}; % conv_6_2 40 | \node[conv, yshift=-\d] {Conv 1x1, 128}; % conv_7_1 41 | \node[conv] (s4) {Conv 3x3, 256}; % conv_7_2 42 | \node[conv, yshift=-\d] {Conv 1x1, 128}; % conv_8_1 43 | \node[conv] (s5) {Conv 3x3, 256}; % conv_8_2 44 | \node[conv, yshift=-\d] {Conv 1x1, 128}; % conv_9_1 45 | \node[conv] (s6) {Conv 3x3, 256}; % conv_9_2 46 | \end{scope} 47 | 48 | \node[anchor=north west] at ($(n0) +(shapecoord)$) {\footnotesize 300x300x3}; 49 | \def\mapsizes{{"38x38x512", "19x19x1024", "10x10x512", "5x5x256", "3x3x256", "1x1x256"}} 50 | \def\priors{{4,6,6,6,4,4}} 51 | 52 | \coordinate (c3) at ($(s6) +(0pt, -2.5*\layerheight-2*\nd-2*\d)$); 53 | 54 | \foreach \y in {1,...,6} { 55 | 56 | \coordinate (c1) at ($(s\y) +(1.5*\layerwidth, -\d-\nd-\layerheight)$); 57 | 58 | \node[anchor=north west] at ($(s\y) +(shapecoord)$) {\footnotesize \pgfmathparse{\mapsizes[\y-1]}\pgfmathresult}; 59 | 60 | \ifthenelse{\y=1}{ 61 | \node[layer] (n1) at (c1) {L2 Normalize}; 62 | \coordinate (c2) at ($(n1) +({(\y-1)*\layerwidth}, {-5*(\layerheight+\nd)})$); 63 | \begin{scope} [stack] 64 | \node[conv] (n5) at (c2) 65 | {Conv 3x3, \pgfmathparse{int(\priors[\y-1]*21)}\pgfmathresult}; 66 | \node[layer] (n2) {Flatten}; 67 | \end{scope} 68 | \draw[signal] (n1) -- (n5); 69 | 70 | \begin{scope} [stack] 71 | \node[conv] (n3) at ($(c2) +(6*\layerwidth, -0pt)$) 72 | {Conv 3x3, \pgfmathparse{int(\priors[\y-1]*4)}\pgfmathresult}; 73 | \node[layer] (n4) {Flatten}; 74 | \end{scope} 75 | 76 | \draw[signal] (n1.south) |- +(\d, {-4*(\layerheight+\nd)}) -| (n3.north); 77 | }{ 78 | \coordinate (c2) at ($(c1) +({(\y-1)*\layerwidth}, -0pt)$); 79 | \begin{scope} [stack] 80 | \node[conv] (n1) at (c2) 81 | {Conv 3x3, \pgfmathparse{int(\priors[\y-1]*21)}\pgfmathresult}; 82 | \node[layer] (n2) {Flatten}; 83 | \end{scope} 84 | 85 | \begin{scope} [stack] 86 | \node[conv] (n3) at ($(c2) +(6*\layerwidth, -0pt)$) 87 | {Conv 3x3, \pgfmathparse{int(\priors[\y-1]*4)}\pgfmathresult}; 88 | \node[layer] (n4) {Flatten}; 89 | \end{scope} 90 | 91 | \draw[signal] (s\y.south) |- +(\d,-\d) -| (n3.north); 92 | } 93 | 94 | \coordinate (c4) at ($(c3) +(0pt, -0.5*\layerheight-\nd-\d)$); 95 | 96 | \begin{scope} [stack] 97 | \node[layer] (n6) at ($(c4) +(0pt, 0pt)$) {Reshape}; 98 | \node[softmax] (n8) {Softmax}; 99 | \end{scope} 100 | 101 | \begin{scope} [stack] 102 | \node[layer] (n7) at ($(c4) +(1.5*\layerwidth, -\layerheight-\nd)$) {Reshape}; 103 | \end{scope} 104 | 105 | \draw[signal] (s\y.south) |- +(\d,-\d) -| (n1.north); 106 | \draw[signal, -] (n2.south) |- ($(c3) +(1*\layerwidth, -0pt)$); 107 | \draw[signal, -] (n4.south) |- ($(c3) +(2.5*\layerwidth, -\nd)$); 108 | 109 | } 110 | 111 | \draw[signal] ($(c3) +(1*\layerwidth, -0pt)$) -| (n6); 112 | \draw[signal] ($(c3) +(2.5*\layerwidth, -\nd)$) -| (n7); 113 | 114 | \node[point] (n9) at ($(n8) +(0pt, -\layerheight-2*\d-\nd-10pt)$) {Output}; 115 | \draw[signal] (n8) -- (n9); 116 | \draw[signal] (n7.south) |- +(-\d, -\d-10pt) -| (n9); 117 | 118 | \node[anchor=north west, text width=5cm, align=left] at ($(n8) +(0pt, -0.5*\layerheight)$) {classification\par}; 119 | \node[anchor=north west, text width=5cm, align=left] at ($(n7) +(0pt, -0.5*\layerheight)$) {bounding box regression\par}; 120 | 121 | % Legend 122 | 123 | \def\legendx{1000pt} 124 | \def\legendy{-20pt} 125 | \def\legendd{24pt} 126 | 127 | \def\w{30pt} 128 | 129 | \coordinate (n1) at (\legendx,\legendy); 130 | 131 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 132 | \draw[signal] (n1) +(-\w/2, 0pt) -- +(\w/2, 0pt); 133 | \node[minimum width=\w, label=east:Vector Transfer] at (n1) {}; 134 | 135 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 136 | \draw[signal] (n1) +(-\w/2+4pt,+10pt) |- +(\w/2-4pt, 0pt); 137 | \draw[signal] (n1) +(-\w/2+4pt,-10pt) |- +(\w/2-4pt, 0pt); 138 | \node[minimum width=\w, label=east:Concatenate] at (n1) {}; 139 | 140 | \coordinate (n1) at ($(n1) +(0pt, -\legendd)$); 141 | \draw[signal] (n1) +(-\w/2+4pt,0pt) -| +(\w/2-4pt, +12pt); 142 | \draw[signal] (n1) +(-\w/2+4pt,0pt) -| +(\w/2-4pt, -12pt); 143 | \node[minimum width=\w, label=east:Copy] at (n1) {}; 144 | 145 | \end{tikzpicture} -------------------------------------------------------------------------------- /model_ssd_old.tex: -------------------------------------------------------------------------------- 1 | % SSD 2 | \def\d{10pt} 3 | \def\branchy{70pt} 4 | 5 | \begin{tikzpicture}[] 6 | {[start chain=main going below, node distance=12pt, 7 | point/.append style={on chain, join=by {signal}}, 8 | layer/.append style={on chain, join=by {signal, to path={-- ++(0,-20pt) -| (\tikztotarget)}}}, 9 | ] 10 | \node[point] (n) {Input Image}; 11 | \node[anchor=north west] at ($(n) +(\layerwidth/2+0pt, -6pt)$) {300x300x3}; 12 | \node[conv, node distance=16pt, on chain, join=by {signal}] {Conv 3x3, 64}; % conv_1_1, hack 13 | \node[conv] {Conv 3x3, 64}; % conv_1_2 14 | \node[pool] {MaxPool 2x2/2}; 15 | \node[conv] {Conv 3x3, 64}; % conv_2_1 16 | \node[conv] {Conv 3x3, 64}; % conv_2_2 17 | \node[pool] {MaxPool 2x2/2}; 18 | \node[conv] {Conv 3x3, 256}; % conv_3_1 19 | \node[conv] {Conv 3x3, 256}; % conv_3_2 20 | \node[conv] {Conv 3x3, 256}; % conv_3_3 21 | \node[pool] {MaxPool 2x2/2}; 22 | \node[conv] {Conv 3x3, 512}; % conv_4_1 23 | \node[conv] {Conv 3x3, 512}; % conv_4_2 24 | \node[conv] (n) {Conv 3x3, 512}; % conv_4_3 25 | \node[anchor=north west] at ($(n) +(\layerwidth/2+0pt, -6pt)$) {38x38x512}; 26 | 27 | {[start branch=b1 going below] 28 | \node[layer, xshift=\layerwidth*1.5, yshift=-16pt] {L2 Normalize}; 29 | {[start branch=b1c going below] 30 | \node[conv, xshift=\layerwidth*4.5, yshift=-104pt] {Conv 3x3, 84}; 31 | \node[layer] {Flatten}; 32 | } 33 | {[start branch=b1r going below] 34 | \node[conv, xshift=\layerwidth*10.5, yshift=-104pt] {Conv 3x3, 16}; 35 | \node[layer] {Flatten}; 36 | } 37 | } 38 | 39 | \node[pool, yshift=-16pt] {MaxPool 2x2/2}; 40 | \node[conv] {Conv 3x3, 512}; % conv_5_1 41 | \node[conv] {Conv 3x3, 512}; % conv_5_2 42 | \node[conv] {Conv 3x3, 512}; % conv_5_3 43 | \node[pool] {MaxPool 2x2/2}; 44 | \node[conv] {Conv 3x3 1024}; % fc6 45 | \node[conv] (n) {Conv 1x1 1024}; % fc7 46 | \node[anchor=north west] at ($(n) +(\layerwidth/2+0pt, -6pt)$) {19x19x1024}; 47 | 48 | {[start branch=b2c going below] 49 | \node[conv, xshift=\layerwidth*5, yshift=-16pt] {Conv 3x3, 126}; 50 | \node[layer] {Flatten}; 51 | } 52 | {[start branch=b2r going below] 53 | \node[conv, xshift=\layerwidth*11, yshift=-16pt] {Conv 3x3, 24}; 54 | \node[layer] {Flatten}; 55 | } 56 | 57 | \node[conv, yshift=-16pt] {Conv 1x1, 256}; % conv_6_1 58 | \node[conv] (n) {Conv 3x3, 512}; % conv_6_2 59 | \node[anchor=north west] at ($(n) +(\layerwidth/2+0pt, -6pt)$) {10x10x512}; 60 | 61 | {[start branch=b3c going below] 62 | \node[conv, xshift=\layerwidth*4, yshift=-16pt] {Conv 3x3, 126}; 63 | \node[layer] {Flatten}; 64 | } 65 | {[start branch=b3r going below] 66 | \node[conv, xshift=\layerwidth*10, yshift=-16pt] {Conv 3x3, 24}; 67 | \node[layer] {Flatten}; 68 | } 69 | 70 | \node[conv, yshift=-16pt] {Conv 1x1, 128}; % conv_7_1 71 | \node[conv] (n) {Conv 3x3, 256}; % conv_7_2 72 | \node[anchor=north west] at ($(n) +(\layerwidth/2+0pt, -6pt)$) {5x5x256}; 73 | 74 | {[start branch=b4c going below] 75 | \node[conv, xshift=\layerwidth*3, yshift=-16pt] {Conv 3x3, 126}; 76 | \node[layer] {Flatten}; 77 | } 78 | {[start branch=b4r going below] 79 | \node[conv, xshift=\layerwidth*9, yshift=-16pt] {Conv 3x3, 24}; 80 | \node[layer] {Flatten}; 81 | } 82 | 83 | \node[conv, yshift=-16pt] {Conv 1x1, 128}; % conv_8_1 84 | \node[conv] (n) {Conv 3x3, 256}; % conv_8_2 85 | \node[anchor=north west] at ($(n) +(\layerwidth/2+0pt, -6pt)$) {3x3x256}; 86 | 87 | {[start branch=b5c going below] 88 | \node[conv, xshift=\layerwidth*2, yshift=-16pt] {Conv 3x3, 84}; 89 | \node[layer] {Flatten}; 90 | } 91 | {[start branch=b5r going below] 92 | \node[conv, xshift=\layerwidth*8, yshift=-16pt] {Conv 3x3, 16}; 93 | \node[layer] {Flatten}; 94 | } 95 | 96 | \node[conv, yshift=-16pt] {Conv 1x1, 128}; % conv_9_1 97 | \node[conv] (n) {Conv 3x3, 256}; % conv_9_2 98 | \node[anchor=north west] at ($(n) +(\layerwidth/2+0pt, -6pt)$) {1x1x256}; 99 | 100 | {[start branch=b6c going below] 101 | \node[conv, xshift=\layerwidth*1, yshift=-16pt] {Conv 3x3, 84}; 102 | \node[layer] {Flatten}; 103 | } 104 | {[start branch=b6r going below] 105 | \node[conv, xshift=\layerwidth*7, yshift=-16pt] {Conv 3x3, 16}; 106 | \node[layer] {Flatten}; 107 | } 108 | } 109 | 110 | {[start chain=going below, node distance=12pt, 111 | point/.append style={on chain, join=by {signal}}, 112 | layer/.append style={on chain, join=by {signal}}, 113 | branch/.append style={on chain, join=by {signal, -}}, 114 | ] 115 | \node[layer, xshift=\layerwidth*2.5, yshift=-\branchy*2, 116 | below of=main/b6c-end, 117 | join=with main/b1/b1c-end by {signal, to path={|- ($(\tikztotarget) +(\d*2.5,\d*2)$) -- ($(\tikztotarget.north) +(\d*2.5,0pt)$)}}, 118 | join=with main/b2c-end by {signal, to path={|- ($(\tikztotarget) +(\d*1.5,\d*3)$) -- ($(\tikztotarget.north) +(\d*1.5,0pt)$)}}, 119 | join=with main/b3c-end by {signal, to path={|- ($(\tikztotarget) +(\d*0.5,\d*4)$) -- ($(\tikztotarget.north) +(\d*0.5,0pt)$)}}, 120 | join=with main/b4c-end by {signal, to path={|- ($(\tikztotarget) +(-\d*0.5,\d*4)$) -- ($(\tikztotarget.north) +(-\d*0.5,0pt)$)}}, 121 | join=with main/b5c-end by {signal, to path={|- ($(\tikztotarget) +(-\d*1.5,\d*3)$) -- ($(\tikztotarget.north) +(-\d*1.5,0pt)$)}}, 122 | join=with main/b6c-end by {signal, to path={|- ($(\tikztotarget) +(-\d*2.5,\d*2)$) -- ($(\tikztotarget.north) +(-\d*2.5,0pt)$)}}, 123 | ] {Concatenate}; 124 | \node[layer] {Reshape}; 125 | \node[softmax] {Softmax}; 126 | \node[point] {Classification}; 127 | } 128 | 129 | {[start chain=going below, node distance=12pt, 130 | point/.append style={on chain, join=by {signal}}, 131 | layer/.append style={on chain, join=by {signal}}, 132 | branch/.append style={on chain, join=by {signal, -}}, 133 | ] 134 | \node[layer, xshift=\layerwidth*2.5, yshift=-\branchy*2, 135 | below of=main/b6r-end, 136 | join=with main/b1/b1r-end by {signal, to path={|- ($(\tikztotarget) +(\d*2.5,\d*2)$) -- ($(\tikztotarget.north) +(\d*2.5,0pt)$)}}, 137 | join=with main/b2r-end by {signal, to path={|- ($(\tikztotarget) +(\d*1.5,\d*3)$) -- ($(\tikztotarget.north) +(\d*1.5,0pt)$)}}, 138 | join=with main/b3r-end by {signal, to path={|- ($(\tikztotarget) +(\d*0.5,\d*4)$) -- ($(\tikztotarget.north) +(\d*0.5,0pt)$)}}, 139 | join=with main/b4r-end by {signal, to path={|- ($(\tikztotarget) +(-\d*0.5,\d*4)$) -- ($(\tikztotarget.north) +(-\d*0.5,0pt)$)}}, 140 | join=with main/b5r-end by {signal, to path={|- ($(\tikztotarget) +(-\d*1.5,\d*3)$) -- ($(\tikztotarget.north) +(-\d*1.5,0pt)$)}}, 141 | join=with main/b6r-end by {signal, to path={|- ($(\tikztotarget) +(-\d*2.5,\d*2)$) -- ($(\tikztotarget.north) +(-\d*2.5,0pt)$)}}, 142 | ] {Concatenate}; 143 | \node[layer] {Reshape}; 144 | \node[point, on chain, join=by {signal}] {BBox Regression}; 145 | } 146 | \end{tikzpicture} 147 | -------------------------------------------------------------------------------- /model_vgg16.tex: -------------------------------------------------------------------------------- 1 | % VGG16 2 | \begin{tikzpicture}[start chain=going below, node distance=12pt, 3 | point/.append style={on chain, join=by {signal}}, 4 | layer/.append style={on chain, join=by {signal}}, 5 | ] 6 | \node[point] {Input Image}; 7 | \node[conv] {Conv 3x3, 64}; 8 | \node[activation] {ReLU}; 9 | \node[conv] {Conv 3x3, 64}; 10 | \node[activation] {ReLU}; 11 | \node[pool] {MaxPool 2x2/2}; 12 | \node[conv] {Conv 3x3, 64}; 13 | \node[activation] {ReLU}; 14 | \node[conv] {Conv 3x3, 64}; 15 | \node[activation] {ReLU}; 16 | \node[pool] {MaxPool 2x2/2}; 17 | \node[conv] {Conv 3x3, 256}; 18 | \node[activation] {ReLU}; 19 | \node[conv] {Conv 3x3, 256}; 20 | \node[activation] {ReLU}; 21 | \node[conv] {Conv 3x3, 256}; 22 | \node[activation] {ReLU}; 23 | \node[pool] {MaxPool 2x2/2}; 24 | \node[conv] {Conv 3x3, 512}; 25 | \node[activation] {ReLU}; 26 | \node[conv] {Conv 3x3, 512}; 27 | \node[activation] {ReLU}; 28 | \node[conv] {Conv 3x3, 512}; 29 | \node[activation] {ReLU}; 30 | \node[pool] {MaxPool 2x2/2}; 31 | \node[conv] {Conv 3x3, 512}; 32 | \node[activation] {ReLU}; 33 | \node[conv] {Conv 3x3, 512}; 34 | \node[activation] {ReLU}; 35 | \node[conv] {Conv 3x3, 512}; 36 | \node[activation] {ReLU}; 37 | \node[pool] {MaxPool 2x2/2}; 38 | \node[layer] {Flatten}; 39 | \node[fc] {FC 4096}; 40 | \node[activation] {ReLU}; 41 | \node[layer] {Dropout}; 42 | \node[fc] {FC 4096}; 43 | \node[activation] {ReLU}; 44 | \node[layer] {Dropout}; 45 | \node[fc] {FC 1000}; 46 | \node[softmax] {Softmax}; 47 | \node[point] {Classification Output}; 48 | \end{tikzpicture} 49 | -------------------------------------------------------------------------------- /multiscale_prediction.tex: -------------------------------------------------------------------------------- 1 | % Multi Scale Prediction 2 | 3 | \begin{tikzpicture} 4 | \def\d{10pt} 5 | \def\hblockheight{40pt} 6 | 7 | \tikzstyle{hblock}=[style=block, draw=black, fill=black!20!white, minimum height=\hblockheight, text width=3cm, align=center] 8 | \tikzstyle{hblockdist}=[node distance=\hblockheight+20pt] 9 | 10 | \begin{scope} [start chain=going right, 11 | every node/.style={on chain, join=by {signal}, hblockdist}] 12 | \node[point] (b1) {Input}; 13 | \node[hblock] (s1) {Convolutional Feature Extractor}; 14 | \node[hblock] (s2) {Convolution and Downsampling}; 15 | \node[hblock] (s3) {Convolution and Downsampling}; 16 | \node[] (b1) {...}; 17 | \node[hblock] (sn) {Convolution and Downsampling}; 18 | \node[hblock] (pn) {Convolutional Predictor}; 19 | \end{scope} 20 | 21 | \node[above of=pn, hblockdist] 22 | (pd) {...}; 23 | \node[hblock, above of=pd, hblockdist] 24 | (p3) {Convolutional Predictor}; 25 | \node[hblock, above of=p3, hblockdist] 26 | (p2) {Convolutional Predictor}; 27 | \node[hblock, above of=p2, hblockdist] 28 | (p1) {Convolutional Predictor}; 29 | 30 | \node[point, right of=pn, node distance=\hblockheight+90pt] 31 | (b1) {Output}; 32 | 33 | \draw[signal] (s1.east) -| +(\d,\d) |- (p1); 34 | \draw[signal] (s2.east) -| +(\d,\d) |- (p2); 35 | \draw[signal] (s3.east) -| +(\d,\d) |- (p3); 36 | 37 | \draw[signal] (p1.east) -| +(3*\d,-\d) |- (b1); 38 | \draw[signal] (p2.east) -| +(2*\d,-\d) |- (b1); 39 | \draw[signal] (p3.east) -| +(1*\d,-\d) |- (b1); 40 | \draw[signal] (pn.east) -- (b1); 41 | \end{tikzpicture} 42 | -------------------------------------------------------------------------------- /network_cnn.tex: -------------------------------------------------------------------------------- 1 | % CNN 2 | \begin{tikzpicture}[] 3 | \def\nodedist{30pt} 4 | \def\layerdist{70pt} 5 | 6 | \tikzstyle{every pin edge}=[signal] 7 | \tikzstyle{annot} = [text width=4em, text centered] 8 | 9 | \foreach \y in {1,...,8} 10 | \node[inputnode] 11 | (I\y) at (0,-\y*\nodedist) {$x_\y$}; 12 | 13 | \foreach \y in {1,...,8} 14 | \node[hiddennode] 15 | (H1\y) at (\layerdist,-\y*\nodedist) {$z_\y^{1}$}; 16 | 17 | \foreach \y in {1,...,8} 18 | \node[hiddennode] 19 | (H2\y) at (2*\layerdist,-\y*\nodedist) {$z_\y^{2}$}; 20 | 21 | \foreach \y in {1,...,6} 22 | \node[hiddennode] 23 | (H3\y) at (3*\layerdist,-\y*\nodedist-\nodedist) {$z_\y^{3}$}; 24 | 25 | \foreach \y in {1,...,6} 26 | \node[outputnode] 27 | (O\y) at (4*\layerdist,-\y*\nodedist-\nodedist) {$y_\y$}; 28 | 29 | \foreach \dest in {1,...,8} 30 | \draw[signal, violet] (I\dest) -- (H1\dest); 31 | \foreach \dest [count=\source from 1] in {2,...,8} 32 | \draw[signal, teal] (I\source) -- (H1\dest); 33 | \foreach \dest [count=\source from 2] in {1,...,7} 34 | \draw[signal, brown] (I\source) -- (H1\dest); 35 | 36 | \foreach \dest in {1,...,8} 37 | \draw[signal, red,] (H1\dest) -- (H2\dest); 38 | \foreach \dest [count=\source from 1] in {2,...,8} 39 | \draw[signal, green] (H1\source) -- (H2\dest); 40 | \foreach \dest [count=\source from 2] in {1,...,7} 41 | \draw[signal, blue] (H1\source) -- (H2\dest); 42 | 43 | \foreach \dest in {1,...,6} 44 | \draw[signal, cyan] (H2\dest) -- (H3\dest); 45 | \foreach \dest [count=\source from 3] in {1,...,6} 46 | \draw[signal, orange] (H2\source) -- (H3\dest); 47 | \foreach \dest [count=\source from 2] in {1,...,6} 48 | \draw[signal, lime] (H2\source) -- (H3\dest); 49 | 50 | \foreach \dest in {1,...,6} 51 | \foreach \source in {1,...,6} 52 | \draw[signal] (H3\source) -- (O\dest); 53 | \end{tikzpicture} 54 | -------------------------------------------------------------------------------- /network_cnn_receptivefield.tex: -------------------------------------------------------------------------------- 1 | % CNN receptive field 2 | \begin{tikzpicture}[] 3 | \def\nodedist{30pt} 4 | \def\layerdist{70pt} 5 | 6 | \tikzstyle{every pin edge}=[signal] 7 | \tikzstyle{annot} = [text width=4em, text centered] 8 | 9 | \foreach \y in {1,...,14} 10 | \node[inputnode] 11 | (I\y) at (0,-\y*\nodedist) {$x_{\y}$}; 12 | 13 | \foreach \y in {1,...,14} 14 | \node[hiddennode] 15 | (H1\y) at (\layerdist,-\y*\nodedist) {$z_{\y}^{1}$}; 16 | 17 | \foreach \y in {1,...,14} 18 | \node[hiddennode] 19 | (H2\y) at (2*\layerdist,-\y*\nodedist) {$z_{\y}^{2}$}; 20 | 21 | \foreach \y in {1,...,12} 22 | \node[hiddennode] 23 | (H3\y) at (3*\layerdist,-\y*\nodedist-\nodedist) {$z_{\y}^{3}$}; 24 | 25 | \foreach \dest in {1,...,14} 26 | \draw[signal, violet] (I\dest) -- (H1\dest); 27 | \foreach \dest [count=\source from 1] in {2,...,14} 28 | \draw[signal, teal] (I\source) -- (H1\dest); 29 | \foreach \dest [count=\source from 2] in {1,...,13} 30 | \draw[signal, brown] (I\source) -- (H1\dest); 31 | 32 | \foreach \dest in {1,...,14} 33 | \draw[signal, red,] (H1\dest) -- (H2\dest); 34 | \foreach \dest [count=\source from 1] in {2,...,14} 35 | \draw[signal, green] (H1\source) -- (H2\dest); 36 | \foreach \dest [count=\source from 2] in {1,...,13} 37 | \draw[signal, blue] (H1\source) -- (H2\dest); 38 | 39 | \foreach \dest in {1,...,12} 40 | \draw[signal, cyan] (H2\dest) -- (H3\dest); 41 | \foreach \dest [count=\source from 3] in {1,...,12} 42 | \draw[signal, orange] (H2\source) -- (H3\dest); 43 | \foreach \dest [count=\source from 2] in {1,...,12} 44 | \draw[signal, lime] (H2\source) -- (H3\dest); 45 | 46 | 47 | \draw [fill=blue, draw=red, fill opacity=0.2, draw opacity=1.0, line width=1.4pt] 48 | ($(I7) +(-14pt,+21pt)$) -- ($(H39) +(-14pt,+21pt)$) -- ($(H39) +(-14pt,-21pt)$) -- ($(I13) +(-14pt,-21pt)$) -- cycle; 49 | 50 | \end{tikzpicture} -------------------------------------------------------------------------------- /network_cnn_stide.tex: -------------------------------------------------------------------------------- 1 | % CNN with sdide 2 | \begin{tikzpicture}[] 3 | \def\nodedist{30pt} 4 | \def\layerdist{70pt} 5 | 6 | \tikzstyle{every pin edge}=[signal] 7 | \tikzstyle{annot} = [text width=4em, text centered] 8 | 9 | \foreach \y in {1,...,16} 10 | \node[inputnode] 11 | (I\y) at (0,-\y*\nodedist) {$x_{\y}$}; 12 | 13 | \foreach \y in {1,...,16} 14 | \node[hiddennode] 15 | (H1\y) at (\layerdist,-\y*\nodedist) {$z_{\y}^{1}$}; 16 | 17 | \foreach \y in {1,...,8} 18 | \node[hiddennode] 19 | (H2\y) at (2*\layerdist,-\y*2*\nodedist) {$z_{\y}^{2}$}; 20 | 21 | \foreach \y in {1,...,6} 22 | \node[hiddennode] 23 | (H3\y) at (3*\layerdist,-\y*2*\nodedist-2*\nodedist) {$z_{\y}^{3}$}; 24 | 25 | \foreach \y in {1,...,6} 26 | \node[hiddennode] 27 | (H4\y) at (4*\layerdist,-\y*2*\nodedist-2*\nodedist) {$z_{\y}^{4}$}; 28 | 29 | \foreach \y in {1,...,6} 30 | \node[outputnode] 31 | (O\y) at (5*\layerdist,-\y*2*\nodedist-2*\nodedist) {$y_{\y}$}; 32 | 33 | \foreach \dest in {1,...,16} 34 | \draw[signal, violet] (I\dest) -- (H1\dest); 35 | \foreach \dest [count=\source from 1] in {2,...,16} 36 | \draw[signal, teal] (I\source) -- (H1\dest); 37 | \foreach \dest [count=\source from 2] in {1,...,15} 38 | \draw[signal, brown] (I\source) -- (H1\dest); 39 | 40 | \foreach \dest [evaluate=\dest as \source using int(\dest*2)] in {1,...,8} 41 | \draw[signal, red,] (H1\source) -- (H2\dest); 42 | \foreach \dest [evaluate=\dest as \source using int(\dest*2-1)] in {1,...,8} 43 | \draw[signal, green] (H1\source) -- (H2\dest); 44 | \foreach \dest [evaluate=\dest as \source using int(\dest*2+1)] in {1,...,7} 45 | \draw[signal, blue] (H1\source) -- (H2\dest); 46 | 47 | \foreach \dest in {1,...,6} 48 | \draw[signal, cyan] (H2\dest) -- (H3\dest); 49 | \foreach \dest [count=\source from 3] in {1,...,6} 50 | \draw[signal, orange] (H2\source) -- (H3\dest); 51 | \foreach \dest [count=\source from 2] in {1,...,6} 52 | \draw[signal, lime] (H2\source) -- (H3\dest); 53 | 54 | \foreach \dest in {1,...,6} 55 | \draw[signal, magenta] (H3\dest) -- (H4\dest); 56 | \foreach \dest [count=\source from 2] in {1,...,5} 57 | \draw[signal, violet] (H3\source) -- (H4\dest); 58 | \foreach \dest [count=\source from 1] in {2,...,6} 59 | \draw[signal, pink] (H3\source) -- (H4\dest); 60 | 61 | \foreach \dest in {1,...,6} 62 | \foreach \source in {1,...,6} 63 | \draw[signal] (H4\source) -- (O\dest); 64 | \end{tikzpicture} 65 | -------------------------------------------------------------------------------- /network_cnn_stide2.tex: -------------------------------------------------------------------------------- 1 | % CNN with sdide 2 | \begin{tikzpicture}[] 3 | \def\nodedist{30pt} 4 | \def\layerdist{70pt} 5 | 6 | \tikzstyle{every pin edge}=[signal] 7 | \tikzstyle{annot} = [text width=4em, text centered] 8 | 9 | \foreach \y in {1,...,14} 10 | \node[inputnode] 11 | (I\y) at (0,-\y*\nodedist) {$x_{\y}$}; 12 | 13 | \foreach \y in {1,...,14} 14 | \node[hiddennode] 15 | (H1\y) at (\layerdist,-\y*\nodedist) {$z_{\y}^{1}$}; 16 | 17 | \foreach \y in {1,...,7} 18 | \node[hiddennode] 19 | (H2\y) at (2*\layerdist,-\y*2*\nodedist) {$z_{\y}^{2}$}; 20 | 21 | \foreach \y in {1,...,5} 22 | \node[hiddennode] 23 | (H3\y) at (3*\layerdist,-\y*2*\nodedist-2*\nodedist) {$z_{\y}^{3}$}; 24 | 25 | \foreach \y in {1,...,5} 26 | \node[hiddennode] 27 | (H4\y) at (4*\layerdist,-\y*2*\nodedist-2*\nodedist) {$z_{\y}^{4}$}; 28 | 29 | \foreach \y in {1,...,5} 30 | \node[outputnode] 31 | (O\y) at (5*\layerdist,-\y*2*\nodedist-2*\nodedist) {$y_{\y}$}; 32 | 33 | \foreach \dest in {1,...,14} 34 | \draw[signal, violet] (I\dest) -- (H1\dest); 35 | \foreach \dest [count=\source from 1] in {2,...,14} 36 | \draw[signal, teal] (I\source) -- (H1\dest); 37 | \foreach \dest [count=\source from 2] in {1,...,13} 38 | \draw[signal, brown] (I\source) -- (H1\dest); 39 | 40 | \foreach \dest [evaluate=\dest as \source using int(\dest*2)] in {1,...,7} 41 | \draw[signal, red,] (H1\source) -- (H2\dest); 42 | \foreach \dest [evaluate=\dest as \source using int(\dest*2-1)] in {1,...,7} 43 | \draw[signal, green] (H1\source) -- (H2\dest); 44 | \foreach \dest [evaluate=\dest as \source using int(\dest*2+1)] in {1,...,6} 45 | \draw[signal, blue] (H1\source) -- (H2\dest); 46 | 47 | \foreach \dest in {1,...,5} 48 | \draw[signal, cyan] (H2\dest) -- (H3\dest); 49 | \foreach \dest [count=\source from 3] in {1,...,5} 50 | \draw[signal, orange] (H2\source) -- (H3\dest); 51 | \foreach \dest [count=\source from 2] in {1,...,5} 52 | \draw[signal, lime] (H2\source) -- (H3\dest); 53 | 54 | \foreach \dest in {1,...,5} 55 | \draw[signal, magenta] (H3\dest) -- (H4\dest); 56 | \foreach \dest [count=\source from 2] in {1,...,4} 57 | \draw[signal, violet] (H3\source) -- (H4\dest); 58 | \foreach \dest [count=\source from 1] in {2,...,5} 59 | \draw[signal, pink] (H3\source) -- (H4\dest); 60 | 61 | \foreach \dest in {1,...,5} 62 | \foreach \source in {1,...,5} 63 | \draw[signal] (H4\source) -- (O\dest); 64 | 65 | % receptive field 66 | \draw [fill=blue, draw=red, fill opacity=0.2, draw opacity=1.0, line width=1.4pt] 67 | ($(I4) +(-14pt,+21pt)$) -- ($(H23) +(-14pt,+21pt)$) -- ($(H23) +(-14pt,-21pt)$) -- ($(I8) +(-14pt,-21pt)$) -- cycle; 68 | 69 | \end{tikzpicture} 70 | -------------------------------------------------------------------------------- /network_init.tex: -------------------------------------------------------------------------------- 1 | \usetikzlibrary{shapes,arrows,positioning,calc,chains,scopes} 2 | 3 | % colors 4 | \definecolor{snowymint}{HTML}{E3F8D1} 5 | \definecolor{wepeep}{HTML}{FAD2D2} 6 | \definecolor{portafino}{HTML}{F5EE9D} 7 | \definecolor{plum}{HTML}{DCACEF} 8 | \definecolor{sail}{HTML}{A3CEEE} 9 | \definecolor{highland}{HTML}{6D885A} 10 | 11 | \tikzstyle{signal}=[arrows={-latex},draw=black,line width=1.5pt,rounded corners=4pt] 12 | 13 | % RNN 14 | \tikzstyle{block}=[draw=black,line width=1.0pt] 15 | \tikzstyle{cell}=[style=block,draw=highland,fill=snowymint, 16 | rounded corners] 17 | \tikzstyle{celllayer}=[style=block,draw,fill=portafino, 18 | inner sep=1pt,outer sep=0, 19 | minimum width=28pt, minimum height=14pt] 20 | \tikzstyle{pointwise}=[style=block,ellipse,fill=wepeep, 21 | inner sep=1pt,outer sep=0, minimum size=12pt] 22 | 23 | \def\iolen{24pt} 24 | \def\intergape{2pt} 25 | 26 | % MLP and CNN 27 | \tikzstyle{netnode}=[circle, inner sep=0pt, text width=22pt, align=center, line width=1.0pt] 28 | \tikzstyle{inputnode}=[netnode, fill=sail,draw=black] 29 | \tikzstyle{hiddennode}=[netnode, fill=snowymint,draw=black] 30 | \tikzstyle{outputnode}=[netnode, fill=plum,draw=black] 31 | 32 | % Architecture 33 | \def\layerwidth{90pt} 34 | \def\layerheight{14pt} 35 | 36 | \tikzstyle{layer}=[style=block, draw, fill=black!20!white, 37 | inner sep=1pt,outer sep=0, font=\footnotesize, 38 | text centered, 39 | minimum width=\layerwidth, minimum height=\layerheight] 40 | 41 | \tikzstyle{fc}=[style=layer, fill=blue!30!white] 42 | \tikzstyle{conv}=[style=layer, fill=green!30!white] 43 | \tikzstyle{activation}=[style=layer, fill=orange!30!white] 44 | \tikzstyle{pool}=[style=layer, fill=red!30!white] 45 | \tikzstyle{bn}=[style=layer, fill=cyan!30!white] 46 | \tikzstyle{recurrent}=[style=layer, fill=purple!30!white] 47 | \tikzstyle{softmax}=[style=layer, fill=yellow!30!white] 48 | \tikzstyle{point}=[] 49 | \tikzstyle{branch}=[coordinate] 50 | 51 | \def\vlayerwidth{30pt} 52 | \def\vlayerheight{3pt} 53 | \def\vblockheight{28pt} 54 | 55 | \tikzstyle{vlayer}=[minimum width=\vlayerwidth, minimum height=\vlayerheight] 56 | \tikzstyle{vblock}=[minimum width=\vlayerwidth, minimum height=\vblockheight, text width=1cm, align=center] 57 | 58 | 59 | % Precision, Recall 60 | \colorlet{fn}{gray!90!green!30!white} 61 | \colorlet{tp}{green!40!white} 62 | \colorlet{fp}{red!40!white} 63 | \colorlet{tn}{gray!90!red!20!white} -------------------------------------------------------------------------------- /network_layer_conv.tex: -------------------------------------------------------------------------------- 1 | % Convolutional layer 2 | \begin{tikzpicture}[] 3 | \def\nodedist{30pt} 4 | \def\layerdist{70pt} 5 | 6 | \tikzstyle{every pin edge}=[signal] 7 | \tikzstyle{annot} = [text width=4em, text centered] 8 | 9 | \foreach \y in {1,...,6} 10 | \node[hiddennode] 11 | (H1\y) at ($(\layerdist,-\y*\nodedist) +(0, 0.5*\nodedist)$) {$z_\y$}; 12 | 13 | \foreach \y in {1,...,6} 14 | \node[hiddennode] 15 | (H2\y) at ($(2*\layerdist,-\y*\nodedist) +(0, 0.5*\nodedist)$) {$z_\y$}; 16 | 17 | \foreach \dest in {1,...,6} 18 | \draw[signal, red, dashed] (H1\dest) -- (H2\dest); 19 | 20 | \foreach \x [count=\xx from 1] in {2,...,6} 21 | \draw[signal, green, dashed] (H1\xx) -- (H2\x); 22 | 23 | \foreach \x [count=\xx from 2] in {1,...,5} 24 | \draw[signal, blue, dashed] (H1\xx) -- (H2\x); 25 | \end{tikzpicture} 26 | -------------------------------------------------------------------------------- /network_layer_fc.tex: -------------------------------------------------------------------------------- 1 | % Fully connected layer 2 | \begin{tikzpicture}[] 3 | \def\nodedist{30pt} 4 | \def\layerdist{70pt} 5 | 6 | \tikzstyle{every pin edge}=[signal] 7 | \tikzstyle{annot} = [text width=4em, text centered] 8 | 9 | \foreach \y in {1,...,6} 10 | \node[hiddennode] 11 | (H1\y) at ($(\layerdist,-\y*\nodedist) +(0, 0.5*\nodedist)$) {$z_\y$}; 12 | 13 | \foreach \y in {1,...,6} 14 | \node[hiddennode] 15 | (H2\y) at ($(2*\layerdist,-\y*\nodedist) +(0, 0.5*\nodedist)$) {$z_\y$}; 16 | 17 | \foreach \dest in {1,...,6} 18 | \foreach \source in {1,...,6} 19 | \draw[signal] (H1\source) -- (H2\dest); 20 | \end{tikzpicture} 21 | -------------------------------------------------------------------------------- /network_mlp.tex: -------------------------------------------------------------------------------- 1 | % MLP 2 | \begin{tikzpicture}[] 3 | \def\nodedist{35pt} 4 | \def\layerdist{80pt} 5 | \def\pindist{20pt} 6 | 7 | \tikzstyle{every pin edge}=[signal] 8 | \tikzstyle{annot} = [text width=4em, text centered] 9 | 10 | \foreach \y in {1,...,3} 11 | \node[inputnode, pin={[pin edge={latex-}, pin distance=\pindist]left:Input \y}] 12 | (I\y) at (0,-\y*\nodedist) {$x_\y$}; 13 | 14 | \foreach \y in {1,...,4} 15 | \node[hiddennode] 16 | (H\y) at ($(\layerdist,-\y*\nodedist) +(0, 0.5*\nodedist)$) {$z_\y$}; 17 | 18 | \foreach \y in {1,...,1} 19 | \node[outputnode, pin={[pin edge={-latex}, pin distance=\pindist]right:Output \y}] 20 | (O\y) at ($(I2) + (2*\layerdist, 0)$) {$y_\y$}; 21 | 22 | \foreach \dest in {1,...,4} 23 | \foreach \source in {1,...,3} 24 | \draw[signal] (I\source) -- (H\dest); 25 | 26 | \foreach \dest in {1,...,1} 27 | \foreach \source in {1,...,4} 28 | \draw[signal] (H\source) edge (O\dest); 29 | 30 | \node[annot, above=4pt of H1] (hl) {Hidden layer}; 31 | \node[annot] at (I1 |- hl) {Input layer}; 32 | \node[annot] at (O1 |- hl) {Output layer}; 33 | \end{tikzpicture} 34 | -------------------------------------------------------------------------------- /network_mlp2.tex: -------------------------------------------------------------------------------- 1 | % MLP 2 hidden layers 2 | \begin{tikzpicture}[] 3 | \def\nodedist{35pt} 4 | \def\layerdist{80pt} 5 | \def\pindist{20pt} 6 | 7 | \tikzstyle{every pin edge}=[signal] 8 | \tikzstyle{annot} = [text width=4em, text centered] 9 | 10 | \foreach \y in {1,...,3} 11 | \node[inputnode, pin={[pin edge={latex-}, pin distance=\pindist]left:Input \y}] 12 | (I\y) at (0,-\y*\nodedist) {$x_\y$}; 13 | 14 | \foreach \y in {1,...,4} 15 | \node[hiddennode] 16 | (H1\y) at ($(\layerdist,-\y*\nodedist) +(0, 0.5*\nodedist)$) {$z_\y^1$}; 17 | 18 | \foreach \y in {1,...,4} 19 | \node[hiddennode] 20 | (H2\y) at ($(2*\layerdist,-\y*\nodedist) +(0, 0.5*\nodedist)$) {$z_\y^2$}; 21 | 22 | \foreach \y in {1,...,2} 23 | \node[outputnode, pin={[pin edge={-latex}, pin distance=\pindist]right:Output \y}] 24 | (O\y) at ($(H21) + (\layerdist, -\y*\nodedist)$) {$y_\y$}; 25 | 26 | \foreach \dest in {1,...,4} 27 | \foreach \source in {1,...,3} 28 | \draw[signal] (I\source) -- (H1\dest); 29 | 30 | \foreach \dest in {1,...,4} 31 | \foreach \source in {1,...,4} 32 | \draw[signal] (H1\source) -- (H2\dest); 33 | 34 | \foreach \dest in {1,...,2} 35 | \foreach \source in {1,...,4} 36 | \draw[signal] (H2\source) edge (O\dest); 37 | 38 | \node[annot, above=4pt of H11] (hl) {Hidden layer 1}; 39 | \node[annot, above=4pt of H21] (hl) {Hidden layer 2}; 40 | \node[annot] at (I1 |- hl) {Input layer}; 41 | \node[annot] at (O1 |- hl) {Output layer}; 42 | \end{tikzpicture} 43 | -------------------------------------------------------------------------------- /network_unfolding.tex: -------------------------------------------------------------------------------- 1 | % unfolding 2 | \begin{tikzpicture} 3 | \def\nodedist{64pt} 4 | 5 | \newcommand{\timestep}[2]{ 6 | \node[block, fill=snowymint, rounded corners, minimum width=40pt, minimum height=24pt] (a#2) at #1 {A}; 7 | \node[inputnode, below=26pt of a#2] (x#2) {$x_#2$}; 8 | \node[outputnode, above=26pt of a#2] (h#2) {$h_#2$}; 9 | \draw[signal] (x#2) -- (a#2); 10 | \draw[signal] (a#2) -- (h#2); 11 | } 12 | 13 | \timestep{(0, 0)}{t}; 14 | \coordinate (0t) at ($(ht)!0.6!(at)$); 15 | \draw[signal, -, shorten >=\intergape] (at) -- +(40pt,0pt) |- (0t); 16 | \draw[signal, latex-, shorten >=\intergape] (at) -- +(-40pt,0pt) |- (0t); 17 | 18 | \node[] (e) at ($(at) +(\nodedist,0)$) {\LARGE=}; 19 | 20 | \timestep{($(e) +(0.7*\nodedist,0)$)}{0}; 21 | \timestep{($(a0) +(\nodedist,0)$)}{1}; 22 | \draw[signal] (a0) -- (a1); 23 | \timestep{($(a1) +(\nodedist,0)$)}{2}; 24 | \draw[signal] (a1) -- (a2); 25 | \timestep{($(a2) +(\nodedist,0)$)}{3}; 26 | \draw[signal] (a2) -- (a3); 27 | 28 | \node[] at ($(a3) +(0.6*\nodedist,0)$) (ddd) {$\dots$}; 29 | \timestep{($(ddd) +(0.7*\nodedist,0)$)}{t}; 30 | \draw[signal, -] (a3) -- (ddd); 31 | \draw[signal] (ddd) -- (at); 32 | \end{tikzpicture} 33 | -------------------------------------------------------------------------------- /pooling_2.tex: -------------------------------------------------------------------------------- 1 | % pooling, kernel (3,3), stride (2,2) 2 | \begin{tikzpicture} 3 | \coordinate (p) at (0,0); 4 | \draw[ 5 | ultra thick, 6 | step=1, 7 | color=black, 8 | draw=black, 9 | fill=black!20!white, 10 | shift={(p)} 11 | ] (0,0) grid (5,-5) rectangle (0,0) 12 | foreach[count=~] \l in {90, 15, 19, 36, 85, 13, 55, 31, 42, 23, 41, 11, 11, 57, 58, 67, 89, 87, 83, 49, 2, 11, 19, 32, 91} { 13 | ({0.5+mod(~-1,5}, {-0.5-div(~-1,5}) node {\Large \l} 14 | }; 15 | \draw[shift={(p)}, draw=red, ultra thick] (0,0) rectangle (3,-3); 16 | 17 | \coordinate (p) at (6.5,-1.5); 18 | \draw[ 19 | ultra thick, 20 | step=1, 21 | color=black, 22 | draw=black, 23 | fill=black!20!white, 24 | shift={(p)} 25 | ] (0,0) grid (2,-2) rectangle (0,0) 26 | foreach[count=~] \l in {90, 85, 89, 91} { 27 | ({0.5+mod(~-1,2}, {-0.5-div(~-1,2}) node {\Large \l} 28 | }; 29 | \draw[shift={(p)}, draw=red, ultra thick] (0,0) rectangle (1,-1); 30 | % max {90, 85, 89, 91} 31 | % average {32, 40, 38, 54} 32 | \end{tikzpicture} 33 | -------------------------------------------------------------------------------- /pooling_average.tex: -------------------------------------------------------------------------------- 1 | % average pooling, kernel (2,2), stride (2,2) 2 | \begin{tikzpicture} 3 | \coordinate (p) at (0,0); 4 | \draw[shift={(p)}, fill=red!20!white] (0,0) rectangle (2,-2); 5 | \draw[shift={(p)}, fill=yellow!20!white] (2,0) rectangle (4,-2); 6 | \draw[shift={(p)}, fill=blue!20!white] (0,-2) rectangle (2,-4); 7 | \draw[shift={(p)}, fill=green!20!white] (2,-2) rectangle (4,-4); 8 | \draw[ 9 | ultra thick, 10 | step=1, 11 | color=black, 12 | draw=black, 13 | fill=black!20!white, 14 | shift={(p)} 15 | ] (0,0) grid (4,-4) 16 | foreach[count=~] \l in {73, 74, 17, 49, 10, 29, 41, 20, 4, 23, 39, 4, 50, 80, 56, 57} { 17 | ({0.5+mod(~-1,4}, {-0.5-div(~-1,4}) node {\Large \l} 18 | }; 19 | 20 | \draw[signal] (4.5,-2) -> (5.5, -2); 21 | 22 | \coordinate (p) at (6,-1); 23 | \draw[shift={(p)}, fill=red!20!white] (0,0) rectangle (1,-1); 24 | \draw[shift={(p)}, fill=yellow!20!white] (1,0) rectangle (2,-1); 25 | \draw[shift={(p)}, fill=blue!20!white] (0,-1) rectangle (1,-2); 26 | \draw[shift={(p)}, fill=green!20!white] (1,-1) rectangle (2,-2); 27 | \draw[ 28 | ultra thick, 29 | step=1, 30 | color=black, 31 | draw=black, 32 | fill=black!20!white, 33 | shift={(p)} 34 | ] (0,0) grid (2,-2) 35 | foreach[count=~] \l in {46, 32, 39, 39} { 36 | ({0.5+mod(~-1,2}, {-0.5-div(~-1,2}) node {\Large \l} 37 | }; 38 | \end{tikzpicture} 39 | -------------------------------------------------------------------------------- /pooling_both.tex: -------------------------------------------------------------------------------- 1 | % max and average pooling, kernel (2,2), stride (2,2) 2 | 3 | \begin{tikzpicture} 4 | \coordinate (p) at (0,0); 5 | \draw[shift={(p)}, fill=red!20!white] (0,0) rectangle (2,-2); 6 | \draw[shift={(p)}, fill=yellow!20!white] (2,0) rectangle (4,-2); 7 | \draw[shift={(p)}, fill=blue!20!white] (0,-2) rectangle (2,-4); 8 | \draw[shift={(p)}, fill=green!20!white] (2,-2) rectangle (4,-4); 9 | \draw[ 10 | ultra thick, 11 | step=1, 12 | color=black, 13 | draw=black, 14 | fill=black!20!white, 15 | shift={(p)} 16 | ] (0,0) grid (4,-4) 17 | foreach[count=~] \l in {73, 74, 17, 49, 10, 29, 41, 20, 4, 23, 39, 4, 50, 80, 56, 57} { 18 | ({0.5+mod(~-1,4}, {-0.5-div(~-1,4}) node {\Large \l} 19 | }; 20 | 21 | % max pooling 22 | \coordinate (p) at (7,0.5); 23 | \draw[shift={(p)}, fill=red!20!white] (0,0) rectangle (1,-1); 24 | \draw[shift={(p)}, fill=yellow!20!white] (1,0) rectangle (2,-1); 25 | \draw[shift={(p)}, fill=blue!20!white] (0,-1) rectangle (1,-2); 26 | \draw[shift={(p)}, fill=green!20!white] (1,-1) rectangle (2,-2); 27 | \draw[ 28 | ultra thick, 29 | step=1, 30 | color=black, 31 | draw=black, 32 | fill=black!20!white, 33 | shift={(p)} 34 | ] (0,0) grid (2,-2) 35 | foreach[count=~] \l in {74, 49, 80, 57} { 36 | ({0.5+mod(~-1,2}, {-0.5-div(~-1,2}) node {\Large \l} 37 | }; 38 | \draw[signal] (4.5,-1.5) -> ($(p) +(-0.5, -1.25)$); 39 | \node[text width=200pt, align=center, right of=p, yshift=10pt] (l1) {Max Pooling}; 40 | 41 | % average pooling 42 | \coordinate (p) at (7,-2.5); 43 | \draw[shift={(p)}, fill=red!20!white] (0,0) rectangle (1,-1); 44 | \draw[shift={(p)}, fill=yellow!20!white] (1,0) rectangle (2,-1); 45 | \draw[shift={(p)}, fill=blue!20!white] (0,-1) rectangle (1,-2); 46 | \draw[shift={(p)}, fill=green!20!white] (1,-1) rectangle (2,-2); 47 | \draw[ 48 | ultra thick, 49 | step=1, 50 | color=black, 51 | draw=black, 52 | fill=black!20!white, 53 | shift={(p)} 54 | ] (0,0) grid (2,-2) 55 | foreach[count=~] \l in {46, 32, 39, 39} { 56 | ({0.5+mod(~-1,2}, {-0.5-div(~-1,2}) node {\Large \l} 57 | }; 58 | \draw[signal] (4.5,-2.5) -> ($(p) +(-0.5, -0.75)$); 59 | \node[text width=200pt, align=center, right of=p, yshift=10pt] (l1) {Average Pooling}; 60 | \end{tikzpicture} -------------------------------------------------------------------------------- /pooling_max.tex: -------------------------------------------------------------------------------- 1 | % max pooling, kernel (2,2), stride (2,2) 2 | \begin{tikzpicture} 3 | \coordinate (p) at (0,0); 4 | \draw[shift={(p)}, fill=red!20!white] (0,0) rectangle (2,-2); 5 | \draw[shift={(p)}, fill=yellow!20!white] (2,0) rectangle (4,-2); 6 | \draw[shift={(p)}, fill=blue!20!white] (0,-2) rectangle (2,-4); 7 | \draw[shift={(p)}, fill=green!20!white] (2,-2) rectangle (4,-4); 8 | \draw[ 9 | ultra thick, 10 | step=1, 11 | color=black, 12 | draw=black, 13 | fill=black!20!white, 14 | shift={(p)} 15 | ] (0,0) grid (4,-4) 16 | foreach[count=~] \l in {73, 74, 17, 49, 10, 29, 41, 20, 4, 23, 39, 4, 50, 80, 56, 57} { 17 | ({0.5+mod(~-1,4}, {-0.5-div(~-1,4}) node {\Large \l} 18 | }; 19 | 20 | \draw[signal] (4.5,-2) -> (5.5, -2); 21 | 22 | \coordinate (p) at (6,-1); 23 | \draw[shift={(p)}, fill=red!20!white] (0,0) rectangle (1,-1); 24 | \draw[shift={(p)}, fill=yellow!20!white] (1,0) rectangle (2,-1); 25 | \draw[shift={(p)}, fill=blue!20!white] (0,-1) rectangle (1,-2); 26 | \draw[shift={(p)}, fill=green!20!white] (1,-1) rectangle (2,-2); 27 | \draw[ 28 | ultra thick, 29 | step=1, 30 | color=black, 31 | draw=black, 32 | fill=black!20!white, 33 | shift={(p)} 34 | ] (0,0) grid (2,-2) 35 | foreach[count=~] \l in {74, 49, 80, 57} { 36 | ({0.5+mod(~-1,2}, {-0.5-div(~-1,2}) node {\Large \l} 37 | }; 38 | \end{tikzpicture} 39 | -------------------------------------------------------------------------------- /precision.tex: -------------------------------------------------------------------------------- 1 | % precision 2 | 3 | \begin{tikzpicture} 4 | \def\radius{0.5} 5 | \fill[tp] (0,2*\radius+0.2) arc (90:270:\radius); 6 | \fill[tp] (0,-0.2) arc (90:270:\radius); 7 | \fill[fp] (0,-2*\radius-0.2) arc (270:450:\radius); 8 | \draw[signal, -] (-1.5*\radius, 0) -- (1.5*\radius,0); 9 | \end{tikzpicture} 10 | -------------------------------------------------------------------------------- /recall.tex: -------------------------------------------------------------------------------- 1 | % recall 2 | 3 | \begin{tikzpicture} 4 | \def\radius{0.5} 5 | \fill[fn] (0,-0.2) rectangle (-1.5*\radius,-3.0*\radius-0.2); 6 | \fill[tp] (0,2*\radius+0.2) arc (90:270:\radius); 7 | \fill[tp] (0,-0.5*\radius-0.2) arc (90:270:\radius); 8 | \draw[signal, -] (-1.5*\radius, 0) -- (1.5*\radius,0); 9 | \end{tikzpicture} 10 | -------------------------------------------------------------------------------- /sets.tex: -------------------------------------------------------------------------------- 1 | % TP, FP, FN, TN sets 2 | 3 | \begin{tikzpicture} 4 | %\def\radius{3} 5 | \def\radius{80pt} 6 | \def\d{8pt} 7 | 8 | \tikzstyle{annot} = [text width=4em, text centered] 9 | 10 | \fill[fn] (0,-1.5*\radius) rectangle (-1.5*\radius,1.5*\radius); 11 | \fill[tn] (0,-1.5*\radius) rectangle (1.5*\radius,1.5*\radius); 12 | \draw (-1.5*\radius,1.5*\radius) rectangle (1.5*\radius,-1.5*\radius); 13 | 14 | \fill[tp] (0,+\radius) arc (90:270:\radius); 15 | \fill[fp] (0,-\radius) arc (270:450:\radius); 16 | 17 | \draw (0,0) circle (\radius); 18 | \coordinate[pin={[pin edge={latex-, black}, pin distance=0.8*\radius]-25:Detections}] (B) at (-25:\radius); 19 | 20 | \node[annot, text width=100pt, align=center] at (-0.5*\radius,0) {True Positives}; 21 | \node[annot, text width=100pt, align=center] at (0.5*\radius,0) {False Positives}; 22 | 23 | \node[annot, text width=100pt, align=center] at (-0.75*\radius,1.5*\radius-\d*2) {False Negatives}; 24 | \node[annot, text width=100pt, align=center] at (0.75*\radius,1.5*\radius-\d*2) {True Negatives}; 25 | 26 | \node[annot, text width=100pt, align=center] at (-0.75*\radius,1.5*\radius+\d*2) {Text Instances}; 27 | \node[annot, text width=100pt, align=center] at (0.75*\radius,1.5*\radius+\d*2) {Background}; 28 | 29 | \coordinate (p) at (-1.5*\radius+\d/4,1.5*\radius+\d/4); 30 | \draw[shift={(p)}] (0,0) -- (0,\d) -- (1.5*\radius-\d,\d) -- (1.5*\radius-\d,0); 31 | 32 | \coordinate (p) at (\d/4,1.5*\radius+\d/4); 33 | \draw[shift={(p)}] (0,0) -- (0,\d) -- (1.5*\radius-\d,\d) -- (1.5*\radius-\d,0); 34 | 35 | \pgfmathsetseed{10} 36 | \foreach \x in {1,2,...,20}{ 37 | \draw[fill=black!50!white] ({(-1.5*\radius+\d/2)*rnd},{-1.5*\radius+(3.0*\radius-\d*3)*rnd}) circle (0.08); 38 | \draw ({(1.5*\radius-\d/2)*rnd},{-1.5*\radius+(3.0*\radius-\d*3)*rnd}) circle (0.08); 39 | }; 40 | \end{tikzpicture} 41 | -------------------------------------------------------------------------------- /test/test_network.tex: -------------------------------------------------------------------------------- 1 | \documentclass[tikz]{standalone} 2 | %\documentclass[tikz]{article} 3 | 4 | \usepackage{pgfplots} 5 | \usepackage{ifthen} 6 | 7 | \usepackage{amsmath} 8 | \DeclareMathOperator{\sigm}{sigm} 9 | \newcommand{\diff}{\mathop{}\!\mathrm{d}} 10 | 11 | \begin{document} 12 | 13 | \input{../network_init.tex} 14 | \input{../network_cnn_stide2.tex} 15 | \input{../network_cnn_receptivefield.tex} 16 | \input{../model_crnn.tex} 17 | \input{../model_ssd.tex} 18 | \input{../model_dsodsl.tex} 19 | 20 | 21 | \tikzset{ 22 | skip/.style={signal, to path={-- ++(0,-#1) -| (\tikztotarget)}} 23 | } 24 | \tikzset{ 25 | skip/.style={signal, to path={|- ($(\tikztotarget) +(0,#1)$) -- (\tikztotarget)}} 26 | } 27 | % join=by {skip=16pt} 28 | 29 | 30 | \begin{tikzpicture}[thick, node distance=30pt, on grid] 31 | \begin{scope} [start chain=going below, 32 | every node/.style={on chain}, 33 | layer/.append style={join=by {signal}}, 34 | point/.append style={join=by {signal}}, 35 | %every node/.append style={join=by {->,shorten >=-1pt,decoration={post length=4pt}}} 36 | ] 37 | \node[point] (input) {Input}; 38 | \node[bn] {BN}; 39 | \node[activation] {ReLU}; 40 | \node[conv] {weights}; 41 | \node[bn] {BN}; 42 | \node[activation] {ReLU}; 43 | \node[conv] {weights}; 44 | \node[layer] (add) {addition}; 45 | \node[point] {Output}; 46 | \end{scope} 47 | \draw[signal] (input) -- +(\layerwidth/2+30pt,0) |- (add); 48 | \end{tikzpicture} 49 | 50 | 51 | 52 | \def\vblockwidth{30pt} 53 | \def\vlayerwidth{30pt} 54 | \def\vlayerheight{2pt} 55 | 56 | \tikzstyle{vlayer}=[minimum width=\vlayerwidth, minimum height=\vlayerheight, rotate=90] 57 | \tikzstyle{vblock}=[minimum width=\vblockwidth, minimum height=\vlayerwidth, node distance=26pt, on chain, join=by {signal}, text width=1cm, align=center] 58 | 59 | \begin{tikzpicture}[thick, node distance=2pt, on grid] 60 | \begin{scope} [start chain=going right, 61 | every node/.style={on chain}, 62 | %layer/.append style={join=by {signal}}, 63 | %point/.append style={join=by {signal}} 64 | ] 65 | \node[point] {Input}; 66 | \node[conv, vlayer, node distance=26pt, on chain, join=by {signal}] {}; 67 | \node[bn, vlayer] {}; 68 | \node[activation, vlayer] {}; 69 | \node[conv, vlayer] {}; 70 | \node[bn, vlayer] {}; 71 | \node[activation, vlayer] {}; 72 | \node[conv, vlayer] {}; 73 | \node[bn, vlayer] {}; 74 | \node[activation, vlayer] {}; 75 | \node[pool, vlayer] {}; 76 | 77 | \node[layer, vblock] {Dense\\6 48}; 78 | 79 | \node[conv, vlayer, node distance=26pt, on chain, join=by {signal}] {}; 80 | \node[bn, vlayer] {}; 81 | \node[activation, vlayer] {}; 82 | \node[pool, vlayer] {}; 83 | 84 | \node[layer, vblock] {Dense\\8 48}; 85 | 86 | \node[conv, vlayer, node distance=26pt, on chain, join=by {signal}] {}; 87 | \node[bn, vlayer] {}; 88 | \node[activation, vlayer] (n1) {}; 89 | 90 | \end{scope} 91 | 92 | \begin{scope} [start chain=going right, every node/.style={on chain}] 93 | \node[pool, vlayer] (n2) at ($(n1) +(20pt, 0pt)$) {}; 94 | 95 | \node[layer, vblock, node distance=32pt, on chain, join=by {signal}] {Dense\\8 48}; 96 | 97 | \node[conv, vlayer, node distance=26pt, on chain, join=by {signal}] {}; 98 | \node[bn, vlayer] {}; 99 | \node[activation, vlayer] {}; 100 | 101 | \node[layer, vblock] {Dense\\8 48}; 102 | 103 | \node[conv, vlayer, node distance=26pt, on chain, join=by {signal}] (n6) {}; 104 | \node[bn, vlayer] {}; 105 | \node[activation, vlayer] (n3) {}; 106 | \end{scope} 107 | 108 | \begin{scope} [start chain=going right, every node/.style={on chain}] 109 | \node[conv, vlayer] (n4) at ($(n6) +(0pt, 50pt)$) {}; 110 | \node[bn, vlayer] {}; 111 | \node[activation, vlayer] (n5) {}; 112 | \end{scope} 113 | 114 | 115 | \coordinate (n13) at ($(n3) +(12pt, 0pt)$) {}; 116 | \coordinate (n14) at ($(n13) +(50pt, 0pt)$); 117 | \coordinate (n11) at ($(n13) +(-50pt, -0pt)$); 118 | \coordinate (n12) at (n13); 119 | 120 | \draw[signal] (n1) -- (n2); 121 | \draw[signal] (n2) -| +(8pt,8pt) |- (n4); 122 | \draw[signal, -] (n3) -- (n13); 123 | \draw[signal, -] (n5) -| +(8pt,-8pt) |- (n13); 124 | \draw[signal, -] (n1) -| +(8pt, 8pt) |- +(16pt, 100pt) -| (n14); 125 | 126 | \draw[signal, -] (n13) -- (n14); 127 | 128 | \foreach \y in {1,...,4} { 129 | \coordinate (n11) at ($(n11) +(0pt, -100pt)$); 130 | \draw[signal, -] (n12) -| +(8pt,-8pt) |- +(-60pt, -30pt) |- (n11); 131 | \coordinate (n12) at ($(n11) +(50pt, 0pt)$); 132 | 133 | \begin{scope} [start chain=going right, every node/.style={on chain}] 134 | \node[pool, vlayer] (n7) at ($(n11) +(32pt, +40pt)$) {}; 135 | \node[bn, vlayer] {}; 136 | \node[activation, vlayer] {}; 137 | \node[conv, vlayer] (n8) {}; 138 | \end{scope} 139 | 140 | \begin{scope} [start chain=going right, every node/.style={on chain}] 141 | \node[bn, vlayer] (n9) at ($(n11) +(32pt-2*\vlayerheight, 0pt)$) {}; 142 | \node[activation, vlayer] {}; 143 | \node[conv, vlayer] {}; 144 | \node[bn, vlayer] {}; 145 | \node[activation, vlayer] {}; 146 | \node[conv, vlayer] (n10) {}; 147 | \end{scope} 148 | 149 | \draw[signal] (n11) -| +(16pt,+8pt) |- (n7); 150 | \draw[signal] (n11) -- (n9); 151 | \draw[signal, -] (n8) -| +(8pt,-8pt) |- (n12); 152 | \draw[signal, -] (n10) -- (n12); 153 | 154 | \draw[signal, -] (n12) -| (n14); 155 | 156 | } 157 | \end{tikzpicture} 158 | 159 | 160 | \end{document} 161 | --------------------------------------------------------------------------------