Skip to content

Instantly share code, notes, and snippets.

@rinx
Created January 15, 2017 10:04
Show Gist options
  • Save rinx/d278669fddbf75159f33cbed498ca0c0 to your computer and use it in GitHub Desktop.
Save rinx/d278669fddbf75159f33cbed498ca0c0 to your computer and use it in GitHub Desktop.
TikZでCNNの図を描くやつ
\begin{figure}[htbp]
\centering
\tikzset{%
every channel/.style={
rectangle,
draw,
draw=black,
fill=white,
minimum size=1cm,
},
every neuron/.style={
circle,
draw,
minimum size=0.25cm
},
}
\begin{tikzpicture}[>=stealth]
\foreach \m [count=\y from 0] in {1,2,3,4}
\node [every channel/.try] (input-\m) at (0.5-0.25*\y, 1.0-0.25*\y) {};
\foreach \m [count=\y from 0] in {1,2,3,4,5,6,7,8}
\node [every channel/.try, minimum size=0.5cm] (hidden1-\m) at (4.0 - 0.25*\y, 1.5 - 0.25*\y) {};
\foreach \m [count=\y from 0] in {1,2,3,4,5,6,7,8}
\node [every neuron/.try, neuron \m/.try] (hidden2-\m) at (6.0, 2.5 - 0.5*\y) {};
\foreach \m [count=\y from 0] in {1,2,3,4}
\node [every neuron/.try, neuron \m/.try] (hidden3-\m) at (9.0, 1.5 - 0.5*\y) {};
\foreach \i in {1,3,6,8}
\foreach \j in {1,...,4}
\draw [->] (hidden2-\i) -- (hidden3-\j);
\draw [->] (1.2, 0.5) -- ++ (1.0, 0.0);
\node [align=center, above] at (1.8, 0.5) {\footnotesize conv.};
\draw [->] (4.0, 0.5) -- ++ (1.5, 0.0);
\node [align=center, below] at (4.75, 0.5) {\footnotesize fully-connected};
\foreach \l [count=\x from 0] in {Input, Hidden, Hidden, Output}
\node [align=center, above] at (\x * 3.0, 2.8) {\l \\ layer};
\end{tikzpicture}
\caption[CNNの模式図]{CNNの模式図.この例では出力側の2層には全結合層を用いている.}
\label{fig:schematic_diagram_CNN}
\end{figure}
@rinx
Copy link
Author

rinx commented Jan 15, 2017

2017-01-15 19 05 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment