commit 96b641bc269c6685a7871b27009f98099ea3941d Author: Haris Iqbal Date: Wed Sep 12 17:13:15 2018 +0200 Initialize diff --git a/examples/HED/HED.pdf b/examples/HED/HED.pdf new file mode 100644 index 0000000..c72a146 Binary files /dev/null and b/examples/HED/HED.pdf differ diff --git a/examples/HED/HED.tex b/examples/HED/HED.tex new file mode 100644 index 0000000..dace597 --- /dev/null +++ b/examples/HED/HED.tex @@ -0,0 +1,107 @@ +\documentclass[border=15pt, multi, tikz]{standalone} +%\usepackage{blocks} +\usepackage{import} +\subimport{../../layers/}{init} +\usetikzlibrary{positioning} + +\newcommand{\midarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw=\edgecolor] (-0.3,0) -- ++(0.3,0);} + +\begin{document} +\begin{tikzpicture} +\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw Layer Blocks +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% conv1_1,conv1_2,pool1 +\pic[shift={(0,0,0)}] at (0,0,0) {ConvReluPool={blockname=crp1,% + numFilters={{"64","64","32"}},height=40,width={2,2},depth=40,zlabel=I}}; +% conv2_1,conv2_2,pool2 +\pic[shift={(2.1,0,0)}] at (crp1-east) {ConvReluPool={blockname=crp2,% + numFilters={{"128","128"}},height=35,width={3,3},depth=35,zlabel=I/2}}; +%% conv3_1,conv3_2,conv3_3,pool3 +\pic[shift={(2,0,0)}] at (crp2-east) {ConvReluPool={blockname=crp3,% + numFilters={{"256","256","256"}},height=30,width={4,4,4},depth=30,zlabel=I/4}}; +%% conv4_1,conv4_2,conv4_3,pool4 +\pic[shift={(1.8,0,0)}] at (crp3-east) {ConvReluPool={blockname=crp4,% + numFilters={{"512","512","512"}},height=23,width={7,7,7},depth=23,zlabel=I/8}}; +%% conv5_1,conv5_2,conv5_3,pool5 +\pic[shift={(1.5,0,0)}] at (crp4-east) {ConvRelu={blockname=crp5,% + numFilters={{"512","512","512"}},height=15,width={7,7,7},depth=15,zlabel=I/16}}; +%% score32 +\pic[shift={(1,0,0)}] at (crp5-east) {Conv={blockname=score32,% + numFilters={{"21","4096"}},height=15,width=1,depth=15,zlabel=I/16}}; + +%% Upsampling Deconv Layer +\pic[shift={(2,0,0)}] at (score32-east) {Deconv={blockname=up32,% + numFilters={{"1","4096"}},height=33,width=1,depth=33,zlabel=}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%Joining with previous streams (fcn-16) +%% score16 +\pic[shift={(0,0,10)}] at (crp5-anchor) {Conv={blockname=score16,% + numFilters={{"1","4096"}},height=20,width=1,depth=20,zlabel=I/8}}; +%% Upsampling Deconv Layer +\pic[shift={(0.5,0,0)}] at (up32-west) {Deconv={blockname=up16,% + numFilters={{"1","4096"}},height=33,width=1,depth=33,zlabel=}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%Joining with previous streams (fcn-8) +%% score8 +\pic[shift={(1,0,14)}] at (crp4-anchor) {Conv={blockname=score8,% + numFilters={{"1","4096"}},height=25,width=1,depth=25,zlabel=I/4}}; + +%% Upsampling Deconv Layer +\pic[shift={(0.5,0,0)}] at (up16-west) {Deconv={blockname=up8,% + numFilters={{"1","4096"}},height=33,width=1,depth=33,zlabel=}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%Joining with previous streams (fcn-4) +%% score8 +\pic[shift={(0,0,18)}] at (crp3-east) {Conv={blockname=score4,% + numFilters={{"1","4096"}},height=30,width=1,depth=30,zlabel=I/2}}; +%% Upsampling Deconv Layer +\pic[shift={(0.5,0,0)}] at (up8-west) {Deconv={blockname=up4,% + numFilters={{"1","4096"}},height=33,width=1,depth=33,zlabel=}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%Joining with previous streams (fcn-2) +%% score8 +\pic[shift={(0,0,22)}] at (crp2-east) {Conv={blockname=score2,% + numFilters={{"1","4096"}},height=33,width=1,depth=33,zlabel=I}}; +%% Upsampling Deconv Layer +\pic[shift={(0.5,0,0)}] at (up4-west) {Deconv={blockname=up2,% + numFilters={{"1","4096"}},height=33,width=1,depth=33,zlabel=I}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Final convolution +\pic[shift={(3,0,0)}] at (up2-east) {Conv={blockname=output,% + numFilters={{"1","4096"}},height=33,width=1,depth=33,zlabel=I}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw connections +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\draw [connection] (crp1-east) -- node {\midarrow} (crp2-west); +\draw [connection] (crp2-east) -- node {\midarrow} (crp3-west); +\draw [connection] (crp3-east) -- node {\midarrow} (crp4-west); +\draw [connection] (crp4-east) -- node {\midarrow} (crp5-west); +\draw [connection] (crp5-east) -- node {\midarrow} (score32-west); +\draw [connection] (score32-east) -- node {\midarrow} (up32-west); + +\path (crp4-east) -- (crp5-west) coordinate[pos=0.4] (between4_5) ; +\draw [connection] (between4_5) -- node {\midarrow} ++(0,0,10) -- node {\midarrow} (score16-west); +\draw [connection] (score16-east) -- node{\midarrow}++(6,0,0)-- node{\midarrow}(up16-out); + +\path (crp3-east) -- (crp4-west) coordinate[pos=0.4] (between3_4) ; +\draw [connection] (between3_4) -- node {\midarrow} ++(0,0,14) -- node {\midarrow} (score8-west); +\draw [connection] (score8-east) -- node{\midarrow}++(11.55,0,0)-- node{\midarrow}(up8-out); + +\path (crp2-east) -- (crp3-west) coordinate[pos=0.4] (between2_3) ; +\draw [connection] (between2_3) -- node {\midarrow} ++(0,0,18) -- node {\midarrow} (score4-west); +\draw [connection] (score4-east) -- node{\midarrow}++(17.3,0,0)-- node{\midarrow}(up4-out); + +\path (crp1-east) -- (crp2-west) coordinate[pos=0.4] (between1_2) ; +\draw [connection] (between1_2) -- node {\midarrow} ++(0,0,22) -- node {\midarrow} (score2-west); +\draw [connection] (score2-east) -- node{\midarrow}++(22.7,0,0)-- node{\midarrow}(up2-out); + +\draw [connection] (up2-east) -- node {\midarrow} (output-west); + +\draw [connection] (output-east) -- node {\midarrow} ++(,0,0); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\end{tikzpicture} +\end{document}\grid diff --git a/examples/SoftmaxLoss/SoftmaxLoss.pdf b/examples/SoftmaxLoss/SoftmaxLoss.pdf new file mode 100644 index 0000000..bd24036 Binary files /dev/null and b/examples/SoftmaxLoss/SoftmaxLoss.pdf differ diff --git a/examples/SoftmaxLoss/SoftmaxLoss.tex b/examples/SoftmaxLoss/SoftmaxLoss.tex new file mode 100644 index 0000000..c9f9ff9 --- /dev/null +++ b/examples/SoftmaxLoss/SoftmaxLoss.tex @@ -0,0 +1,49 @@ +\documentclass[border=15pt, multi, tikz]{standalone} +%\usepackage{blocks} +\usepackage{import} +\subimport{../../layers/}{init} +\usetikzlibrary{positioning} + +\newcommand{\midarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw=\edgecolor] (-0.3,0) -- ++(0.3,0);} +\newcommand{\up}{0.25} +\newcommand{\down}{0.25} +\newcommand{\arrowlength}{4} + +\begin{document} +\begin{tikzpicture} +\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw Layer Blocks +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% conv1_1,conv1_2,pool1 +\pic[shift={(0,0,0)},fill={rgb:blue,1.5;red,3.5;green,3.5;white,5}] at (0,0,0) {GenericSequentialLayer={blockname=crp1,% + numFilters={{" ",""}},height=20,width={7},depth=20, blocklabel=SoftmaxLoss: $E_\mathcal{S}$ ,ylabel= ,zlabel= }}; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw connections +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\draw [connection] (crp1-east)++(0,\up,0) -- node {\midarrow} ++(\arrowlength.0,0) +node [anchor=south east,scale=2.1]{$E_\mathcal{S} [p;\theta]$}; +\draw (crp1-west)++(0,\up,0) coordinate (crp1-west-up); +\draw [connection] (crp1-west-up)++(-\arrowlength,0,0) +node[anchor=south west,scale=2.1]{$p(x^{(t)})$} +-- node {\midarrow} (crp1-west-up); + +\draw [connection] (crp1-west)++(0,-\down,0) -- node {\midarrow} ++(-\arrowlength.0,0) +node[anchor=north west,inner sep = 10, xshift=-25,scale=2.3] +{ + $\frac{\partial L}{\partial E_\mathcal{S}}\frac{\partial E_\mathcal{S}}{\partial p}$ +}; +\draw (crp1-east)++(0,-\down,0) coordinate (crp1-east-down); +\draw [connection] (crp1-east-down)++(\arrowlength,0,0) +node[anchor=north east,inner sep = 10, xshift=25,scale=2.3] +{ + $\frac{\partial L}{\partial E_\mathcal{S}} = \lambda_\mathcal{S}$ +} +-- node {\midarrow} (crp1-east-down); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +\end{tikzpicture} +\end{document} diff --git a/examples/VGG16/vgg16.pdf b/examples/VGG16/vgg16.pdf new file mode 100644 index 0000000..5e83583 Binary files /dev/null and b/examples/VGG16/vgg16.pdf differ diff --git a/examples/VGG16/vgg16.tex b/examples/VGG16/vgg16.tex new file mode 100644 index 0000000..ccd5688 --- /dev/null +++ b/examples/VGG16/vgg16.tex @@ -0,0 +1,57 @@ +\documentclass[border=15pt, multi, tikz]{standalone} +%\usepackage{blocks} +\usepackage{import} +\subimport{../../layers/}{init} +\usetikzlibrary{positioning} + +\newcommand{\midarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw=\edgecolor] (-0.3,0) -- ++(0.3,0);} +\begin{document} +\begin{tikzpicture} +\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw Layer Blocks +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% conv1_1,conv1_2,pool1 +\pic[shift={(0,0,0)}] at (0,0,0) {ConvReluPool={blockname=crp1,% + numFilters={{"64","64","32"}},height=40,width={2,2},depth=40,ylabel=224,zlabel=224}}; +% conv2_1,conv2_2,pool2 +\pic[shift={(2.1,0,0)}] at (crp1-east) {ConvReluPool={blockname=crp2,% + numFilters={{"128","128"}},height=35,width={3,3},depth=35,ylabel=112,zlabel=112}}; +%% conv3_1,conv3_2,conv3_3,pool3 +\pic[shift={(2,0,0)}] at (crp2-east) {ConvReluPool={blockname=crp3,% + numFilters={{"256","256","256"}},height=30,width={4,4,4},depth=30,ylabel=56,zlabel=56}}; +%% conv4_1,conv4_2,conv4_3,pool4 +\pic[shift={(1.8,0,0)}] at (crp3-east) {ConvReluPool={blockname=crp4,% + numFilters={{"512","512","512"}},height=23,width={7,7,7},depth=23,ylabel=28,zlabel=28}}; +%% conv5_1,conv5_2,conv5_3,pool5 +\pic[shift={(1.5,0,0)}] at (crp4-east) {ConvReluPool={blockname=crp5,% + numFilters={{"512","512","512"}},height=15,width={7,7,7},depth=15,ylabel=14,zlabel=14}}; +%% fc6, +\pic[shift={(1.2,0,0)}] at (crp5-east) {FullyConnectedRelu={blockname=fc6,% + numFilters={{"4096","dummy"}},height=10,width={10},depth=10,ylabel=7,zlabel=7}}; +%% fc7 +\pic[shift={(1,0,0)}] at (fc6-east) {FullyConnectedRelu={blockname=fc7,% + numFilters={{"4096","dummy"}},height=3,width={10},depth=3,ylabel= ,zlabel=1 }}; + +%% fc8 +\pic[shift={(1,0,0)}] at (fc7-east) {FullyConnected={blockname=fc8,% + numFilters={{"K","dummy"}},height=3,width=7,depth=3,ylabel=,zlabel=1}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Output +%% Softmax +%\pic[shift={(1,0,0)}] at (elt2-east) {Deconv={blockname=up8,% +% numFilters={{"21","4096"}},height=35,width=1,depth=35,zlabel=I}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw connections +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\draw [connection] (crp1-east) -- node {\midarrow} (crp2-west); +\draw [connection] (crp2-east) -- node {\midarrow} (crp3-west); +\draw [connection] (crp3-east) -- node {\midarrow} (crp4-west); +\draw [connection] (crp4-east) -- node {\midarrow} (crp5-west); +\draw [connection] (crp5-east) -- node {\midarrow} (fc6-west); +\draw [connection] (fc6-east) -- node {\midarrow} (fc7-west); +\draw [connection] (fc7-east) -- node {\midarrow} (fc8-west); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\end{tikzpicture} +\end{document} diff --git a/examples/fcn-DT/fcn-DT.pdf b/examples/fcn-DT/fcn-DT.pdf new file mode 100644 index 0000000..ddba1f9 Binary files /dev/null and b/examples/fcn-DT/fcn-DT.pdf differ diff --git a/examples/fcn-DT/fcn-DT.tex b/examples/fcn-DT/fcn-DT.tex new file mode 100644 index 0000000..d88816c --- /dev/null +++ b/examples/fcn-DT/fcn-DT.tex @@ -0,0 +1,140 @@ +\documentclass[border=15pt, multi, tikz]{standalone} +%\usepackage{blocks} +\usepackage{import} +\subimport{../../layers/}{init} +\usetikzlibrary{positioning} + +\tikzstyle{connection1}=[ultra thick,every node/.style={sloped,allow upside down},draw={rgb:blue,0;red,4;green,2;white,0},opacity=0.7] + +\newcommand{\localmidarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw={rgb:blue,0;red,4;green,2;white,0}] (-0.3,0) -- ++(0.3,0);} + +\begin{document} +\begin{tikzpicture} +\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw ConvNet Layers +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% conv1_1,conv1_2,pool1 +\pic[shift={(0,0,0)}] at (0,0,0) {ConvReluPool={blockname=crp1,% + numFilters={{"64","64","32"}},height=40,width={2,2},depth=40,zlabel=I}}; +% conv2_1,conv2_2,pool2 +\pic[shift={(2.1,0,0)}] at (crp1-east) {ConvReluPool={blockname=crp2,% + numFilters={{"128","128"}},height=35,width={3,3},depth=35,zlabel=I/2}}; +%% conv3_1,conv3_2,conv3_3,pool3 +\pic[shift={(2,0,0)}] at (crp2-east) {ConvReluPool={blockname=crp3,% + numFilters={{"256","256","256"}},height=30,width={4,4,4},depth=30,zlabel=I/4}}; +%% conv4_1,conv4_2,conv4_3,pool4 +\pic[shift={(1.5,0,0)}] at (crp3-east) {ConvReluPool={blockname=crp4,% + numFilters={{"512","512","512"}},height=23,width={7,7,7},depth=23,zlabel=I/8}}; +%% conv5_1,conv5_2,conv5_3,pool5 +\pic[shift={(1.5,0,0)}] at (crp4-east) {ConvReluPool={blockname=crp5,% + numFilters={{"512","512","512"}},height=15,width={7,7,7},depth=15,zlabel=I/16}}; +%% fc6, fc7 +\pic[shift={(1.2,0,0)}] at (crp5-east) {ConvRelu={blockname=cp6_7,% + numFilters={{"4096","4096"}},height=10,width={10,10},depth=10,zlabel=I/32}}; +%% score32 +\pic[shift={(1,0,0)}] at (cp6_7-east) {Conv={blockname=score32,% + numFilters={{"21","4096"}},height=10,width=1,depth=10,zlabel=I/32}}; +%% Upsampling Deconv Layer +\pic[shift={(2,0,0)}] at (score32-east) {Deconv={blockname=up16,% + numFilters={{"21","4096"}},height=40,width=1,depth=40,zlabel=I}}; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw Edge Layers +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% upsampling crp2 x2 +\pic[shift={(-0.75,-8,0)}] at (crp2-anchor) {Deconv={blockname=crp2_upx2,% + numFilters={{"bilinear x2","4096"}},height=7.5,width=7.5,depth=7.5,zlabel=}}; +%% upsampling crp3 x4 +\pic[shift={(-0.75,-8,0)}] at (crp3-anchor) {Deconv={blockname=crp3_upx4,% + numFilters={{"bilinear x4","4096"}},height=7.5,width=7.5,depth=7.5,zlabel=}}; + +%% edge +\pic[shift={(7,-11,0)}] at (crp4-west) {Conv={blockname=edge,% + numFilters={{"1x1 conv","4096"}}, height=30,width=1,depth=30,zlabel=I}}; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Domain Transform Module +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\pic[shift={(5,0,0)},fill={rgb:blue,1;red,2;green,4;white,7}] at (up16-east) {DomainTransform={blockname=diff1,% + numFilters={{"21","4096"}},height=40,width=1,depth=40,zlabel=}}; + +\pic[shift={(2,0,0)},fill={rgb:blue,1;red,2;green,4;white,7}] at (diff1-east) {DomainTransform={blockname=diff2,% + numFilters={{"21","4096"}},height=40,width=1,depth=40,zlabel=}}; + +\pic[shift={(2,0,0)},fill={rgb:blue,1;red,2;green,4;white,7}] at (diff2-east) {DomainTransform={blockname=diff3,% + numFilters={{"21","4096"}},height=40,width=1,depth=40,zlabel=}}; + +\pic[shift={(2,0,0)},fill={rgb:blue,1;red,2;green,4;white,7}] at (diff3-east) {DomainTransform={blockname=diff4,% + numFilters={{"21","4096"}},height=40,width=1,depth=40,zlabel=}}; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Arrows on Domain Transform +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\draw [connection1] (diff1-anchor)+(0,3,3) -- node{ } ++(0,3,-3); +\draw [connection1] (diff1-anchor)+(0,3,3)-- node{\localmidarrow} ++(0,3,2.9); +\draw [connection1] (diff1-anchor)+(0,3,-2.9) -- node{\localmidarrow} ++(0,3,-3); + +\draw [connection1] (diff1-anchor)+(0,2,3) -- node{ } ++(0,2,-3); +\draw [connection1] (diff1-anchor)+(0,2,3)-- node{\localmidarrow} ++(0,2,2.9); +\draw [connection1] (diff1-anchor)+(0,2,-2.9) -- node{\localmidarrow} ++(0,2,-3); +%%%%%%%%%%%%%%%%%% +\draw [connection1] (diff2-anchor)+(0,-3,-3) -- node{ } ++(0,-3,3); +\draw [connection1] (diff2-anchor)+(0,-3,-3)-- node{\localmidarrow} ++(0,-3,-2.9); +\draw [connection1] (diff2-anchor)+(0,-3,2.9) -- node{\localmidarrow} ++(0,-3,3); + +\draw [connection1] (diff2-anchor)+(0,-2,-3) -- node{ } ++(0,-2,3); +\draw [connection1] (diff2-anchor)+(0,-2,-3)-- node{\localmidarrow} ++(0,-2,-2.9); +\draw [connection1] (diff2-anchor)+(0,-2,2.9) -- node{\localmidarrow} ++(0,-2,3); +%%%%%%%%%%%%%%%%%% +\draw [connection1] (diff3-anchor)+(0,3,3) -- node{ } ++(0,-3,3); +\draw [connection1] (diff3-anchor)+(0,3,3)-- node{\localmidarrow} ++(0,2.9,3); +\draw [connection1] (diff3-anchor)+(0,-2.9,3) -- node{\localmidarrow} ++(0,-3,3); + +\draw [connection1] (diff3-anchor)+(0,3,2) -- node{ } ++(0,-3,2); +\draw [connection1] (diff3-anchor)+(0,3,2)-- node{\localmidarrow} ++(0,2.9,2); +\draw [connection1] (diff3-anchor)+(0,-2.9,2) -- node{\localmidarrow} ++(0,-3,2); +%%%%%%%%%%%%%%%%%% +\draw [connection1] (diff4-anchor)+(0,-3,-3) -- node{ } ++(0,3,-3); +\draw [connection1] (diff4-anchor)+(0,-3,-3)-- node{\localmidarrow} ++(0,-2.9,-3); +\draw [connection1] (diff4-anchor)+(0,2.9,-3) -- node{\localmidarrow} ++(0,3,-3); + +\draw [connection1] (diff4-anchor)+(0,-3,-2) -- node{ } ++(0,3,-2); +\draw [connection1] (diff4-anchor)+(0,-3,-2)-- node{\localmidarrow} ++(0,-2.9,-2); +\draw [connection1] (diff4-anchor)+(0,2.9,-2) -- node{\localmidarrow} ++(0,3,-2); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw connections +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% ConvNet Connections\draw [connection] (crp1-east) -- node {\midarrow} (crp2-west); +\draw [connection] (crp2-east) -- node {\midarrow} (crp3-west); +\draw [connection] (crp3-east) -- node {\midarrow} (crp4-west); +\draw [connection] (crp4-east) -- node {\midarrow} (crp5-west); +\draw [connection] (crp5-east) -- node {\midarrow} (cp6_7-west); +\draw [connection] (cp6_7-east) -- node {\midarrow} (score32-west); +\draw [connection] (score32-east) -- node {\midarrow} (up16-west); +% Diffusion Block internal connections +\draw [connection] (up16-east) -- node {\midarrow} (diff1-west); +\draw [connection] (diff1-east) -- node {\midarrow} (diff2-west); +\draw [connection] (diff2-east) -- node {\midarrow} (diff3-west); +\draw [connection] (diff3-east) -- node {\midarrow} (diff4-west); +\draw [connection] (diff4-east) -- node {\midarrow} ++(2,0,0); + +% EdgeNet Input Connections +\draw [connection](crp1-south)--node {\midarrow}(edge-west-|crp1-south)--node {\midarrow}(edge-west-|crp2-south); +\draw [connection](crp2-south)--node {\midarrow}(crp2_upx2-north); +\draw [connection](crp2_upx2-south)--node {\midarrow}(edge-west-|crp2-south)--node {\midarrow}(edge-west-|crp3-south); +\draw [connection](crp3-south)--node {\midarrow}(crp3_upx4-north); +\draw [connection](crp3_upx4-south)--node {\midarrow}(edge-west-|crp3-south)--node {\midarrow}(edge-west); +% EdgeNet Output Connections +\draw [connection](edge-east) +node[anchor=south west,inner sep = 10, yshift=-20, xshift=180,scale=2.3]{Edges} +--node {\midarrow}(diff4-south |-edge-east)--node {\midarrow}(diff4-south); +\draw [connection](diff3-south |-edge-east)--node {\midarrow}(diff3-south); +\draw [connection](diff2-south |-edge-east)--node {\midarrow}(diff2-south); +\draw [connection](diff1-south |-edge-east)--node {\midarrow}(diff1-south); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\end{tikzpicture} +\end{document} diff --git a/examples/fcn8s/fcn8.pdf b/examples/fcn8s/fcn8.pdf new file mode 100644 index 0000000..4ff823a Binary files /dev/null and b/examples/fcn8s/fcn8.pdf differ diff --git a/examples/fcn8s/fcn8.tex b/examples/fcn8s/fcn8.tex new file mode 100644 index 0000000..261a12b --- /dev/null +++ b/examples/fcn8s/fcn8.tex @@ -0,0 +1,87 @@ +\documentclass[border=15pt, multi, tikz]{standalone} +%\usepackage{blocks} +\usepackage{import} +\subimport{../../layers/}{init} +\usetikzlibrary{positioning} + +\newcommand{\midarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw=\edgecolor] (-0.3,0) -- ++(0.3,0);} +\begin{document} +\begin{tikzpicture} +\tikzstyle{connection}=[ultra thick,every node/.style={sloped,allow upside down},draw=\edgecolor,opacity=0.7] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw Layer Blocks +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% conv1_1,conv1_2,pool1 +\pic[shift={(0,0,0)}] at (0,0,0) {ConvReluPool={blockname=crp1,% + numFilters={{"64","64","32"}},height=40,width={2,2},depth=40,zlabel=I}}; +% conv2_1,conv2_2,pool2 +\pic[shift={(2.1,0,0)}] at (crp1-east) {ConvReluPool={blockname=crp2,% + numFilters={{"128","128"}},height=35,width={3,3},depth=35,zlabel=I/2}}; +%% conv3_1,conv3_2,conv3_3,pool3 +\pic[shift={(2,0,0)}] at (crp2-east) {ConvReluPool={blockname=crp3,% + numFilters={{"256","256","256"}},height=30,width={4,4,4},depth=30,zlabel=I/4}}; +%% conv4_1,conv4_2,conv4_3,pool4 +\pic[shift={(1.8,0,0)}] at (crp3-east) {ConvReluPool={blockname=crp4,% + numFilters={{"512","512","512"}},height=23,width={7,7,7},depth=23,zlabel=I/8}}; +%% conv5_1,conv5_2,conv5_3,pool5 +\pic[shift={(1.5,0,0)}] at (crp4-east) {ConvReluPool={blockname=crp5,% + numFilters={{"512","512","512"}},height=15,width={7,7,7},depth=15,zlabel=I/16}}; +%% fc6, fc7 +\pic[shift={(1.2,0,0)}] at (crp5-east) {ConvRelu={blockname=cp6_7,% + numFilters={{"4096","4096"}},height=10,width={10,10},depth=10,zlabel=I/32}}; +%% score32 +\pic[shift={(1,0,0)}] at (cp6_7-east) {Conv={blockname=score32,% + numFilters={{"1","4096"}},height=10,width=1,depth=10,zlabel=I/32}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%Joining with previous streams (fcn-16) +%% Upsampling Deconv Layer +\pic[shift={(1,0,0)}] at (score32-east) {Deconv={blockname=up32,% + numFilters={{"1","4096"}},height=15,width=1,depth=15,zlabel=I/16}}; +%% score16 +\pic[shift={(0,-4,0)}] at (up32-west) {Conv={blockname=score16,% + numFilters={{"1","4096"}},height=15,width=1,depth=15,zlabel=I/16}}; +%% Elementwise sum between score16 and up32 +\pic[shift={(1.5,0,0)}] at (up32-east) {Sum={blockname=elt1,% + numFilters={{"1","4096"}},height=15,width=1,depth=15,zlabel=I/16}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%Joining with previous streams (fcn-8) +%% Upsampling Deconv Layer +\pic[shift={(1,0,0)}] at (elt1-east) {Deconv={blockname=up16,% + numFilters={{"1","4096"}},height=20,width=1,depth=20,zlabel=I/8}}; +%% score8 +\pic[shift={(0,-7,0)}] at (up16-west) {Conv={blockname=score8,% + numFilters={{"1","4096"}},height=20,width=1,depth=20,zlabel=I/8}}; +%% Elementwise sum between score8 and up16 +\pic[shift={(1.5,0,0)}] at (up16-east) {Sum={blockname=elt2,% + numFilters={{"1","4096"}},height=20,width=1,depth=20,zlabel=I/8}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Output +%% Upsampling to original image size +\pic[shift={(1,0,0)}] at (elt2-east) {Deconv={blockname=up8,% + numFilters={{"1","4096"}},height=35,width=1,depth=35,zlabel=I}}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Draw connections +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\draw [connection] (crp1-east) -- node {\midarrow} (crp2-west); +\draw [connection] (crp2-east) -- node {\midarrow} (crp3-west); +\draw [connection] (crp3-east) -- node {\midarrow} (crp4-west); +\draw [connection] (crp4-east) -- node {\midarrow} (crp5-west); +\draw [connection] (crp5-east) -- node {\midarrow} (cp6_7-west); +\draw [connection] (cp6_7-east) -- node {\midarrow} (score32-west); +\draw [connection] (score32-east) -- node {\midarrow} (up32-west); + +\path (crp4-east) -- (crp5-west) coordinate[pos=0.25] (between4_5) ; +\draw [connection] (between4_5) -- node {\midarrow} (score16-west-|between4_5) -- node {\midarrow} (score16-west); +\draw [connection] (up32-east) -- node {\midarrow} (elt1-west); +\draw [connection] (score16-east) -- node {\midarrow} (score16-east -| elt1-south) -- node {\midarrow} (elt1-south); +\draw [connection] (elt1-east) -- node {\midarrow} (up16-west); + +\path (crp3-east) -- (crp4-west) coordinate[pos=0.25] (between3_4) ; +\draw [connection] (between3_4) -- node {\midarrow} (score8-west-|between3_4) -- node {\midarrow} (score8-west); +\draw [connection] (up16-east) -- node {\midarrow} (elt2-west); +\draw [connection] (score8-east) -- node {\midarrow} (score8-east -| elt2-south)-- node {\midarrow} (elt2-south); +\draw [connection] (elt2-east) -- node {\midarrow} (up8-west); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\end{tikzpicture} +\end{document}\grid diff --git a/layers/Conv.sty b/layers/Conv.sty new file mode 100644 index 0000000..1981139 --- /dev/null +++ b/layers/Conv.sty @@ -0,0 +1,55 @@ +\ProvidesPackage{Conv} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw conv combination +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\tikzset{Conv/.pic={\tikzset{/block/.cd,#1} +% conv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [conv] (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- ++(\cubescale*\x,0,0) coordinate (c) -- cycle + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- ++(+\cubescale*\x,0,0) coordinate (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +\draw [conv] + (\SecondLastLayerOriginX*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) -- (c) -- cycle ; +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale, 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=, +blockname=, +} diff --git a/layers/ConvRelu.sty b/layers/ConvRelu.sty new file mode 100644 index 0000000..9f217ea --- /dev/null +++ b/layers/ConvRelu.sty @@ -0,0 +1,63 @@ +\ProvidesPackage{ConvRelu} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw convRelu +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\tikzset{ConvRelu/.pic={\tikzset{/block/.cd,#1} +% conv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [relu] + (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x/3,0,0) coordinate (a1) -- ++(0,-\cubescale*\cubey,0) coordinate (b1) -- ++(\cubescale*\x/3,0,0) coordinate (c) -- cycle + (d) -- (a1) -- ++(0,0,-\cubescale*\cubez) coordinate (h1) -- ++(+\cubescale*\x/3,0,0) coordinate (e) -- cycle; +\draw [conv] + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- (c) -- cycle + (d) -- (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +\draw [conv] + (\SecondLastLayerOriginX*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) -- (c) -- cycle ; +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + %(0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + % Black Label name + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (d)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale, 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +%\draw (0.5*\SecondLastLayerOriginX*\cubescale , -\cubescale*\cubey/2 , -\cubescale*\cubez/2) coordinate (\cubeblockname-center); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=dsdasfkdas, +blockname=a, +} + diff --git a/layers/ConvReluPool.sty b/layers/ConvReluPool.sty new file mode 100644 index 0000000..d2bc8c4 --- /dev/null +++ b/layers/ConvReluPool.sty @@ -0,0 +1,69 @@ +\ProvidesPackage{ConvReluPool} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw convRelu+pooling combination +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\tikzset{ConvReluPool/.pic={\tikzset{/block/.cd,#1} +% conv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [relu] + (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x/3,0,0) coordinate (a1) -- ++(0,-\cubescale*\cubey,0) coordinate (b1) -- ++(\cubescale*\x/3,0,0) coordinate (c) -- cycle + (d) -- (a1) -- ++(0,0,-\cubescale*\cubez) coordinate (h1) -- ++(+\cubescale*\x/3,0,0) coordinate (e) -- cycle; +\draw [conv] + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- (c) -- cycle + (d) -- (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +% Pooling layer +\draw [pool] + (\SecondLastLayerOriginX*\cubescale +1*\cubescale,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-1*\cubescale,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- ++(1*\cubescale,0,0) coordinate (c) -- cycle + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) edge (g) -- (c) -- cycle + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- (e) -- cycle; + +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + %(d) edge ["\bf\cubeblockname"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (e) + + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + %(0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (d)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale + 1*\cubescale , 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +%\draw (0.5*\SecondLastLayerOriginX*\cubescale , -\cubescale*\cubey/2 , -\cubescale*\cubez/2) coordinate (\cubeblockname-center); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +\path (\cubeblockname-anchor) -- ++(0,\cubescale*\cubey/2,0) coordinate (\cubeblockname-north); +\path (\cubeblockname-anchor) -- ++(0,-\cubescale*\cubey/2,0) coordinate (\cubeblockname-south); +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=, +blockname=, +} diff --git a/layers/Deconv.sty b/layers/Deconv.sty new file mode 100644 index 0000000..cf98ad3 --- /dev/null +++ b/layers/Deconv.sty @@ -0,0 +1,58 @@ +\ProvidesPackage{Deconv} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw Deconvolution layer +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\tikzset{Deconv/.pic={\tikzset{/block/.cd,#1} +% deconv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [deconv] (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- ++(\cubescale*\x,0,0) coordinate (c) -- cycle + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- ++(+\cubescale*\x,0,0) coordinate (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +\draw [deconv] + (\SecondLastLayerOriginX*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) -- (c) -- cycle ; +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale, 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +\path (\cubeblockname-anchor) -- ++(0,\cubescale*\cubey/2,0) coordinate (\cubeblockname-north); +\path (\cubeblockname-anchor) -- ++(0,-\cubescale*\cubey/2,0) coordinate (\cubeblockname-south); + +\path (\cubeblockname-anchor) -- ++(0,0,\cubescale*\cubez/2) coordinate (\cubeblockname-out); +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=, +blockname=, +} diff --git a/layers/DomainTransform.sty b/layers/DomainTransform.sty new file mode 100644 index 0000000..7e15afa --- /dev/null +++ b/layers/DomainTransform.sty @@ -0,0 +1,64 @@ +\ProvidesPackage{DomainTransform} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw generic sequential layer +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +\tikzset{DomainTransform/.pic={\tikzset{/block/.cd,#1} +% conv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [layer] (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- ++(\cubescale*\x,0,0) coordinate (c) -- cycle + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- ++(+\cubescale*\x,0,0) coordinate (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +\draw [layer] + (\SecondLastLayerOriginX*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) -- (c) -- cycle ; +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale + 2*\cubescale , 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +\path (\cubeblockname-anchor) -- ++(0,\cubescale*\cubey/2,0) coordinate (\cubeblockname-north); +\path (\cubeblockname-anchor) -- ++(0,-\cubescale*\cubey/2,0) coordinate (\cubeblockname-south); + + + +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=, +blockname=, +} + diff --git a/layers/FullyConnected.sty b/layers/FullyConnected.sty new file mode 100644 index 0000000..3fe83ba --- /dev/null +++ b/layers/FullyConnected.sty @@ -0,0 +1,55 @@ +\ProvidesPackage{FullyConnected} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw conv combination +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\tikzset{FullyConnected/.pic={\tikzset{/block/.cd,#1} +% conv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [fullyconn] (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- ++(\cubescale*\x,0,0) coordinate (c) -- cycle + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- ++(+\cubescale*\x,0,0) coordinate (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +\draw [fullyconn] + (\SecondLastLayerOriginX*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) -- (c) -- cycle ; +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale + 2*\cubescale , 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=, +blockname=, +} diff --git a/layers/FullyConnectedRelu.sty b/layers/FullyConnectedRelu.sty new file mode 100644 index 0000000..caeb796 --- /dev/null +++ b/layers/FullyConnectedRelu.sty @@ -0,0 +1,61 @@ +\ProvidesPackage{FullyConnectedRelu} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw fully connected +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\tikzset{FullyConnectedRelu/.pic={\tikzset{/block/.cd,#1} +% conv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [fullyrelu] + (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x/3,0,0) coordinate (a1) -- ++(0,-\cubescale*\cubey,0) coordinate (b1) -- ++(\cubescale*\x/3,0,0) coordinate (c) -- cycle + (d) -- (a1) -- ++(0,0,-\cubescale*\cubez) coordinate (h1) -- ++(+\cubescale*\x/3,0,0) coordinate (e) -- cycle; +\draw [fullyconn] + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- (c) -- cycle + (d) -- (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +\draw [fullyconn] + (\SecondLastLayerOriginX*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) -- (c) -- cycle ; +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale, 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +%\draw (0.5*\SecondLastLayerOriginX*\cubescale , -\cubescale*\cubey/2 , -\cubescale*\cubez/2) coordinate (\cubeblockname-center); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=, +blockname=, +} + diff --git a/layers/GenericSequentialLayer.sty b/layers/GenericSequentialLayer.sty new file mode 100644 index 0000000..cbebf98 --- /dev/null +++ b/layers/GenericSequentialLayer.sty @@ -0,0 +1,58 @@ +\ProvidesPackage{GenericSequentialLayer} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw generic sequential layer +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\tikzset{GenericSequentialLayer/.pic={\tikzset{/block/.cd,#1} +% conv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [layer] (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- ++(\cubescale*\x,0,0) coordinate (c) -- cycle + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- ++(+\cubescale*\x,0,0) coordinate (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +\draw [layer] + (\SecondLastLayerOriginX*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) -- (c) -- cycle ; +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale + 2*\cubescale , 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +\path (\cubeblockname-anchor) -- ++(0,\cubescale*\cubey/2,0) coordinate (\cubeblockname-north); +\path (\cubeblockname-anchor) -- ++(0,-\cubescale*\cubey/2,0) coordinate (\cubeblockname-south); +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=, +blockname=, +} + diff --git a/layers/Multiply.sty b/layers/Multiply.sty new file mode 100644 index 0000000..28b493d --- /dev/null +++ b/layers/Multiply.sty @@ -0,0 +1,42 @@ +\ProvidesPackage{Multiply} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw Elementwise operations +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\tikzset{Multiply/.pic={\tikzset{/block/.cd,#1} + +\draw (0,0,0) circle (\SphereRadius); + +\draw (0,0,0) coordinate (\cubeblockname-anchor); +\draw (\SphereRadius,0,0) coordinate (\cubeblockname-east); +\draw (-\SphereRadius,0,0) coordinate (\cubeblockname-west); +\draw (0,\SphereRadius,0) coordinate (\cubeblockname-north); +\draw (0,-\SphereRadius,0) coordinate (\cubeblockname-south); + +\draw[very thick] (-2*\SphereRadius/4,-2*\SphereRadius/4,0) -- (2*\SphereRadius/4,2*\SphereRadius/4,0); +\draw[very thick] (2*\SphereRadius/4,-2*\SphereRadius/4,0) -- (-2*\SphereRadius/4,2*\SphereRadius/4,0); + +\shade[ball color=blue,opacity=0.30] (0,0,0) circle (\SphereRadius); + +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +radius/.store in=\SphereRadius, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +radius=0.5, +blocklabel=, +blockname=, +} diff --git a/layers/SigmaSum.sty b/layers/SigmaSum.sty new file mode 100644 index 0000000..694512c --- /dev/null +++ b/layers/SigmaSum.sty @@ -0,0 +1,42 @@ +\ProvidesPackage{SigmaSum} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw Reduction sum operations +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\tikzset{SigmaSum/.pic={\tikzset{/block/.cd,#1} + +\draw (0,0,0) circle [radius=\SphereRadius] node[scale=4*\SphereRadius] {$\Sigma$}; + +\draw (0,0,0) coordinate (\cubeblockname-anchor); +\draw (\SphereRadius,0,0) coordinate (\cubeblockname-east); +\draw (-\SphereRadius,0,0) coordinate (\cubeblockname-west); +\draw (0,\SphereRadius,0) coordinate (\cubeblockname-north); +\draw (0,-\SphereRadius,0) coordinate (\cubeblockname-south); + +%\draw[very thick] (-2*\SphereRadius/4,-2*\SphereRadius/4,0) -- (2*\SphereRadius/4,2*\SphereRadius/4,0); +%\draw [very thick] (c1-east)++(0,\up,0) node [anchor=south west, inner sep = 10, xshift=10,scale=1.2]{$p_{i,j}^{(k)} - p_{(i+\Delta i),(j+\Delta j)}^{(k)}$} -- node {\midarrow} (abs1-west-up); + +\shade[ball color=green,opacity=0.30] (0,0,0) circle (\SphereRadius); + +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +radius/.store in=\SphereRadius, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +radius=0.5, +blocklabel=, +blockname=, +} diff --git a/layers/Sum.sty b/layers/Sum.sty new file mode 100644 index 0000000..d99c2fc --- /dev/null +++ b/layers/Sum.sty @@ -0,0 +1,42 @@ +\ProvidesPackage{Sum} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw Elementwise operations +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\tikzset{Sum/.pic={\tikzset{/block/.cd,#1} + +\draw (0,0,0) circle (\SphereRadius); + +\draw (0,0,0) coordinate (\cubeblockname-anchor); +\draw (\SphereRadius,0,0) coordinate (\cubeblockname-east); +\draw (-\SphereRadius,0,0) coordinate (\cubeblockname-west); +\draw (0,\SphereRadius,0) coordinate (\cubeblockname-north); +\draw (0,-\SphereRadius,0) coordinate (\cubeblockname-south); + +\draw[very thick] (-2*\SphereRadius/4,0,0) -- (2*\SphereRadius/4,0,0); +\draw[very thick] (0,-2*\SphereRadius/4,0) -- (0,2*\SphereRadius/4,0); + +\shade[ball color=blue,opacity=0.30] (0,0,0) circle (\SphereRadius); + +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +radius/.store in=\SphereRadius, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +radius=0.5, +blocklabel=, +blockname=, +} diff --git a/layers/Up.sty b/layers/Up.sty new file mode 100644 index 0000000..d8f455b --- /dev/null +++ b/layers/Up.sty @@ -0,0 +1,58 @@ +\ProvidesPackage{Up} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%This Block can draw Deconvolution layer +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\tikzset{Up/.pic={\tikzset{/block/.cd,#1} +% deconv layers +\foreach \x [ count=\i,evaluate=\x as \numfilters using {array({\cubexlabel},\i-1)}, evaluate=\x as \k using {\x+\prev}, remember=\k as \prev (initially 0)] in \cubex +{ +\draw [up] (\k*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(-\cubescale*\x,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez) -- ++(\cubescale*\x,0,0) coordinate (c) -- cycle + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) edge coordinate[pos=1] (f) ++(0,-\cubescale*\cubey,0) (f) edge (g) + (d) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (h) edge (g) -- ++(+\cubescale*\x,0,0) coordinate (e) -- cycle; +% labelling each conv layer with number of filters in each layer +\path [every edge/.append style={pic actions}] + (b) edge ["\numfilters"',midway] (b -| c); +\xdef\SecondLastLayerOriginX{\k} %making value of \k available after the loop as well +} +\draw [up] + (\SecondLastLayerOriginX*\cubescale ,\cubescale*\cubey/2 , \cubescale*\cubez/2) coordinate + (d) -- ++(0,0,-\cubescale*\cubez) coordinate (e) -- ++(0,-\cubescale*\cubey,0) coordinate (f) -- (c) -- cycle ; +% Labelling the block +\path [every edge/.append style={pic actions}] + % name or size of depth dimension + (c) edge ["\small\cubezlabel"',pos=0,text width=14*\cubescale*\cubez,text centered,sloped] (f) + % name or size of height dimension + (0,0,\cubez*\cubescale/2) coordinate (o) edge ["\cubeylabel",midway] (o |- o) + % Block name + (0,-\cubey*\cubescale/2,+\cubez*\cubescale/2) coordinate (o)+(0,-20pt) coordinate (o1) edge ["\textcolor{black}{ \bf \cubeblocklabel}"',midway,white] (o1 -| c) ; + +\draw (\SecondLastLayerOriginX*\cubescale, 0,0) coordinate (\cubeblockname-east); +\draw (0,0,0) coordinate (\cubeblockname-west); +\path (\cubeblockname-west) -- (\cubeblockname-east) coordinate[pos=0.5] (\cubeblockname-anchor); +\path (\cubeblockname-anchor) -- ++(0,\cubescale*\cubey/2,0) coordinate (\cubeblockname-north); +\path (\cubeblockname-anchor) -- ++(0,-\cubescale*\cubey/2,0) coordinate (\cubeblockname-south); + +\path (\cubeblockname-anchor) -- ++(0,0,\cubescale*\cubez/2) coordinate (\cubeblockname-out); +}, +/block/.search also={/tikz}, +/block/.cd, +width/.store in=\cubex, +height/.store in=\cubey, +depth/.store in=\cubez, +scale/.store in=\cubescale, +numFilters/.store in=\cubexlabel, +ylabel/.store in=\cubeylabel, +zlabel/.store in=\cubezlabel, +blocklabel/.store in=\cubeblocklabel, +blockname/.store in=\cubeblockname, +width=2, +height=13, +depth=15, +scale=.2, +numFilters=, +ylabel=, +zlabel=, +blocklabel=, +blockname=, +} diff --git a/layers/init.tex b/layers/init.tex new file mode 100644 index 0000000..c5be37a --- /dev/null +++ b/layers/init.tex @@ -0,0 +1,32 @@ +%\ProvidesPackage{init} +\usetikzlibrary{quotes,arrows.meta} +\usetikzlibrary{positioning} + +\newcommand*{\SecondLastLayerOriginX}{No value} +\def\edgecolor{rgb:blue,4;red,1;green,4;black,3} +\newcommand{\midarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw=\edgecolor] (-0.3,0) -- ++(0.3,0);} + +\tikzstyle{conv} =[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.4, pic actions, fill={rgb:yellow,5;red,2.5;white,5}] +\tikzstyle{relu} =[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.6, pic actions, fill={rgb:yellow,5;red,5;white,4},draw={rgb:yellow,5;red,5;white,4}] +\tikzstyle{pool} =[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.6, pic actions, fill={rgb:red,1;black,0.3}]% colour coeff will be normalized to 1 +\tikzstyle{deconv}=[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.4, pic actions, fill={rgb:blue,5;green,2.5;white,5}] +\tikzstyle{up}=[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.5, pic actions, fill={rgb:blue,5;green,2.5;white,1}] +\tikzstyle{layer} =[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.4, pic actions] +\tikzstyle{fullyconn} =[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.4, pic actions, fill={rgb:blue,5;red,2.5;white,5}] +\tikzstyle{fullyrelu} =[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.6, pic actions, fill={rgb:blue,5;red,5;white,4},draw={rgb:blue,5;red,5;white,4}] +\tikzstyle{DT} =[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=0.4, pic actions, fill={rgb:blue,1;red,2;green,4;white,7}] + +\usepackage{ConvReluPool} +\usepackage{ConvRelu} +\usepackage{Conv} +\usepackage{Deconv} +\usepackage{Up} +%\usepackage{Eltwise} +\usepackage{Multiply} +\usepackage{Sum} +\usepackage{SigmaSum} +\usepackage{FullyConnected} +\usepackage{FullyConnectedRelu} +\usepackage{DomainTransform} +\usepackage{GenericSequentialLayer} + diff --git a/layers/texput.log b/layers/texput.log new file mode 100644 index 0000000..5390e16 --- /dev/null +++ b/layers/texput.log @@ -0,0 +1,21 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2018.3.2) 28 MAR 2018 09:46 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**DomainTransform.tex + +! Emergency stop. +<*> DomainTransform.tex + +*** (job aborted, file error in nonstop mode) + + +Here is how much of TeX's memory you used: + 3 strings out of 493013 + 117 string characters out of 6135683 + 53262 words of memory out of 5000000 + 3649 multiletter control sequences out of 15000+600000 + 3640 words of font info for 14 fonts, out of 8000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 0i,0n,0p,1b,6s stack positions out of 5000i,500n,10000p,200000b,80000s +! ==> Fatal error occurred, no output PDF file produced!