cnn.tex (1107B)
1 \begin{tikzpicture} 2 \foreach \n in {-2,-1,0,1,2}{ 3 \pgfmathsetmacro\xfocus{ifthenelse(\n>-2 && \n<2, 1, \transparencyDefault)} 4 \pgfmathsetmacro\ofocus{ifthenelse(\n==0, 1, \transparencyDefault)} 5 6 \ifnum\n=0 \def\t{t} 7 \else\ifnum\n<0 \def\t{t\n} 8 \else \def\t{t+\n} 9 \fi\fi 10 11 \node[opacity=\xfocus] (x\n) at ($(10mm*\n, 0mm)$) {\(\vctr{x}_{\t}\)}; 12 \node[draw,opacity=\ofocus] (conv\n) at ($(10mm*\n, 10mm)$) {Conv}; 13 \node[opacity=\ofocus] (h\n) at ($(10mm*\n, 18mm)$) {\(h_{\t,i}\)}; 14 } 15 16 \node[draw,minimum width=48.5mm] (pool) at (0mm, 26mm) {Pooling}; 17 18 \foreach \n in {-2,-1,0,1,2}{ 19 \pgfmathsetmacro\ofocus{ifthenelse(\n==0, 1, \transparencyDefault)} 20 \foreach \d in {-1,0,1}{ 21 \pgfmathsetmacro\src{int(\n+\d)} 22 \pgfmathsetmacro\isvalid{int(ifthenelse(\src>=-2 && \src<=2, 1, 0))} 23 \ifnum\isvalid>0 24 \draw[arrow,opacity=\ofocus] (x\src) -- (conv\n); 25 \fi 26 } 27 28 \draw[arrow,opacity=\ofocus] (conv\n) -- (h\n); 29 \draw[arrow,opacity=\ofocus] (h\n) -- (h\n |- pool.south); 30 } 31 32 \node (o) at (0mm, 33mm) {\(o_i\)}; 33 \draw[arrow] (pool) -- (o); 34 \end{tikzpicture}%