max-pooling.tex 3.2 KB

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