max-pooling.tex 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. \documentclass{standalone}
  2. \usepackage{amssymb}
  3. \usepackage{tikz}
  4. \usetikzlibrary{arrows.meta}
  5. \usetikzlibrary{decorations.pathreplacing}
  6. \begin{document}
  7. \definecolor{c1}{HTML}{9ACFC6}
  8. \definecolor{c2}{HTML}{DABBD6}
  9. \definecolor{c3}{HTML}{CBDCB9}
  10. \definecolor{c4}{HTML}{9AC3E1}
  11. \definecolor{c5}{HTML}{DEBBA5}
  12. \definecolor{c6}{HTML}{C4DDE5}
  13. \newcommand*{\xMin}{0}%
  14. \newcommand*{\xMax}{6}%
  15. \newcommand*{\yMin}{0}%
  16. \newcommand*{\yMax}{4}%
  17. \newcommand*{\xMinR}{9.5}%
  18. \newcommand*{\xMaxR}{12.5}%
  19. \newcommand*{\yMinR}{1}%
  20. \newcommand*{\yMaxR}{3}%
  21. \begin{tikzpicture}
  22. \fill [c1] (0, 0) rectangle (2, 2);
  23. \fill [c2] (2, 0) rectangle (4, 2);
  24. \fill [c3] (4, 0) rectangle (6, 2);
  25. \fill [c4] (0, 2) rectangle (2, 4);
  26. \fill [c5] (2, 2) rectangle (4, 4);
  27. \fill [c6] (4, 2) rectangle (6, 4);
  28. \fill [c1] (9.5, 1) rectangle (10.5, 2);
  29. \fill [c2] (10.5, 1) rectangle (11.5, 2);
  30. \fill [c3] (11.5, 1) rectangle (12.5, 2);
  31. \fill [c4] (9.5, 2) rectangle (10.5, 3);
  32. \fill [c5] (10.5, 2) rectangle (11.5, 3);
  33. \fill [c6] (11.5, 2) rectangle (12.5, 3);
  34. \foreach \i in {\xMin,...,\xMax} {
  35. \draw [very thin,gray] (\i,\yMin) -- (\i,\yMax) node [below] at (\i,\yMin) {};
  36. }
  37. \foreach \i in {\yMin,...,\yMax} {
  38. \draw [very thin,gray] (\xMin,\i) -- (\xMax,\i) node [left] at (\xMin,\i) {};
  39. }
  40. % [7, 9, 3, 5, 9, 4,
  41. % 0, 7, 0, 0, 9, 0,
  42. % 5, 0, 9, 3, 7, 5,
  43. % 9, 2, 9, 6, 4, 3]
  44. \foreach \i in {\xMin,2,...,\xMax} {
  45. \draw [thick,gray] (\i,\yMin) -- (\i,\yMax) node [below] at (\i,\yMin) {};
  46. }
  47. \foreach \i in {\yMin,2,...,\yMax} {
  48. \draw [thick,gray] (\xMin,\i) -- (\xMax,\i) node [left] at (\xMin,\i) {};
  49. }
  50. \node at (0.5, 0.5) {7};
  51. \node at (1.5, 0.5) {9};
  52. \node at (2.5, 0.5) {3};
  53. \node at (3.5, 0.5) {5};
  54. \node at (4.5, 0.5) {9};
  55. \node at (5.5, 0.5) {4};
  56. %
  57. \node at (0.5, 1.5) {0};
  58. \node at (1.5, 1.5) {7};
  59. \node at (2.5, 1.5) {0};
  60. \node at (3.5, 1.5) {0};
  61. \node at (4.5, 1.5) {9};
  62. \node at (5.5, 1.5) {0};
  63. %
  64. \node at (0.5, 2.5) {5};
  65. \node at (1.5, 2.5) {0};
  66. \node at (2.5, 2.5) {9};
  67. \node at (3.5, 2.5) {3};
  68. \node at (4.5, 2.5) {7};
  69. \node at (5.5, 2.5) {5};
  70. %
  71. \node at (0.5, 3.5) {9};
  72. \node at (1.5, 3.5) {2};
  73. \node at (2.5, 3.5) {9};
  74. \node at (3.5, 3.5) {6};
  75. \node at (4.5, 3.5) {4};
  76. \node at (5.5, 3.5) {3};
  77. \draw[draw=black,line width=12pt,-{Latex[length=9mm]}] (6.5, 2) -- (9,2);
  78. \node[font=\footnotesize\bfseries] at (7.7, 2.5) {$2\times 2$ max pooling};
  79. \foreach \i in {\xMinR,...,\xMaxR} {
  80. \draw [thick,gray] (\i,\yMinR) -- (\i,\yMaxR) node [below] at (\i,\yMinR) {};
  81. }
  82. \foreach \i in {\yMinR,...,\yMaxR} {
  83. \draw [thick,gray] (\xMinR,\i) -- (\xMaxR,\i) node [left] at (\xMinR,\i) {};
  84. }
  85. \node at (10, 1.5) {9};
  86. \node at (11, 1.5) {5};
  87. \node at (12, 1.5) {9};
  88. \node at (10, 2.5) {9};
  89. \node at (11, 2.5) {9};
  90. \node at (12, 2.5) {7};
  91. \draw [decorate,decoration={brace,amplitude=4pt},xshift=-2pt,yshift=0pt]
  92. (0,2) -- (0,4) node [black,midway,xshift=-0.3cm] {\footnotesize $2$};
  93. \draw [decorate,decoration={brace,amplitude=4pt},xshift=0pt,yshift=2pt]
  94. (0,4) -- (2,4) node [black,midway,yshift=+0.3cm] {\footnotesize $2$};
  95. \end{tikzpicture}
  96. \end{document}