phd-thesis-en/figures/cnn-synapses.tikz
2017-07-08 17:42:46 +02:00

100 lines
4.5 KiB
Text

\documentclass[crop,tikz]{standalone}
\input{common-headers}
\usetikzlibrary{circuits.logic.CDH}
\usetikzlibrary{decorations.markings}
\usepackage{ifthen}
\newcommand{\gimmelegs}[1]{%
\draw[black!50,densely dash dot] (#1.east) -- +( 4mm,0cm);
\draw (#1.input 1) -- +(-4mm,0cm);
\draw[black!50,densely dash dot] (#1.input 2) -- +(-4mm,0cm);
\ifthenelse{\equal{\detokenize{#1}}{\detokenize{cell}}}{}{%
\node[xshift=-3mm,fill,circle,inner sep=1pt] (in#1) at (#1.input 1) {};
}
}
\begin{document}
% Sum inputs
\begin{tikzpicture}[circuit logic CDH, node distance=20mm]
\node (cell) [and gate,fill=black!50] {}; \gimmelegs{cell}
\node (celle) [and gate,right=of cell] {}; \gimmelegs{celle}
\node (cellse) [and gate,below=of celle] {}; \gimmelegs{cellse}
\node (cells) [and gate,below=of cell] {}; \gimmelegs{cells}
\node (cellsw) [and gate,left=of cells] {}; \gimmelegs{cellsw}
\node (cellw) [and gate,left=of cell] {}; \gimmelegs{cellw}
\node (cellnw) [and gate,above=of cellw] {}; \gimmelegs{cellnw}
\node (celln) [and gate,above=of cell] {}; \gimmelegs{celln}
\node (cellne) [and gate,above=of celle] {}; \gimmelegs{cellne}
\node[white,fill=black,circle,inner sep=1pt]
(hub) at (barycentric cs:cell=1,cellnw=1) {$\sum$};
\begin{scope}[decoration={markings,mark=at position 0.5 with {\arrow{Stealth}}}]
% Let's go to the hub
\draw[postaction={decorate},out=-90,in=130] (incellnw) to (hub);
\draw[postaction={decorate},out=-90,in=90] (incelln) to (hub);
\draw[postaction={decorate},out=-90,in=40] (incellne) to (hub);
\draw[postaction={decorate},out=90 ,in=10,looseness=0.5] (incelle) to (hub);
\draw[postaction={decorate},out=90 ,in=-20] (incellse) to (hub);
\draw[postaction={decorate},out=90 ,in=160] (incellw) to (hub);
\draw[postaction={decorate},out=90 ,in=200,looseness=1.5] (incellsw) to (hub);
\draw[postaction={decorate},out=90 ,in=-120] (incells) to (hub);
% Then feedback my cell
\draw[postaction={decorate},thick,out=-70 ,in=90] (hub) to (cell.north);
\end{scope}
\begin{scope}[on background layer]
\draw[thin] ($ (cell.center) + (-4cm,-3.5cm) $)
rectangle ($ (cell.center) + ( 4cm, 3.5cm) $);
\end{scope}
\end{tikzpicture}
\renewcommand{\gimmelegs}[1]{%
\draw (#1.east) -- +(4mm,0cm);
\draw[black!50,densely dash dot] (#1.input 1) -- +(-4mm,0cm);
\draw[black!50,densely dash dot] (#1.input 2) -- +(-4mm,0cm);
\ifthenelse{\equal{\detokenize{#1}}{\detokenize{cell}}}{}{%
\node[xshift=2mm,fill,circle,inner sep=1pt] (out#1) at (#1.output) {};
}
}
% Sum outputs
\begin{tikzpicture}[circuit logic CDH, node distance=20mm]
\node (cell) [and gate,fill=black!50] {}; \gimmelegs{cell}
\node (celle) [and gate,right=of cell] {}; \gimmelegs{celle}
\node (cellse) [and gate,below=of celle] {}; \gimmelegs{cellse}
\node (cells) [and gate,below=of cell] {}; \gimmelegs{cells}
\node (cellsw) [and gate,left=of cells] {}; \gimmelegs{cellsw}
\node (cellw) [and gate,left=of cell] {}; \gimmelegs{cellw}
\node (cellnw) [and gate,above=of cellw] {}; \gimmelegs{cellnw}
\node (celln) [and gate,above=of cell] {}; \gimmelegs{celln}
\node (cellne) [and gate,above=of celle] {}; \gimmelegs{cellne}
\node[white,fill=black,circle,inner sep=1pt]
(hub) at (barycentric cs:cell=1,cellne=1) {$\sum$};
\begin{scope}[decoration={markings,mark=at position 0.5 with {\arrow{Stealth}}}]
% Let's go to the hub
\draw[postaction={decorate},out=-90,in=130] (outcellnw) to (hub);
\draw[postaction={decorate},out=-90,in=90] (outcelln) to (hub);
\draw[postaction={decorate},out=-90,in=40] (outcellne) to (hub);
\draw[postaction={decorate},out=90 ,in=10] (outcelle) to (hub);
\draw[postaction={decorate},out=90 ,in=-80,looseness=1.5] (outcellse) to (hub);
\draw[postaction={decorate},out=90 ,in=160] (outcellw) to (hub);
\draw[postaction={decorate},out=90 ,in=200,looseness=1.2] (outcellsw) to (hub);
\draw[postaction={decorate},out=90 ,in=-100] (outcells) to (hub);
% Then feedback my cell
\draw[postaction={decorate},thick,out=-120 ,in=90] (hub) to (cell.north);
\end{scope}
\begin{scope}[on background layer]
\draw[thin] ($ (cell.center) + (-4cm,-3.5cm) $)
rectangle ($ (cell.center) + ( 4cm, 3.5cm) $);
\end{scope}
\end{tikzpicture}
\end{document}