-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResNet50 Tex #24
Comments
just install the pycore package using |
Hi @somdipdey, can you kindly share your RestNet drawing code? |
+1 @lc82111. Would highly appreciate it if you could share the code you used to visualise the ResNet @somdipdey. |
+1 if @somdipdey or anyone else shares ResNet code. |
I drew a ResNet diagram and It turns out to be a scroll. And I failed to modularize the code and to define some useful command. Hope someone being more familiar with TeX/tikz can make useful macro I made this diagram according to modified resnet model for MNIST. Here's the definition of model, maybe helpful (paddlepaddle, similary to pytorch): def conv_bn_layer(input, ch_out, filter_size, stride, padding, act="relu", bias_attr=False):
tmp = fluid.layers.conv2d(
input=input,
filter_size=filter_size,
num_filters=ch_out,
stride=stride,
padding=padding,
act=None,
bias_attr=bias_attr) # 定义层
return fluid.layers.batch_norm(input=tmp, act=act) # 均一化
def shortcut(input, ch_in, ch_out, stride):
if ch_in != ch_out:
return conv_bn_layer(input, ch_out, 1, stride, 0, None)
else:
return input
def basicblock(input, ch_in, ch_out, stride):
tmp = conv_bn_layer(input, ch_out, 3, stride, 1)
tmp = conv_bn_layer(tmp, ch_out, 3, 1, 1, act=None, bias_attr=True)
short = shortcut(input, ch_in, ch_out, stride)
return fluid.layers.elementwise_add(x=tmp, y=short, act="relu")
def layer_warp(block_func, input, ch_in, ch_out, count, stride):
tmp = block_func(input, ch_in, ch_out, stride)
for i in range(1, count):
tmp = block_func(tmp, ch_out, ch_out, 1)
return tmp
def resnet_handwriting(ipt):
conv1 = conv_bn_layer(ipt, ch_out=16, filter_size=3, stride=1, padding=1)
res1 = layer_warp(basicblock, conv1, 16, 16, 3, 1)
res2 = layer_warp(basicblock, res1, 16, 32, 4, 1)
res3 = layer_warp(basicblock, res2, 32, 64, 5, 1)
res4 = layer_warp(basicblock, res3, 64, 128, 3, 1)
pool = fluid.layers.pool2d(
input=res4, pool_size=8, pool_type="avg", pool_stride=1)
predict = fluid.layers.fc(input=pool, size=10, act="softmax")
return predict Full version: Minimal version: \documentclass[border=8pt, multi, tikz]{standalone}
%\usepackage{blocks}
% \usepackage[top=4cm,left=2cm]{geometry}
\usepackage{import}
\subimport{./layers/}{init}
\usetikzlibrary{positioning}
\usetikzlibrary{3d} %for including external image
\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5}
\def\PoolColor{rgb:red,1;black,0}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\FcColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}
\def\SumColor{rgb:blue,5;green,15}
\def\LayerColor{rgb:black,1}
\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}
\noindent
\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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% input picture
\node[canvas is zy plane at x=0] (temp) at (-3.5,0,0) {\includegraphics[width=-8cm,height=8cm]{infer_3.jpg}};
\path (-5,0,0);
% input
\pic[shift={(0,0,0)}] at (0,0,0) {
Box={
name=input,
caption=Input,
xlabel={{"1","28"}},
ylabel=28,
zlabel=28,
fill=\ConvColor,
height=28,
width=0.09375,
depth=28
}
};
% conv1
\pic[shift={(1.5,0,0)}] at (input-east) {
RightBandedBox={
name=conv1,
caption=Conv1\\3\(\times\)3,
xlabel={{"16",""}},
ylabel=28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=28,
width=1.5,
depth=28
}
};
% layer1
% res1_1_1
\pic[shift={(1.5,0,0)}] at (conv1-east) {
RightBandedBox={
name=res1_1_1,
xlabel={{"16",""}},
ylabel=28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=28,
width=1.5,
depth=28
}
};
% res1_1_2
\pic[shift={(0,0,0)}] at (res1_1_1-east) {
Box={
name=res1_1_2,
caption=\makebox[0pt]{\shortstack[c]{3\(\times\)3 bn relu\\3\(\times\)3\\ele\_add bn relu}},
xlabel={{"16",""}},
zlabel=28,
fill=\ConvColor,
height=28,
width=1.5,
depth=28
}
};
% add1_1
\pic[shift={(0,0,0)}] at (res1_1_2-east) {
Ball={
name=add1_1,
fill=\SumColor,
opacity=0.6,
radius=2.5,
logo=\(+\)
}
};
% relu1_1
\pic[shift={(0,0,0)}] at (add1_1-east) {
Box={
name=relu1_1,
caption=,
xlabel={{"16",""}},
zlabel=28,
fill=\ConvReluColor,
height=28,
width=1.5,
depth=28
}
};
% res1_2_1
\pic[shift={(1.5,0,0)}] at (relu1_1-east) {
RightBandedBox={
name=res1_2_1,
xlabel={{"16",""}},
ylabel=28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=28,
width=1.5,
depth=28
}
};
% res1_2_2
\pic[shift={(0,0,0)}] at (res1_2_1-east) {
Box={
name=res1_2_2,
caption=\makebox[0pt]{\shortstack[c]{3\(\times\)3 bn relu\\3\(\times\)3\\ele\_add bn relu}},
xlabel={{"16",""}},
zlabel=28,
fill=\ConvColor,
height=28,
width=1.5,
depth=28
}
};
% add1_2
\pic[shift={(0,0,0)}] at (res1_2_2-east) {
Ball={
name=add1_2,
fill=\SumColor,
opacity=0.6,
radius=2.5,
logo=\(+\)
}
};
% relu1_2
\pic[shift={(0,0,0)}] at (add1_2-east) {
Box={
name=relu1_2,
caption=,
xlabel={{"16",""}},
zlabel=28,
fill=\ConvReluColor,
height=28,
width=1.5,
depth=28
}
};
% res1_3_1
\pic[shift={(1.5,0,0)}] at (relu1_2-east) {
RightBandedBox={
name=res1_3_1,
xlabel={{"16",""}},
ylabel=28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=28,
width=1.5,
depth=28
}
};
% res1_3_2
\pic[shift={(0,0,0)}] at (res1_3_1-east) {
Box={
name=res1_3_2,
caption=\makebox[0pt]{\shortstack[c]{3\(\times\)3 bn relu\\3\(\times\)3\\ele\_add bn relu}},
xlabel={{"16",""}},
zlabel=28,
fill=\ConvColor,
height=28,
width=1.5,
depth=28
}
};
% add1_3
\pic[shift={(0,0,0)}] at (res1_3_2-east) {
Ball={
name=add1_3,
fill=\SumColor,
opacity=0.6,
radius=2.5,
logo=\(+\)
}
};
% relu1_3
\pic[shift={(0,0,0)}] at (add1_3-east) {
Box={
name=relu1_3,
caption=,
xlabel={{"16",""}},
zlabel=28,
fill=\ConvReluColor,
height=28,
width=1.5,
depth=28
}
};
% layer2
% res2_1_1
\pic[shift={(1.5,0,0)}] at (relu1_3-east) {
RightBandedBox={
name=res2_1_1,
xlabel={{"32",""}},
ylabel=28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=28,
width=3,
depth=28
}
};
% warp2
\pic[shift={(1.5,7,0)}] at (relu1_3-east) {
Box={
name=warp2,
caption=\makebox[0pt]{\shortstack[c]{1\(\times\)1}},
xlabel={{"32",""}},
ylabel=28,
fill=\UnpoolColor,
height=28,
width=3,
depth=28
}
};
% res2_1_2
\pic[shift={(0,0,0)}] at (res2_1_1-east) {
Box={
name=res2_1_2,
caption=\makebox[0pt]{\shortstack[c]{3\(\times\)3 bn relu\\3\(\times\)3\\ele\_add bn relu}},
xlabel={{"32",""}},
zlabel=28,
fill=\ConvColor,
height=28,
width=3,
depth=28
}
};
% add2_1
\pic[shift={(0,0,0)}] at (res2_1_2-east) {
Ball={
name=add2_1,
fill=\SumColor,
opacity=0.6,
radius=2.5,
logo=\(+\)
}
};
% relu2_1
\pic[shift={(0,0,0)}] at (add2_1-east) {
Box={
name=relu2_1,
caption=,
xlabel={{"32",""}},
zlabel=28,
fill=\ConvReluColor,
height=28,
width=3,
depth=28
}
};
% pool2d
\pic[shift={(1.5,0,0)}] at (relu2_1-east) {
Box={
name=pool2d,
caption=\makebox[0pt]{\shortstack[c]{avg\_pool\\size=8\\stride=1}},
xlabel={{"128",""}},
ylabel=23,
zlabel=23,
fill=\PoolColor,
height=23,
width=12,
depth=23
}
};
% fullconnection
\pic[shift={(1.5,0,0)}] at (pool2d-east) {
RightBandedBox={
name=fc,
caption=\makebox[0pt]{\shortstack[c]{full\_connection\\softmax}},
xlabel={{"1",""}},
zlabel=10,
fill=\FcColor,
bandfill=\SoftmaxColor,
height=4,
width=4,
depth=40
}
};
% connections
\draw [connection] (input-east) -- node {\midarrow} (conv1-west);
\draw [connection] (conv1-east) -- node {\midarrow} (res1_1_1-west);
\draw [connection] (relu1_1-east) -- node {\midarrow} (res1_2_1-west);
\draw [connection] (relu1_2-east) -- node {\midarrow} (res1_3_1-west);
\draw [connection] (relu1_3-east) -- node {\midarrow} (res2_1_1-west);
% connections shortcut
% conv1 to add1_1
\path (add1_1-north) ++ (0,4,0) coordinate (add1_1-north-above);
\draw [connection] (conv1-north) -- node {\midarrow} (conv1-north|-add1_1-north-above) -- node {\midarrow} (add1_1-north-above) -- node {\midarrow} (add1_1-north);
% relu1_1 to add1_2
\path (add1_2-north) ++ (0,4,0) coordinate (add1_2-north-above);
\draw [connection] (relu1_1-north) -- node {\midarrow} (relu1_1-north|-add1_2-north-above) -- node {\midarrow} (add1_2-north-above) -- node {\midarrow} (add1_2-north);
% relu1_2 to add1_3
\path (add1_3-north) ++ (0,4,0) coordinate (add1_3-north-above);
\draw [connection] (relu1_2-north) -- node {\midarrow} (relu1_2-north|-add1_3-north-above) -- node {\midarrow} (add1_3-north-above) -- node {\midarrow} (add1_3-north);
% relu1_3 to warp2_1
\draw [connection] (relu1_3-north) -- node {\midarrow} (relu1_3-north|-warp2-west) -- node {\midarrow} (warp2-west);
\draw [connection] (warp2-east) -- node {\midarrow} (warp2-east-|add2_1-north) -- node {\midarrow} (add2_1-north);
% pool & fullconnection
\draw [densely dashed] (relu2_1-nearnortheast) -- (pool2d-nearnorthwest);
\draw [densely dashed] (relu2_1-nearsoutheast) -- (pool2d-nearsouthwest);
\draw [densely dashed] (relu2_1-farnortheast) -- (pool2d-farnorthwest);
\draw [densely dashed] (relu2_1-farsoutheast) -- (pool2d-farsouthwest);
\draw [densely dashed] (pool2d-nearnortheast) -- (fc-nearnorthwest);
\draw [densely dashed] (pool2d-nearsoutheast) -- (fc-nearsouthwest);
\draw [densely dashed] (pool2d-farnortheast) -- (fc-farnorthwest);
\draw [densely dashed] (pool2d-farsoutheast) -- (fc-farsouthwest);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document} |
\documentclass[border=12pt, multi, tikz]{standalone}
\usepackage[fontsize=14pt]{fontsize}
\usepackage{import}
\subimport{../../layers/}{init}
\usetikzlibrary{positioning}
\usetikzlibrary{3d} %for including external image
\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5}
\def\bnColor{rgb:yellow,5;red,5}
\def\PoolColor{rgb:red,1;black,0}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\FcColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}
\def\SumColor{rgb:blue,5;green,15}
\def\LayerColor{rgb:black,1}
\newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width =1mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);}
\begin{document}
\noindent
\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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\path (-4,0,0);
% input
\pic[shift={(0,0,0)}] at (0,0,0) {
Box={
name=input,
caption=Input,
xlabel= 3,
ylabel=224,
zlabel= \qquad 224,
fill=\ConvColor,
height=100,
width=0.1,
depth=100
}
};
% conv1
\pic[shift={(1.5,0,0)}] at (input-east) {
RightBandedBox={
name= conv1,
caption=Conv1,
xlabel={{"64",""}},
ylabel=112,
zlabel= \qquad 112,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=50,
width=2.1,
depth=50
}
};
% MaxPool2d
\pic[shift={(1,0,0)}] at (conv1-east) {
RightBandedBox={
name= MaxPool,
xlabel={{"64",""}},
ylabel=112,
fill=\PoolColor,
height=50,
width=2.1,
depth=50
}
};
% layer1
% conv1_1
\pic[shift={(3,0,0)}] at (MaxPool-east) {
RightBandedBox={
name= conv1_1,
xlabel={{"64",""}},
ylabel= 112,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=50,
width=2.1,
depth=50
}
};
% conv1_2
\pic[shift={(0,0,0)}] at (conv1_1-east) {
RightBandedBox={
name= conv1_2,
xlabel={{"\quad 64",""}},
zlabel= \qquad 112,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=50,
width=2.1,
depth=50
}
};
% add1_1
\pic[shift={(1,0,0)}] at (conv1_2-east) {
Ball={
name=add1_1,
fill=\SumColor,
opacity=0.6,
radius=2,
logo=\(+\)
}
};
\pic[shift={(-0.2,0,0)}] at (conv1_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 3}},%
xlabel={{"","dummy"}},fill=,opacity=0.1,height=60,width={10},depth=60}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pic[shift={(3,0,0)}] at (conv1_2-east) {
RightBandedBox={
name= conv2_1,
xlabel={{"128",""}},
ylabel= 56,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=25,
width=4.2,
depth=25
}
};
% conv2_2
\pic[shift={(0,0,0)}] at (conv2_1-east) {
RightBandedBox={
name= conv2_2,
xlabel={{"128",""}},
zlabel= \qquad 56,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=25,
width=4.2,
depth=25
}
};
% add1_2
\pic[shift={(1,0,0)}] at (conv2_2-east) {
Ball={
name=add1_2,
fill=\SumColor,
opacity=0.6,
radius=2,
logo=\(+\)
}
};
\pic[shift={(-0.4,0,0)}] at (conv2_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 4}},%
xlabel={{"","dummy"}},fill=,opacity=0.1,height=30,width={20},depth=30}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv3_1
\pic[shift={(3,0,0)}] at (conv2_2-east) {
RightBandedBox={
name= conv3_1,
xlabel={{"256",""}},
ylabel= 28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=12.5,
width=8.4,
depth=12.5
}
};
% conv3_2
\pic[shift={(0,0,0)}] at (conv3_1-east) {
RightBandedBox={
name= conv3_2,
xlabel={{"256",""}},
zlabel= 28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=12.5,
width=8.4,
depth=12.5
}
};
% add1_3
\pic[shift={(1,0,0)}] at (conv3_2-east) {
Ball={
name=add1_3,
fill=\SumColor,
opacity=0.6,
radius=2,
logo=\(+\)
}
};
\pic[shift={(-0.6,0,0)}] at (conv3_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 6}},%
xlabel={{"","dummy"}},fill=,opacity=0.1,height=20,width={30},depth=20}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv4_1
\pic[shift={(3,0,0)}] at (conv3_2-east) {
RightBandedBox={
name= conv4_1,
xlabel={{"512",""}},
ylabel= 14,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=6.25,
width=16.8,
depth=6.25
}
};
% conv4_2
\pic[shift={(0,0,0)}] at (conv4_1-east) {
RightBandedBox={
name= conv4_2,
xlabel={{"512",""}},
ylabel= 14,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=6.25,
width=16.8,
depth=6.25
}
};
% add1_4
\pic[shift={(1,0,0)}] at (conv4_2-east) {
Ball={
name=add1_4,
fill=\SumColor,
opacity=0.6,
radius=2,
logo= \(+\)
}
};
\pic[shift={(-0.8,0,0)}] at (conv4_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 3}},%
xlabel={{"","dummy"}},fill=,opacity=0.1,height=15,width={48},depth=15}};
% avgpool
\pic[shift={(3,0,0)}] at (add1_4-east) {
Box={
name=avgpool,
caption= \\ avgpool,
xlabel={{"1",""}},
ylabel=1,
zlabel=\qquad 512,
fill=\PoolColor,
height=2,
width=2,
depth=150
}
};
% fullconnection
\pic[shift={(2,0,0)}] at (avgpool-east) {
RightBandedBox={
name=fc,
caption=\makebox[0pt]{
\shortstack[c]{\\ full \, connection\\softmax}},
xlabel={{"1",""}},
zlabel=\qquad 7,
fill=\FcColor,
bandfill=\SoftmaxColor,
height=2,
width=2,
depth=20
}
};
% connections
\draw [connection] (input-east) -- node {\midarrow} (conv1-west);
\draw [connection] (conv1-east) -- node {\midarrow} (MaxPool-west);
\draw [connection] (MaxPool-east) -- node {\midarrow} (conv1_1-west);
% connections shortcut
% conv1 to add1_1
\path (MaxPool-east) -- (conv1_1-west) coordinate[pos=0.5] (pool_conv1_1);
\path (pool_conv1_1) ++ (0,5,0) coordinate (pool_conv1_1_above);
\path (add1_1-north) ++ (0,5,0) coordinate (add1_1-north-above);
\draw [connection] (pool_conv1_1) -- node {\midarrow} (pool_conv1_1_above|-add1_1-north-above) -- node {\midarrow} (add1_1-north-above) -- node {\midarrow} (add1_1-north);
\draw [connection] (conv1_2-east) -- (add1_1-west);
\draw [connection] (add1_1-east) -- node {\midarrow} (conv2_1-west);
%
\path (conv1_2-east) -- (conv2_1-west) coordinate[pos=0.65] (add_conv_1);
\path (add_conv_1) ++ (0,5,0) coordinate (add_conv_1-above);
\path (add1_2-north) ++ (0,5,0) coordinate (add1_2-north-above);
\draw [connection] (add_conv_1) -- node {\midarrow} (add_conv_1-above|-add1_2-north-above) -- node {\midarrow} (add1_2-north-above) -- node {\midarrow} (add1_2-north);
\draw [connection] (conv2_2-east) -- (add1_2-west);
\draw [connection] (add1_2-east) -- node {\midarrow} (conv3_1-west);
%%%%%%%%%%%%%%
\path (conv2_2-east) -- (conv3_1-west) coordinate[pos=0.75] (add_conv_2);
\path (add_conv_2) ++ (0,5,0) coordinate (add_conv_2-above);
\path (add1_3-north) ++ (0,5,0) coordinate (add1_3-north-above);
\draw [connection] (add_conv_2) -- node {\midarrow} (add_conv_2-above|-add1_3-north-above) -- node {\midarrow} (add1_3-north-above) -- node {\midarrow} (add1_3-north);
\draw [connection] (conv3_2-east) -- (add1_3-west);
\draw [connection] (add1_3-east) -- node {\midarrow} (conv4_1-west);
%%%%%%%%%%%%%%%
\path (conv3_2-east) -- (conv4_1-west) coordinate[pos=0.75] (add_conv_3);
\path (add_conv_3) ++ (0,5,0) coordinate (add_conv_3-above);
\path (add1_4-north) ++ (0,5,0) coordinate (add1_4-north-above);
\draw [connection] (add_conv_3) -- node {\midarrow} (add_conv_3-above|-add1_4-north-above) -- node {\midarrow} (add1_4-north-above) -- node {\midarrow} (add1_4-north);
\draw [connection] (conv4_2-east) -- (add1_4-west);
%\draw [connection] (add1_4-east) -- node {\midarrow} (conv4_1-west);
\draw [connection](add1_4-east) -- node {\midarrow}(avgpool-west);
\draw [connection](avgpool-east) -- node {\midarrow}(fc-west);
% pool & fullconnection
\draw [densely dashed] (avgpool-nearnortheast) -- (fc-nearnorthwest);
\draw [densely dashed] (avgpool-nearsoutheast) -- (fc-nearsouthwest);
\draw [densely dashed] (avgpool-farnortheast) -- (fc-farnorthwest);
\draw [densely dashed] (avgpool-farsoutheast) -- (fc-farsouthwest);
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document} |
Just write a ResNet101 Based on @sydddl 's perfect work, I also made some change to the gap between each Block to make it look delicious.🍺 |
And here is the code, Just replace the input image path "pics/03-LC-ser-sub-20-mirror" if you like it, big thanks to @sydddl 's work on ResNet34. \documentclass[border=12pt, multi, tikz]{standalone}
\usepackage[fontsize=14pt]{fontsize}
\usepackage{import}
\subimport{./layers/}{init}
\usetikzlibrary{positioning}
\usetikzlibrary{3d} %for including external image
\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
\def\ConvReluColor{rgb:yellow,5;red,5}
\def\bnColor{rgb:yellow,5;red,5}
\def\PoolColor{rgb:red,1;black,0}
\def\UnpoolColor{rgb:blue,2;green,1;black,0.3}
\def\FcColor{rgb:blue,5;red,2.5;white,5}
\def\FcReluColor{rgb:blue,5;red,5;white,4}
\def\SoftmaxColor{rgb:magenta,5;black,7}
\def\SumColor{rgb:blue,5;green,15}
\def\LayerColor{rgb:black,1}
\newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width =1mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);}
\begin{document}
\noindent
\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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node[canvas is zy plane at x=0](temp) at (-3.5,0,0) {\includegraphics[width=-20cm,height=20cm]{pics/03-LC-ser-sub-20-mirror}};
\path (-4,0,0);
% input
\pic[shift={(0,0,0)}] at (0,0,0) {
Box={
name=input,
caption=Input,
xlabel= 3,
ylabel=224,
zlabel= \qquad 224,
fill=\ConvColor,
height=100,
width=0.1,
depth=100
}
};
% conv1
\pic[shift={(1.5,0,0)}] at (input-east) {
RightBandedBox={
name= conv1,
caption=Conv1,
xlabel={{"64",""}},
ylabel=112,
zlabel= \qquad 112,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=50,
width=2.1,
depth=50
}
};
% MaxPool2d
\pic[shift={(1,0,0)}] at (conv1-east) {
RightBandedBox={
name= MaxPool,
xlabel={{"64",""}},
ylabel=112,
fill=\PoolColor,
height=50,
width=2.1,
depth=50
}
};
% layer1
% conv1_1
\pic[shift={(3,0,0)}] at (MaxPool-east) {
RightBandedBox={
name= conv1_1,
xlabel={{"64",""}},
ylabel= 112,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=50,
width=2.1,
depth=50
}
};
% conv1_2
\pic[shift={(0,0,0)}] at (conv1_1-east) {
RightBandedBox={
name= conv1_2,
xlabel={{"\quad 64",""}},
zlabel= \qquad 112,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=50,
width=2.1,
depth=50
}
};
% conv1_3
\pic[shift={(0,0,0)}] at (conv1_2-east) {
RightBandedBox={
name= conv1_3,
xlabel={{"\quad 256",""}},
zlabel= \qquad 112,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=50,
width=8.4,
depth=50
}
};
% add1_1
\pic[shift={(2,0,0)}] at (conv1_3-east) {
Ball={
name=add1_1,
fill=\SumColor,
opacity=0.6,
radius=2,
logo=\(+\)
}
};
\pic[shift={(-0.2,0,1)}] at (conv1_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 3}},%
xlabel={{"","dummy"}},fill=,opacity=0.1,height=60,width={18.4},depth=60}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pic[shift={(4,0,0)}] at (conv1_3-east) {
RightBandedBox={
name= conv2_1,
xlabel={{"128",""}},
ylabel= 56,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=25,
width=4.2,
depth=25
}
};
% conv2_2
\pic[shift={(0,0,0)}] at (conv2_1-east) {
RightBandedBox={
name= conv2_2,
xlabel={{"128",""}},
zlabel= \qquad 56,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=25,
width=4.2,
depth=25
}
};
% conv2_3
\pic[shift={(0,0,0)}] at (conv2_2-east) {
RightBandedBox={
name= conv2_3,
xlabel={{"512",""}},
zlabel= \qquad 56,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=25,
width=16.8,
depth=25
}
};
% add1_2
\pic[shift={(2,0,0)}] at (conv2_3-east) {
Ball={
name=add1_2,
fill=\SumColor,
opacity=0.6,
radius=2,
logo=\(+\)
}
};
\pic[shift={(-0.4,0,1)}] at (conv2_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 4}},%
xlabel={{"","dummy"}},fill=,opacity=0.1,height=30,width={36.8},depth=30}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv3_1
\pic[shift={(4,0,0)}] at (conv2_3-east) {
RightBandedBox={
name= conv3_1,
xlabel={{"256",""}},
ylabel= 28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=12.5,
width=8.4,
depth=12.5
}
};
% conv3_2
\pic[shift={(0,0,0)}] at (conv3_1-east) {
RightBandedBox={
name= conv3_2,
xlabel={{"256",""}},
zlabel= 28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=12.5,
width=8.4,
depth=12.5
}
};
% conv3_3
\pic[shift={(0,0,0)}] at (conv3_2-east) {
RightBandedBox={
name= conv3_3,
xlabel={{"1024",""}},
zlabel= 28,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=12.5,
width=33.6,
depth=12.5
}
};
% add1_3
\pic[shift={(2,0,0)}] at (conv3_3-east) {
Ball={
name=add1_3,
fill=\SumColor,
opacity=0.6,
radius=2,
logo=\(+\)
}
};
\pic[shift={(-0.6,0,1)}] at (conv3_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 23}},%
xlabel={{"","dummy"}},fill=,opacity=0.1,height=20,width={63.6},depth=20}};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conv4_1
\pic[shift={(4,0,0)}] at (conv3_3-east) {
RightBandedBox={
name= conv4_1,
xlabel={{"512",""}},
ylabel= 14,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=6.25,
width=16.8,
depth=6.25
}
};
% conv4_2
\pic[shift={(0,0,0)}] at (conv4_1-east) {
RightBandedBox={
name= conv4_2,
xlabel={{"512",""}},
ylabel= 14,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=6.25,
width=16.8,
depth=6.25
}
};
% conv4_3
\pic[shift={(0,0,0)}] at (conv4_2-east) {
RightBandedBox={
name= conv4_3,
xlabel={{"2048",""}},
ylabel= 14,
fill=\ConvColor,
bandfill=\ConvReluColor,
height=6.25,
width=67.2,
depth=6.25
}
};
% add1_4
\pic[shift={(2,0,0)}] at (conv4_3-east) {
Ball={
name=add1_4,
fill=\SumColor,
opacity=0.6,
radius=2,
logo= \(+\)
}
};
\pic[shift={(-0.8,0,0)}] at (conv4_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 3}},%
xlabel={{"","dummy"}},fill=,opacity=0.1,height=15,width={110.2},depth=15}};
% avgpool
\pic[shift={(4,0,0)}] at (add1_4-east) {
Box={
name=avgpool,
caption= \\ avgpool,
xlabel={{"1",""}},
ylabel=1,
zlabel=\qquad 2048,
fill=\PoolColor,
height=2,
width=2,
depth=200
}
};
% fullconnection
\pic[shift={(2,0,0)}] at (avgpool-east) {
RightBandedBox={
name=fc,
caption=\makebox[0pt]{
\shortstack[c]{\\ full \, connection\\softmax}},
xlabel={{"1",""}},
zlabel=\qquad 3,
fill=\FcColor,
bandfill=\SoftmaxColor,
height=2,
width=2,
depth=20
}
};
% connections
\draw [connection] (input-east) -- node {\midarrow} (conv1-west);
\draw [connection] (conv1-east) -- node {\midarrow} (MaxPool-west);
\draw [connection] (MaxPool-east) -- node {\midarrow} (conv1_1-west);
% connections shortcut
% conv1 to add1_1
\path (MaxPool-east) -- (conv1_1-west) coordinate[pos=0.5] (pool_conv1_1);
\path (pool_conv1_1) ++ (0,5,0) coordinate (pool_conv1_1_above);
\path (add1_1-north) ++ (0,5,0) coordinate (add1_1-north-above);
\draw [connection] (pool_conv1_1) -- node {\midarrow} (pool_conv1_1_above|-add1_1-north-above) -- node {\midarrow} (add1_1-north-above) -- node {\midarrow} (add1_1-north);
\draw [connection] (conv1_3-east) -- (add1_1-west);
\draw [connection] (add1_1-east) -- node {\midarrow} (conv2_1-west);
%
\path (conv1_3-east) -- (conv2_1-west) coordinate[pos=0.65] (add_conv_1); % conv1 -> conv2
\path (add_conv_1) ++ (0,5,0) coordinate (add_conv_1-above);
\path (add1_2-north) ++ (0,5,0) coordinate (add1_2-north-above);
\draw [connection] (add_conv_1) -- node {\midarrow} (add_conv_1-above|-add1_2-north-above) -- node {\midarrow} (add1_2-north-above) -- node {\midarrow} (add1_2-north);
\draw [connection] (conv2_3-east) -- (add1_2-west);
\draw [connection] (add1_2-east) -- node {\midarrow} (conv3_1-west);
%%%%%%%%%%%%%%
\path (conv2_3-east) -- (conv3_1-west) coordinate[pos=0.75] (add_conv_2);
\path (add_conv_2) ++ (0,5,0) coordinate (add_conv_2-above);
\path (add1_3-north) ++ (0,5,0) coordinate (add1_3-north-above);
\draw [connection] (add_conv_2) -- node {\midarrow} (add_conv_2-above|-add1_3-north-above) -- node {\midarrow} (add1_3-north-above) -- node {\midarrow} (add1_3-north);
\draw [connection] (conv3_3-east) -- (add1_3-west);
\draw [connection] (add1_3-east) -- node {\midarrow} (conv4_1-west);
%%%%%%%%%%%%%%%
\path (conv3_3-east) -- (conv4_1-west) coordinate[pos=0.75] (add_conv_3);
\path (add_conv_3) ++ (0,5,0) coordinate (add_conv_3-above);
\path (add1_4-north) ++ (0,5,0) coordinate (add1_4-north-above);
\draw [connection] (add_conv_3) -- node {\midarrow} (add_conv_3-above|-add1_4-north-above) -- node {\midarrow} (add1_4-north-above) -- node {\midarrow} (add1_4-north);
\draw [connection] (conv4_3-east) -- (add1_4-west);
%\draw [connection] (add1_4-east) -- node {\midarrow} (conv4_1-west);
\draw [connection](add1_4-east) -- node {\midarrow}(avgpool-west);
\draw [connection](avgpool-east) -- node {\midarrow}(fc-west);
% pool & fullconnection
\draw [densely dashed] (avgpool-nearnortheast) -- (fc-nearnorthwest);
\draw [densely dashed] (avgpool-nearsoutheast) -- (fc-nearsouthwest);
\draw [densely dashed] (avgpool-farnortheast) -- (fc-farnorthwest);
\draw [densely dashed] (avgpool-farsoutheast) -- (fc-farsouthwest);
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document} |
I guess you set the transparency to 1
…---Original---
From: ***@***.***>
Date: Thu, Jun 2, 2022 07:21 AM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [HarisIqbal88/PlotNeuralNet] ResNet50 Tex (#24)
Hello, I tried the previous examples. It's compiled. But the result is strange.
Do you have any hints why I could not get opacity? I tried it on Linux and osX.
Thanks.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hmm, but I use all the .sty files from here. Also, I copy and past the code in the above. |
``` LaTeX\def\ConvColor{rgb:yellow,5;red,2.5;white,5}
```
this defined the color of Conv layer , and "white" mean transparency,you can check it
…---Original---
From: ***@***.***>
Date: Thu, Jun 2, 2022 08:18 AM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [HarisIqbal88/PlotNeuralNet] ResNet50 Tex (#24)
Hmm, but I use all the .sty files from here. Also, I copy and past the code in the above.
Do you know anyway I can set up the transparency in the tex file?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
A update: If I use pdflatex, everything is fine. If I use latex, there is no opacity effect. |
could u please share the .py file, thanks! |
sorry,i just use LaTeX,no Python project
…---Original---
From: ***@***.***>
Date: Sun, Mar 12, 2023 14:15 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [HarisIqbal88/PlotNeuralNet] ResNet50 Tex (#24)
\documentclass[border=12pt, multi, tikz]{standalone} \usepackage[fontsize=14pt]{fontsize} \usepackage{import} \subimport{./layers/}{init} \usetikzlibrary{positioning} \usetikzlibrary{3d} %for including external image \def\ConvColor{rgb:yellow,5;red,2.5;white,5} \def\ConvReluColor{rgb:yellow,5;red,5} \def\bnColor{rgb:yellow,5;red,5} \def\PoolColor{rgb:red,1;black,0} \def\UnpoolColor{rgb:blue,2;green,1;black,0.3} \def\FcColor{rgb:blue,5;red,2.5;white,5} \def\FcReluColor{rgb:blue,5;red,5;white,4} \def\SoftmaxColor{rgb:magenta,5;black,7} \def\SumColor{rgb:blue,5;green,15} \def\LayerColor{rgb:black,1} \newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width =1mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);} \begin{document} \noindent \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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \node[canvas is zy plane at x=0](temp) at (-3.5,0,0) {\includegraphics[width=-20cm,height=20cm]{pics/03-LC-ser-sub-20-mirror}}; \path (-4,0,0); % input \pic[shift={(0,0,0)}] at (0,0,0) { Box={ name=input, caption=Input, xlabel= 3, ylabel=224, zlabel= \qquad 224, fill=\ConvColor, height=100, width=0.1, depth=100 } }; % conv1 \pic[shift={(1.5,0,0)}] at (input-east) { RightBandedBox={ name= conv1, caption=Conv1, xlabel={{"64",""}}, ylabel=112, zlabel= \qquad 112, fill=\ConvColor, bandfill=\ConvReluColor, height=50, width=2.1, depth=50 } }; % MaxPool2d \pic[shift={(1,0,0)}] at (conv1-east) { RightBandedBox={ name= MaxPool, xlabel={{"64",""}}, ylabel=112, fill=\PoolColor, height=50, width=2.1, depth=50 } }; % layer1 % conv1_1 \pic[shift={(3,0,0)}] at (MaxPool-east) { RightBandedBox={ name= conv1_1, xlabel={{"64",""}}, ylabel= 112, fill=\ConvColor, bandfill=\ConvReluColor, height=50, width=2.1, depth=50 } }; % conv1_2 \pic[shift={(0,0,0)}] at (conv1_1-east) { RightBandedBox={ name= conv1_2, xlabel={{"\quad 64",""}}, zlabel= \qquad 112, fill=\ConvColor, bandfill=\ConvReluColor, height=50, width=2.1, depth=50 } }; % conv1_3 \pic[shift={(0,0,0)}] at (conv1_2-east) { RightBandedBox={ name= conv1_3, xlabel={{"\quad 256",""}}, zlabel= \qquad 112, fill=\ConvColor, bandfill=\ConvReluColor, height=50, width=8.4, depth=50 } }; % add1_1 \pic[shift={(2,0,0)}] at (conv1_3-east) { Ball={ name=add1_1, fill=\SumColor, opacity=0.6, radius=2, logo=\(+\) } }; \pic[shift={(-0.2,0,1)}] at (conv1_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 3}},% xlabel={{"","dummy"}},fill=,opacity=0.1,height=60,width={18.4},depth=60}}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pic[shift={(4,0,0)}] at (conv1_3-east) { RightBandedBox={ name= conv2_1, xlabel={{"128",""}}, ylabel= 56, fill=\ConvColor, bandfill=\ConvReluColor, height=25, width=4.2, depth=25 } }; % conv2_2 \pic[shift={(0,0,0)}] at (conv2_1-east) { RightBandedBox={ name= conv2_2, xlabel={{"128",""}}, zlabel= \qquad 56, fill=\ConvColor, bandfill=\ConvReluColor, height=25, width=4.2, depth=25 } }; % conv2_3 \pic[shift={(0,0,0)}] at (conv2_2-east) { RightBandedBox={ name= conv2_3, xlabel={{"512",""}}, zlabel= \qquad 56, fill=\ConvColor, bandfill=\ConvReluColor, height=25, width=16.8, depth=25 } }; % add1_2 \pic[shift={(2,0,0)}] at (conv2_3-east) { Ball={ name=add1_2, fill=\SumColor, opacity=0.6, radius=2, logo=\(+\) } }; \pic[shift={(-0.4,0,1)}] at (conv2_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 4}},% xlabel={{"","dummy"}},fill=,opacity=0.1,height=30,width={36.8},depth=30}}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % conv3_1 \pic[shift={(4,0,0)}] at (conv2_3-east) { RightBandedBox={ name= conv3_1, xlabel={{"256",""}}, ylabel= 28, fill=\ConvColor, bandfill=\ConvReluColor, height=12.5, width=8.4, depth=12.5 } }; % conv3_2 \pic[shift={(0,0,0)}] at (conv3_1-east) { RightBandedBox={ name= conv3_2, xlabel={{"256",""}}, zlabel= 28, fill=\ConvColor, bandfill=\ConvReluColor, height=12.5, width=8.4, depth=12.5 } }; % conv3_3 \pic[shift={(0,0,0)}] at (conv3_2-east) { RightBandedBox={ name= conv3_3, xlabel={{"1024",""}}, zlabel= 28, fill=\ConvColor, bandfill=\ConvReluColor, height=12.5, width=33.6, depth=12.5 } }; % add1_3 \pic[shift={(2,0,0)}] at (conv3_3-east) { Ball={ name=add1_3, fill=\SumColor, opacity=0.6, radius=2, logo=\(+\) } }; \pic[shift={(-0.6,0,1)}] at (conv3_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 23}},% xlabel={{"","dummy"}},fill=,opacity=0.1,height=20,width={63.6},depth=20}}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % conv4_1 \pic[shift={(4,0,0)}] at (conv3_3-east) { RightBandedBox={ name= conv4_1, xlabel={{"512",""}}, ylabel= 14, fill=\ConvColor, bandfill=\ConvReluColor, height=6.25, width=16.8, depth=6.25 } }; % conv4_2 \pic[shift={(0,0,0)}] at (conv4_1-east) { RightBandedBox={ name= conv4_2, xlabel={{"512",""}}, ylabel= 14, fill=\ConvColor, bandfill=\ConvReluColor, height=6.25, width=16.8, depth=6.25 } }; % conv4_3 \pic[shift={(0,0,0)}] at (conv4_2-east) { RightBandedBox={ name= conv4_3, xlabel={{"2048",""}}, ylabel= 14, fill=\ConvColor, bandfill=\ConvReluColor, height=6.25, width=67.2, depth=6.25 } }; % add1_4 \pic[shift={(2,0,0)}] at (conv4_3-east) { Ball={ name=add1_4, fill=\SumColor, opacity=0.6, radius=2, logo= \(+\) } }; \pic[shift={(-0.8,0,0)}] at (conv4_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 3}},% xlabel={{"","dummy"}},fill=,opacity=0.1,height=15,width={110.2},depth=15}}; % avgpool \pic[shift={(4,0,0)}] at (add1_4-east) { Box={ name=avgpool, caption= \\ avgpool, xlabel={{"1",""}}, ylabel=1, zlabel=\qquad 2048, fill=\PoolColor, height=2, width=2, depth=200 } }; % fullconnection \pic[shift={(2,0,0)}] at (avgpool-east) { RightBandedBox={ name=fc, caption=\makebox[0pt]{ \shortstack[c]{\\ full \, connection\\softmax}}, xlabel={{"1",""}}, zlabel=\qquad 3, fill=\FcColor, bandfill=\SoftmaxColor, height=2, width=2, depth=20 } }; % connections \draw [connection] (input-east) -- node {\midarrow} (conv1-west); \draw [connection] (conv1-east) -- node {\midarrow} (MaxPool-west); \draw [connection] (MaxPool-east) -- node {\midarrow} (conv1_1-west); % connections shortcut % conv1 to add1_1 \path (MaxPool-east) -- (conv1_1-west) coordinate[pos=0.5] (pool_conv1_1); \path (pool_conv1_1) ++ (0,5,0) coordinate (pool_conv1_1_above); \path (add1_1-north) ++ (0,5,0) coordinate (add1_1-north-above); \draw [connection] (pool_conv1_1) -- node {\midarrow} (pool_conv1_1_above|-add1_1-north-above) -- node {\midarrow} (add1_1-north-above) -- node {\midarrow} (add1_1-north); \draw [connection] (conv1_3-east) -- (add1_1-west); \draw [connection] (add1_1-east) -- node {\midarrow} (conv2_1-west); % \path (conv1_3-east) -- (conv2_1-west) coordinate[pos=0.65] (add_conv_1); % conv1 -> conv2 \path (add_conv_1) ++ (0,5,0) coordinate (add_conv_1-above); \path (add1_2-north) ++ (0,5,0) coordinate (add1_2-north-above); \draw [connection] (add_conv_1) -- node {\midarrow} (add_conv_1-above|-add1_2-north-above) -- node {\midarrow} (add1_2-north-above) -- node {\midarrow} (add1_2-north); \draw [connection] (conv2_3-east) -- (add1_2-west); \draw [connection] (add1_2-east) -- node {\midarrow} (conv3_1-west); %%%%%%%%%%%%%% \path (conv2_3-east) -- (conv3_1-west) coordinate[pos=0.75] (add_conv_2); \path (add_conv_2) ++ (0,5,0) coordinate (add_conv_2-above); \path (add1_3-north) ++ (0,5,0) coordinate (add1_3-north-above); \draw [connection] (add_conv_2) -- node {\midarrow} (add_conv_2-above|-add1_3-north-above) -- node {\midarrow} (add1_3-north-above) -- node {\midarrow} (add1_3-north); \draw [connection] (conv3_3-east) -- (add1_3-west); \draw [connection] (add1_3-east) -- node {\midarrow} (conv4_1-west); %%%%%%%%%%%%%%% \path (conv3_3-east) -- (conv4_1-west) coordinate[pos=0.75] (add_conv_3); \path (add_conv_3) ++ (0,5,0) coordinate (add_conv_3-above); \path (add1_4-north) ++ (0,5,0) coordinate (add1_4-north-above); \draw [connection] (add_conv_3) -- node {\midarrow} (add_conv_3-above|-add1_4-north-above) -- node {\midarrow} (add1_4-north-above) -- node {\midarrow} (add1_4-north); \draw [connection] (conv4_3-east) -- (add1_4-west); %\draw [connection] (add1_4-east) -- node {\midarrow} (conv4_1-west); \draw [connection](add1_4-east) -- node {\midarrow}(avgpool-west); \draw [connection](avgpool-east) -- node {\midarrow}(fc-west); % pool & fullconnection \draw [densely dashed] (avgpool-nearnortheast) -- (fc-nearnorthwest); \draw [densely dashed] (avgpool-nearsoutheast) -- (fc-nearsouthwest); \draw [densely dashed] (avgpool-farnortheast) -- (fc-farnorthwest); \draw [densely dashed] (avgpool-farsoutheast) -- (fc-farsouthwest); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{tikzpicture} \end{document}
could u please share the .py file, thanks!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Thank u so much, u’r so kind, have a good day!
发件人: ***@***.***>
发送时间: 2023年3月12日 18:41
收件人: ***@***.***>
抄送: ***@***.***>; ***@***.***>
主题: Re: [HarisIqbal88/PlotNeuralNet] ResNet50 Tex (#24)
sorry,i just use LaTeX,no Python project
…---Original---
From: ***@***.***>
Date: Sun, Mar 12, 2023 14:15 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [HarisIqbal88/PlotNeuralNet] ResNet50 Tex (#24)
\documentclass[border=12pt, multi, tikz]{standalone} \usepackage[fontsize=14pt]{fontsize} \usepackage{import} \subimport{./layers/}{init} \usetikzlibrary{positioning} \usetikzlibrary{3d} %for including external image \def\ConvColor{rgb:yellow,5;red,2.5;white,5} \def\ConvReluColor{rgb:yellow,5;red,5} \def\bnColor{rgb:yellow,5;red,5} \def\PoolColor{rgb:red,1;black,0} \def\UnpoolColor{rgb:blue,2;green,1;black,0.3} \def\FcColor{rgb:blue,5;red,2.5;white,5} \def\FcReluColor{rgb:blue,5;red,5;white,4} \def\SoftmaxColor{rgb:magenta,5;black,7} \def\SumColor{rgb:blue,5;green,15} \def\LayerColor{rgb:black,1} \newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width =1mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);} \begin{document} \noindent \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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \node[canvas is zy plane at x=0](temp) at (-3.5,0,0) {\includegraphics[width=-20cm,height=20cm]{pics/03-LC-ser-sub-20-mirror}}; \path (-4,0,0); % input \pic[shift={(0,0,0)}] at (0,0,0) { Box={ name=input, caption=Input, xlabel= 3, ylabel=224, zlabel= \qquad 224, fill=\ConvColor, height=100, width=0.1, depth=100 } }; % conv1 \pic[shift={(1.5,0,0)}] at (input-east) { RightBandedBox={ name= conv1, caption=Conv1, xlabel={{"64",""}}, ylabel=112, zlabel= \qquad 112, fill=\ConvColor, bandfill=\ConvReluColor, height=50, width=2.1, depth=50 } }; % MaxPool2d \pic[shift={(1,0,0)}] at (conv1-east) { RightBandedBox={ name= MaxPool, xlabel={{"64",""}}, ylabel=112, fill=\PoolColor, height=50, width=2.1, depth=50 } }; % layer1 % conv1_1 \pic[shift={(3,0,0)}] at (MaxPool-east) { RightBandedBox={ name= conv1_1, xlabel={{"64",""}}, ylabel= 112, fill=\ConvColor, bandfill=\ConvReluColor, height=50, width=2.1, depth=50 } }; % conv1_2 \pic[shift={(0,0,0)}] at (conv1_1-east) { RightBandedBox={ name= conv1_2, xlabel={{"\quad 64",""}}, zlabel= \qquad 112, fill=\ConvColor, bandfill=\ConvReluColor, height=50, width=2.1, depth=50 } }; % conv1_3 \pic[shift={(0,0,0)}] at (conv1_2-east) { RightBandedBox={ name= conv1_3, xlabel={{"\quad 256",""}}, zlabel= \qquad 112, fill=\ConvColor, bandfill=\ConvReluColor, height=50, width=8.4, depth=50 } }; % add1_1 \pic[shift={(2,0,0)}] at (conv1_3-east) { Ball={ name=add1_1, fill=\SumColor, opacity=0.6, radius=2, logo=\(+\) } }; \pic[shift={(-0.2,0,1)}] at (conv1_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 3}},% xlabel={{"","dummy"}},fill=,opacity=0.1,height=60,width={18.4},depth=60}}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pic[shift={(4,0,0)}] at (conv1_3-east) { RightBandedBox={ name= conv2_1, xlabel={{"128",""}}, ylabel= 56, fill=\ConvColor, bandfill=\ConvReluColor, height=25, width=4.2, depth=25 } }; % conv2_2 \pic[shift={(0,0,0)}] at (conv2_1-east) { RightBandedBox={ name= conv2_2, xlabel={{"128",""}}, zlabel= \qquad 56, fill=\ConvColor, bandfill=\ConvReluColor, height=25, width=4.2, depth=25 } }; % conv2_3 \pic[shift={(0,0,0)}] at (conv2_2-east) { RightBandedBox={ name= conv2_3, xlabel={{"512",""}}, zlabel= \qquad 56, fill=\ConvColor, bandfill=\ConvReluColor, height=25, width=16.8, depth=25 } }; % add1_2 \pic[shift={(2,0,0)}] at (conv2_3-east) { Ball={ name=add1_2, fill=\SumColor, opacity=0.6, radius=2, logo=\(+\) } }; \pic[shift={(-0.4,0,1)}] at (conv2_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 4}},% xlabel={{"","dummy"}},fill=,opacity=0.1,height=30,width={36.8},depth=30}}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % conv3_1 \pic[shift={(4,0,0)}] at (conv2_3-east) { RightBandedBox={ name= conv3_1, xlabel={{"256",""}}, ylabel= 28, fill=\ConvColor, bandfill=\ConvReluColor, height=12.5, width=8.4, depth=12.5 } }; % conv3_2 \pic[shift={(0,0,0)}] at (conv3_1-east) { RightBandedBox={ name= conv3_2, xlabel={{"256",""}}, zlabel= 28, fill=\ConvColor, bandfill=\ConvReluColor, height=12.5, width=8.4, depth=12.5 } }; % conv3_3 \pic[shift={(0,0,0)}] at (conv3_2-east) { RightBandedBox={ name= conv3_3, xlabel={{"1024",""}}, zlabel= 28, fill=\ConvColor, bandfill=\ConvReluColor, height=12.5, width=33.6, depth=12.5 } }; % add1_3 \pic[shift={(2,0,0)}] at (conv3_3-east) { Ball={ name=add1_3, fill=\SumColor, opacity=0.6, radius=2, logo=\(+\) } }; \pic[shift={(-0.6,0,1)}] at (conv3_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 23}},% xlabel={{"","dummy"}},fill=,opacity=0.1,height=20,width={63.6},depth=20}}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % conv4_1 \pic[shift={(4,0,0)}] at (conv3_3-east) { RightBandedBox={ name= conv4_1, xlabel={{"512",""}}, ylabel= 14, fill=\ConvColor, bandfill=\ConvReluColor, height=6.25, width=16.8, depth=6.25 } }; % conv4_2 \pic[shift={(0,0,0)}] at (conv4_1-east) { RightBandedBox={ name= conv4_2, xlabel={{"512",""}}, ylabel= 14, fill=\ConvColor, bandfill=\ConvReluColor, height=6.25, width=16.8, depth=6.25 } }; % conv4_3 \pic[shift={(0,0,0)}] at (conv4_2-east) { RightBandedBox={ name= conv4_3, xlabel={{"2048",""}}, ylabel= 14, fill=\ConvColor, bandfill=\ConvReluColor, height=6.25, width=67.2, depth=6.25 } }; % add1_4 \pic[shift={(2,0,0)}] at (conv4_3-east) { Ball={ name=add1_4, fill=\SumColor, opacity=0.6, radius=2, logo= \(+\) } }; \pic[shift={(-0.8,0,0)}] at (conv4_1-west) {Box={name=env,caption=\textbf{\large{$\times$ 3}},% xlabel={{"","dummy"}},fill=,opacity=0.1,height=15,width={110.2},depth=15}}; % avgpool \pic[shift={(4,0,0)}] at (add1_4-east) { Box={ name=avgpool, caption= \\ avgpool, xlabel={{"1",""}}, ylabel=1, zlabel=\qquad 2048, fill=\PoolColor, height=2, width=2, depth=200 } }; % fullconnection \pic[shift={(2,0,0)}] at (avgpool-east) { RightBandedBox={ name=fc, caption=\makebox[0pt]{ \shortstack[c]{\\ full \, connection\\softmax}}, xlabel={{"1",""}}, zlabel=\qquad 3, fill=\FcColor, bandfill=\SoftmaxColor, height=2, width=2, depth=20 } }; % connections \draw [connection] (input-east) -- node {\midarrow} (conv1-west); \draw [connection] (conv1-east) -- node {\midarrow} (MaxPool-west); \draw [connection] (MaxPool-east) -- node {\midarrow} (conv1_1-west); % connections shortcut % conv1 to add1_1 \path (MaxPool-east) -- (conv1_1-west) coordinate[pos=0.5] (pool_conv1_1); \path (pool_conv1_1) ++ (0,5,0) coordinate (pool_conv1_1_above); \path (add1_1-north) ++ (0,5,0) coordinate (add1_1-north-above); \draw [connection] (pool_conv1_1) -- node {\midarrow} (pool_conv1_1_above|-add1_1-north-above) -- node {\midarrow} (add1_1-north-above) -- node {\midarrow} (add1_1-north); \draw [connection] (conv1_3-east) -- (add1_1-west); \draw [connection] (add1_1-east) -- node {\midarrow} (conv2_1-west); % \path (conv1_3-east) -- (conv2_1-west) coordinate[pos=0.65] (add_conv_1); % conv1 -> conv2 \path (add_conv_1) ++ (0,5,0) coordinate (add_conv_1-above); \path (add1_2-north) ++ (0,5,0) coordinate (add1_2-north-above); \draw [connection] (add_conv_1) -- node {\midarrow} (add_conv_1-above|-add1_2-north-above) -- node {\midarrow} (add1_2-north-above) -- node {\midarrow} (add1_2-north); \draw [connection] (conv2_3-east) -- (add1_2-west); \draw [connection] (add1_2-east) -- node {\midarrow} (conv3_1-west); %%%%%%%%%%%%%% \path (conv2_3-east) -- (conv3_1-west) coordinate[pos=0.75] (add_conv_2); \path (add_conv_2) ++ (0,5,0) coordinate (add_conv_2-above); \path (add1_3-north) ++ (0,5,0) coordinate (add1_3-north-above); \draw [connection] (add_conv_2) -- node {\midarrow} (add_conv_2-above|-add1_3-north-above) -- node {\midarrow} (add1_3-north-above) -- node {\midarrow} (add1_3-north); \draw [connection] (conv3_3-east) -- (add1_3-west); \draw [connection] (add1_3-east) -- node {\midarrow} (conv4_1-west); %%%%%%%%%%%%%%% \path (conv3_3-east) -- (conv4_1-west) coordinate[pos=0.75] (add_conv_3); \path (add_conv_3) ++ (0,5,0) coordinate (add_conv_3-above); \path (add1_4-north) ++ (0,5,0) coordinate (add1_4-north-above); \draw [connection] (add_conv_3) -- node {\midarrow} (add_conv_3-above|-add1_4-north-above) -- node {\midarrow} (add1_4-north-above) -- node {\midarrow} (add1_4-north); \draw [connection] (conv4_3-east) -- (add1_4-west); %\draw [connection] (add1_4-east) -- node {\midarrow} (conv4_1-west); \draw [connection](add1_4-east) -- node {\midarrow}(avgpool-west); \draw [connection](avgpool-east) -- node {\midarrow}(fc-west); % pool & fullconnection \draw [densely dashed] (avgpool-nearnortheast) -- (fc-nearnorthwest); \draw [densely dashed] (avgpool-nearsoutheast) -- (fc-nearsouthwest); \draw [densely dashed] (avgpool-farnortheast) -- (fc-farnorthwest); \draw [densely dashed] (avgpool-farsoutheast) -- (fc-farsouthwest); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{tikzpicture} \end{document}
could u please share the .py file, thanks!
―
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
―
Reply to this email directly, view it on GitHub<#24 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A6DT7CNFVXH5SF7IREC5WHDW3WR5VANCNFSM4G27VQQQ>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Thanks for your prefect code, maybe the
|
hello, I have a question: "\subimport{../../layers/}{init}",the layers looks like a folder, would you please tell me what I should do? Because I don't have a layers and init. In addition, how do you run it? like "pdflatex resnet34.tex"? I have found the plotNeuralNet on github, it means to edit a "resnet34.py", then run commond "bash ../tikzmake.sh resnet34", It confuse me a lot. Best wishes! |
Hi, it's a folder originally from this repo, pdflatex should work, please edit the path to fit yours accordingly. |
\documentclass[border=12pt, multi, tikz]{standalone} \def\ConvColor{rgb:yellow,5;red,2.5;white,5} \newcommand{\copymidarrow}{\tikz \draw[-Stealth,line width =1mm,draw={rgb:blue,4;red,1;green,1;black,3}] (-0.3,0) -- ++(0.3,0);} \begin{document}
|
Will it be possible to get .tex for ResNet50?
When I am trying to define the architecture in python example: arch.py and then use the command "./tikzmake.sh arch" it is not working and giving me the following error:
The text was updated successfully, but these errors were encountered: