diff --git a/tikz/self-organizing-map/Makefile b/tikz/self-organizing-map/Makefile new file mode 100644 index 0000000..e4f3188 --- /dev/null +++ b/tikz/self-organizing-map/Makefile @@ -0,0 +1,35 @@ +SOURCE = self-organizing-map +DELAY = 80 +DENSITY = 300 +WIDTH = 512 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + make + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg + rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg + inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg + rm $(SOURCE)2.svg diff --git a/tikz/self-organizing-map/README.md b/tikz/self-organizing-map/README.md new file mode 100644 index 0000000..c1b8092 --- /dev/null +++ b/tikz/self-organizing-map/README.md @@ -0,0 +1,3 @@ +Compiled example +---------------- +![Example](self-organizing-map.png) diff --git a/tikz/self-organizing-map/self-organizing-map.png b/tikz/self-organizing-map/self-organizing-map.png new file mode 100644 index 0000000..fe44f2e Binary files /dev/null and b/tikz/self-organizing-map/self-organizing-map.png differ diff --git a/tikz/self-organizing-map/self-organizing-map.tex b/tikz/self-organizing-map/self-organizing-map.tex new file mode 100644 index 0000000..7c64fe2 --- /dev/null +++ b/tikz/self-organizing-map/self-organizing-map.tex @@ -0,0 +1,71 @@ +\documentclass[varwidth=true, border=2pt]{standalone} +\usepackage{tikz} + +\tikzstyle{neuron}=[draw,circle,minimum size=12pt,inner sep=0pt, fill=white] +\tikzstyle{stateTransition}=[very thick] +\tikzstyle{learned}=[text=red] +\tikzstyle{input}=[draw,fill=red!50,circle,minimum size=10pt,inner sep=0pt] + +\begin{document} + \newcommand\n{6} + \newcommand\xs{3} + \begin{tikzpicture} + \foreach \y in {1,...,\n}{ + \foreach \x in {1,...,\n}{ + \node (N-\y-\x)[neuron] at (0.55*\y + \x, 0.75*\y) {}; + } + } + + \foreach \x in {1,...,\xs}{ + \node (x-\x)[input] at (3+\x, -1) {$x_\x$}; + } + + \foreach \y in {1,...,\n}{ + \foreach \x in {1,...,\n}{ + \foreach \t in {1,...,\xs}{ + \draw[thin, dashed, black!50] (x-\t) -- (N-\y-\x) node [midway,above=-0.06cm,sloped] {}; + } + } + } + + \foreach \y in {1,...,\n}{ + \foreach \x in {1,...,\n}{ + \node (N-\y-\x)[neuron] at (0.55*\y + \x, 0.75*\y) {}; + } + } + + % Make it look more like a board + \draw[very thick, dashed, black!50] (N-1-1) -- (N-1-2) + -- (N-1-3) + -- (N-1-4) + -- (N-1-5) + -- (N-1-6) + -- (N-2-6) + -- (N-3-6) + -- (N-4-6) + -- (N-5-6) + -- (N-6-6) + -- (N-6-5) + -- (N-6-4) + -- (N-6-3) + -- (N-6-2) + -- (N-6-1) + -- (N-5-1) + -- (N-4-1) + -- (N-3-1) + -- (N-2-1) + -- (N-1-1); + + + % Neighborhood gets excited + \node (N-4-3)[neuron, fill=black!50] at (0.55*4 + 3, 0.75*4) {}; + \node (N-4-2)[neuron, fill=black!10] at (0.55*4 + 2, 0.75*4) {}; + \node (N-4-4)[neuron, fill=black!10] at (0.55*4 + 4, 0.75*4) {}; + \node (N-5-2)[neuron, fill=black!10] at (0.55*5 + 2, 0.75*5) {}; + \node (N-5-3)[neuron, fill=black!10] at (0.55*5 + 3, 0.75*5) {}; + \node (N-5-4)[neuron, fill=black!10] at (0.55*5 + 4, 0.75*5) {}; + \node (N-3-3)[neuron, fill=black!10] at (0.55*3 + 2, 0.75*3) {}; + \node (N-3-3)[neuron, fill=black!10] at (0.55*3 + 3, 0.75*3) {}; + \node (N-3-3)[neuron, fill=black!10] at (0.55*3 + 4, 0.75*3) {}; + \end{tikzpicture} +\end{document}