self-organizing-map.tex 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. \documentclass[varwidth=true, border=2pt]{standalone}
  2. \usepackage{tikz}
  3. \tikzstyle{neuron}=[draw,circle,minimum size=12pt,inner sep=0pt, fill=white]
  4. \tikzstyle{stateTransition}=[very thick]
  5. \tikzstyle{learned}=[text=red]
  6. \tikzstyle{input}=[draw,fill=red!50,circle,minimum size=10pt,inner sep=0pt]
  7. \begin{document}
  8. \newcommand\n{6}
  9. \newcommand\xs{3}
  10. \begin{tikzpicture}
  11. \foreach \y in {1,...,\n}{
  12. \foreach \x in {1,...,\n}{
  13. \node (N-\y-\x)[neuron] at (0.55*\y + \x, 0.75*\y) {};
  14. }
  15. }
  16. \foreach \x in {1,...,\xs}{
  17. \node (x-\x)[input] at (3+\x, -1) {$x_\x$};
  18. }
  19. \foreach \y in {1,...,\n}{
  20. \foreach \x in {1,...,\n}{
  21. \foreach \t in {1,...,\xs}{
  22. \draw[thin, dashed, black!50] (x-\t) -- (N-\y-\x) node [midway,above=-0.06cm,sloped] {};
  23. }
  24. }
  25. }
  26. \foreach \y in {1,...,\n}{
  27. \foreach \x in {1,...,\n}{
  28. \node (N-\y-\x)[neuron] at (0.55*\y + \x, 0.75*\y) {};
  29. }
  30. }
  31. % Make it look more like a board
  32. \draw[very thick, dashed, black!50] (N-1-1) -- (N-1-2)
  33. -- (N-1-3)
  34. -- (N-1-4)
  35. -- (N-1-5)
  36. -- (N-1-6)
  37. -- (N-2-6)
  38. -- (N-3-6)
  39. -- (N-4-6)
  40. -- (N-5-6)
  41. -- (N-6-6)
  42. -- (N-6-5)
  43. -- (N-6-4)
  44. -- (N-6-3)
  45. -- (N-6-2)
  46. -- (N-6-1)
  47. -- (N-5-1)
  48. -- (N-4-1)
  49. -- (N-3-1)
  50. -- (N-2-1)
  51. -- (N-1-1);
  52. % Neighborhood gets excited
  53. \node (N-4-3)[neuron, fill=black!50] at (0.55*4 + 3, 0.75*4) {};
  54. \node (N-4-2)[neuron, fill=black!10] at (0.55*4 + 2, 0.75*4) {};
  55. \node (N-4-4)[neuron, fill=black!10] at (0.55*4 + 4, 0.75*4) {};
  56. \node (N-5-2)[neuron, fill=black!10] at (0.55*5 + 2, 0.75*5) {};
  57. \node (N-5-3)[neuron, fill=black!10] at (0.55*5 + 3, 0.75*5) {};
  58. \node (N-5-4)[neuron, fill=black!10] at (0.55*5 + 4, 0.75*5) {};
  59. \node (N-3-3)[neuron, fill=black!10] at (0.55*3 + 2, 0.75*3) {};
  60. \node (N-3-3)[neuron, fill=black!10] at (0.55*3 + 3, 0.75*3) {};
  61. \node (N-3-3)[neuron, fill=black!10] at (0.55*3 + 4, 0.75*3) {};
  62. \end{tikzpicture}
  63. \end{document}