-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathfigure6-11-a-max-pooling.tex
More file actions
98 lines (80 loc) · 2.79 KB
/
figure6-11-a-max-pooling.tex
File metadata and controls
98 lines (80 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
\documentclass[tikz, border=50pt]{standalone}
\usepackage{tikz}
\usepackage{medl_colors}
\usepackage{amsmath,xstring}
\usepackage{ifthen}
\usepackage{etoolbox}
\usetikzlibrary{shapes.multipart, shapes.geometric, arrows.meta, decorations.pathreplacing, calligraphy}
\usetikzlibrary{matrix, calc, positioning,fit, backgrounds, shapes}
\pgfdeclarelayer{layer1}
\pgfdeclarelayer{layer2}
\pgfdeclarelayer{layer3}
\pgfdeclarelayer{layer4}
\pgfsetlayers{layer4,layer3,layer2,layer1}
\def\arrayA{
{
%Array x
{
{2, 4, 10, 13}, {6, -4, 3, -2}, {7, -2, 0, -11}, {8, 3, -1, 0}
},
%Array z
{
{6,13}, {8,0}
}
}
}
\begin {document}
\newcommand\fillnumbers[4]{
\foreach \i in {0,...,#3}{
\foreach \j in {0,...,#3}{
\pgfmathparse{int(\arrayA[#4][\j][\i])} \edef\ele{\pgfmathresult};
\node[thick] at (#1+.5+\i,#2-.5-\j) {$\ele$};
}
}
}
\newcommand\slantarray[8]{
\draw[#6, line width=#7, opacity=0.8] (#1,#2) grid (#1+#3+1, #2-#4-1);
\pgfmathparse{#1+((#3+1)/2)}\edef\ni{\pgfmathresult};
\pgfmathparse{#2-#4-1.8}\edef\nj{\pgfmathresult};
\node[#6] at(\ni,\nj){\huge $#8$};
}
\newcommand\lines[8]{
\draw[#7, dashed, ultra thick, opacity=0.8] (#1,#2) -- (#3,#4);
\draw[#7, dashed, ultra thick, opacity=0.8] (#1+#5,#2) -- (#3+#6,#4);
\draw[#7, dashed, ultra thick, opacity=0.8] (#1,#2-#5) -- (#3,#4-#6);
\draw[#7, dashed, ultra thick, opacity=0.8] (#1+#5,#2-#5) -- (#3+#6,#4-#6);
}
\newcommand\fillbg[6]{
\begin{scope}
\node[rectangle,uthickline, minimum size=1cm,fill=#5, draw=#5] at (#1+.5+#3,#2-.5-#4){#6};
\end{scope}
}
\begin{tikzpicture}[remember picture, every node/.style={minimum size=1cm},on grid]
\begin{scope}[every node/.append style={yslant=0.3},yslant=0.3]
\begin{pgfonlayer}{layer4}
\slantarray{0}{0}{3}{3}{0}{border-grey}{2}{x};
\fillnumbers{0}{0}{3}{0};
\end{pgfonlayer}
\begin{pgfonlayer}{layer3}
\slantarray{2}{0}{1}{1}{1}{fill-red}{3}{};
\lines{2}{0}{8}{-5}{2}{1}{border-red}{border-red};
\slantarray{2}{-2}{1}{1}{1}{fill-yellow}{3}{};
\lines{2}{-2}{8}{-6}{2}{1}{border-yellow}{border-yellow};
\end{pgfonlayer}
\begin{pgfonlayer}{layer2}
\slantarray{0}{0}{1}{1}{0}{fill-blue}{3}{};
\lines{0}{0}{7}{-5}{2}{1}{border-blue}{border-blue};
\slantarray{0}{-2}{1}{1}{1}{fill-green}{3}{};
\lines{0}{-2}{7}{-6}{2}{1}{border-green}{border-green};
\end{pgfonlayer}
\begin{pgfonlayer}{layer1}
\slantarray{7}{-5}{1}{1}{1}{border-grey}{2}{z};
\fillbg{7}{-6}{0}{0}{fill-green}{};
\fillbg{7}{-5}{0}{0}{fill-blue}{};
\fillbg{8}{-6}{0}{0}{fill-yellow}{};
\fillbg{8}{-5}{0}{0}{fill-red}{};
\fillnumbers{7}{-5}{1}{1};
\end{pgfonlayer}
\end{scope}
\end{tikzpicture}
\end{document}