Skip to content

Commit

Permalink
added Unet in Ushape example
Browse files Browse the repository at this point in the history
  • Loading branch information
HarisIqbal88 committed Dec 24, 2018
1 parent 2c1a03f commit 2eddc26
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 0 deletions.
Binary file added examples/Unet (copy)/Unet_ushape.pdf
Binary file not shown.
151 changes: 151 additions & 0 deletions examples/Unet (copy)/Unet_ushape.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
\documentclass[border=8pt, multi, tikz]{standalone}
%\usepackage{blocks}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}

\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5;white,5}
\def\PoolColor{rgb:red,1;black,0.3}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\ConcatColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}


\newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width =0.8mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-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]
\tikzstyle{copyconnection}=[ultra thick,every node/.style={sloped,allow upside down},draw={rgb:blue,4;red,1;green,1;black,3},opacity=0.7]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Encoder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv1_1,conv1_2
\pic[shift={(0,0,0)}] at (0,0,0) {RightBandedBox={name=cr1,%
xlabel={{"64","64"}},caption=I,fill=\ConvColor,bandfill=\ConvReluColor,%
height=40,width={2,2},depth=40}};
%pool1
\pic[shift={(1.2,-10,0)}] at (cr1-east) {Box={name=p1,%
fill=\PoolColor,opacity=0.6,height=32,width=1,depth=32}};
%%%%%%%%%%
% conv2_1,conv2_2
\pic[shift={(0,0,0)}] at (p1-east) {RightBandedBox={name=cr2,%
xlabel={{"128","128"}},caption=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
height=32,width={3.5,3.5},depth=32}};
%pool2
\pic[shift={(1.2,-8.5,0)}] at (cr2-east) {Box={name=p2,%
fill=\PoolColor,opacity=0.6,height=25,width=1,depth=25}};
%%%%%%%%%%
% conv3_1,conv3_2
\pic[shift={(0,0,0)}] at (p2-east) {RightBandedBox={name=cr3,%
xlabel={{"256","256"}},caption=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
height=25,width={4.5,4.5},depth=25}};
%pool3
\pic[shift={(1.2,-6.5,0)}] at (cr3-east) {Box={name=p3,%
fill=\PoolColor,opacity=0.6,height=16,width=1,depth=16}};
%%%%%%%%%%
% conv4_1,conv4_2,conv4_3
\pic[shift={(0,0,0)}] at (p3-east) {RightBandedBox={name=cr4,%
xlabel={{"512","512"}},caption=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
height=16,width={6,6},depth=16}};
%pool4
\pic[shift={(1.2,-3,0)}] at (cr4-east) {Box={name=p4,%
fill=\PoolColor,opacity=0.6,height=8,width=1,depth=8}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Bottleneck
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% conv5_1,conv5_2,conv5_3
\pic[shift={(0,0,0)}] at (p4-east) {RightBandedBox={name=cr5,caption=I/16,%
xlabel={{"1024","1024"}},fill=\ConvColor,bandfill=\ConvReluColor,%
height=8,width={8,8},depth=8}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Draw Decoder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% unpool4,
\pic[shift={(0,0,0)}] at (cr5-east) {Box={name=up4,%
fill=\UnpoolColor,opacity=0.6,height=16,width=1,depth=16}};
\pic[shift={(0,0,0)}] at (up4-east) {RightBandedBox={name=ucr4,%
xlabel={{"512","dummy"}},caption=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
height=16,width=6,depth=16}};
\pic[shift={(0,3,0)}] at (ucr4-anchor) {Ball={name=cat4,fill=\ConcatColor,radius=2.5,logo=$||$}};
\pic[shift={(1.4,0,0)}] at (cat4-east) {RightBandedBox={name=ucr4a,%
xlabel={{"512","512"}},caption=I/8,fill=\ConvColor,bandfill=\ConvReluColor,%
height=16,width={6,6},depth=16}};
%%%%%%%%%%
%% unpool3,
\pic[shift={(0,0,0)}] at (ucr4a-east) {Box={name=up3,%
fill=\UnpoolColor,opacity=0.6,height=25,width=1,depth=25}};
\pic[shift={(0,0,0)}] at (up3-east) {RightBandedBox={name=ucr3,%
xlabel={{"256","dummy"}},caption=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
height=25,width=4.5,depth=25}};
\pic[shift={(0,6.5,0)}] at (ucr3-anchor) {Ball={name=cat3,fill=\ConcatColor,radius=2.5,logo=$||$}};
\pic[shift={(1.5,0,0)}] at (cat3-east) {RightBandedBox={name=ucr3a,%
xlabel={{"256","256"}},caption=I/4,fill=\ConvColor,bandfill=\ConvReluColor,%
height=25,width={4.5,4.5},depth=25}};
%%%%%%%%%%
%% unpool2,
\pic[shift={(0,0,0)}] at (ucr3a-east) {Box={name=up2,%
fill=\UnpoolColor,opacity=0.6,height=32,width=1,depth=32}};
\pic[shift={(0,0,0)}] at (up2-east) {RightBandedBox={name=ucr2,%
xlabel={{"128","dummy"}},caption=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
height=32,width=3.5,depth=32}};
\pic[shift={(0,8.5,0)}] at (ucr2-anchor) {Ball={name=cat2,fill=\ConcatColor,radius=2.5,logo=$||$}};
\pic[shift={(1.8,0,0)}] at (cat2-east) {RightBandedBox={name=ucr2a,%
xlabel={{"128","128"}},caption=I/2,fill=\ConvColor,bandfill=\ConvReluColor,%
height=32,width={3.5,3.5},depth=32}};
%%%%%%%%%%
%% unpool1,
\pic[shift={(0,0,0)}] at (ucr2a-east) {Box={name=up1,%
fill=\UnpoolColor,opacity=0.6,height=40,width=1,depth=40}};
\pic[shift={(0,0,0)}] at (up1-east) {RightBandedBox={name=ucr1,%
xlabel={{"64","dummy"}},caption=I,fill=\ConvColor,bandfill=\ConvReluColor,%
height=40,width=2.5,depth=40}};
\pic[shift={(0,10,0)}] at (ucr1-anchor) {Ball={name=cat1,fill=\ConcatColor,radius=2.5,logo=$||$}};
\pic[shift={(2,0,0)}] at (cat1-east) {RightBandedBox={name=ucr1a,%
xlabel={{"64","64"}},caption=I,fill=\ConvColor,bandfill=\ConvReluColor,%
height=40,width={2.5,2.5},depth=40}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Classifier
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pic[shift={(2,0,0)}] at (ucr1a-east) {Box={name=out,caption=Softmax,%
zlabel=I,fill=\SoftmaxColor,height=40,width=1,depth=40}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draw connections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\path (cr1-east) -- (p1-west|-cr1-west) coordinate[pos=0.5] (crp1-mid) ;
\path (cr2-east) -- (p2-west|-cr2-west) coordinate[pos=0.5] (crp2-mid) ;
\path (cr3-east) -- (p3-west|-cr3-west) coordinate[pos=0.5] (crp3-mid) ;
\path (cr4-east) -- (p4-west|-cr4-west) coordinate[pos=0.5] (crp4-mid) ;

\draw[connection](cr1-east)--node{\midarrow}(crp1-mid)--node{\midarrow}(p1-west-|crp1-mid)--node{\midarrow}(p1-west);
\draw[connection](cr2-east)--node{\midarrow}(crp2-mid)--node{\midarrow}(p2-west-|crp2-mid)--node{\midarrow}(p2-west);
\draw[connection](cr3-east)--node{\midarrow}(crp3-mid)--node{\midarrow}(p3-west-|crp3-mid)--node{\midarrow}(p3-west);
\draw[connection](cr4-east)--node{\midarrow}(crp4-mid)--node{\midarrow}(p4-west-|crp4-mid)--node{\midarrow}(p4-west);

%\draw [connection] (cr5-east) -- node {\midarrow} (up4-west);
%\draw [connection] (ucr4a-east) -- node {\midarrow} (up3-west);
%\draw [connection] (ucr3a-east) -- node {\midarrow} (up2-west);
%\draw [connection] (ucr2a-east) -- node {\midarrow} (up1-west);
\draw [connection] (ucr1a-east) -- node {\midarrow} (out-west);
%\draw [connection] (out-east) -- node {\midarrow} ++(2,0,0);

\draw [copyconnection] (cr4-east) -- node {\copymidarrow} (cat4-west);
\draw [copyconnection] (cr3-east) -- node {\copymidarrow} (cat3-west);
\draw [copyconnection] (cr2-east) -- node {\copymidarrow} (cat2-west);
\draw [copyconnection] (cr1-east) -- node {\copymidarrow} (cat1-west);

\draw [copyconnection] (cat4-east) -- node {\copymidarrow} (ucr4a-west);
\draw [copyconnection] (cat3-east) -- node {\copymidarrow} (ucr3a-west);
\draw [copyconnection] (cat2-east) -- node {\copymidarrow} (ucr2a-west);
\draw [copyconnection] (cat1-east) -- node {\copymidarrow} (ucr1a-west);

\draw [copyconnection] (ucr4-north) -- node {\copymidarrow} (cat4-south);
\draw [copyconnection] (ucr3-north) -- node {\copymidarrow} (cat3-south);
\draw [copyconnection] (ucr2-north) -- node {\copymidarrow} (cat2-south);
\draw [copyconnection] (ucr1-north) -- node {\copymidarrow} (cat1-south);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document}

0 comments on commit 2eddc26

Please sign in to comment.