diff --git a/tikz/activation-functions/Makefile b/tikz/activation-functions/Makefile new file mode 100644 index 0000000..df820b6 --- /dev/null +++ b/tikz/activation-functions/Makefile @@ -0,0 +1,33 @@ +SOURCE = activation-functions +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: + #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-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg + rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg + rm $(SOURCE)1.svg diff --git a/tikz/activation-functions/README.md b/tikz/activation-functions/README.md new file mode 100644 index 0000000..a5b11d2 --- /dev/null +++ b/tikz/activation-functions/README.md @@ -0,0 +1,3 @@ +Compiled example +---------------- +![Example](activation-functions.png) diff --git a/tikz/activation-functions/activation-functions.png b/tikz/activation-functions/activation-functions.png new file mode 100644 index 0000000..1f26f3e Binary files /dev/null and b/tikz/activation-functions/activation-functions.png differ diff --git a/tikz/activation-functions/activation-functions.tex b/tikz/activation-functions/activation-functions.tex new file mode 100644 index 0000000..9bfdc75 --- /dev/null +++ b/tikz/activation-functions/activation-functions.tex @@ -0,0 +1,50 @@ +\documentclass[varwidth=false, border=2pt]{standalone} + +\usepackage{pgfplots} +\usepackage{tikz} +\usepackage{xcolor} + +\begin{document} +\begin{tikzpicture} + \definecolor{color1}{HTML}{332288} + \definecolor{color2}{HTML}{FDB863} + \definecolor{color3}{HTML}{B2ABD2} + \definecolor{color4}{HTML}{5E3C99} + \begin{axis}[ + legend pos=north west, + legend cell align={left}, + axis x line=middle, + axis y line=middle, + x tick label style={/pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=1}, + y tick label style={/pgf/number format/fixed, + /pgf/number format/fixed zerofill, + /pgf/number format/precision=1}, + grid = major, + width=16cm, + height=8cm, + grid style={dashed, gray!30}, + xmin=-2, % start the diagram at this x-coordinate + xmax= 2, % end the diagram at this x-coordinate + ymin=-1, % start the diagram at this y-coordinate + ymax= 2, % end the diagram at this y-coordinate + %axis background/.style={fill=white}, + xlabel=x, + ylabel=y, + tick align=outside, + enlargelimits=false] + % plot the stirling-formulae + \addplot[domain=-2:2, color1, ultra thick,samples=500] {1/(1+exp(-x))}; + \addplot[domain=-2:2, color2, ultra thick,samples=500] {tanh(x)}; + \addplot[domain=-2:2, color4, ultra thick,samples=500] {max(0, x)}; + \addplot[domain=-2:2, color4, ultra thick,samples=500, dashed] {ln(exp(x) + 1)}; + \addplot[domain=-2:2, color3, ultra thick,samples=500, dotted] {max(x, exp(x) - 1)}; + \addlegendentry{$\varphi_1(x)=\frac{1}{1+e^{-x}}$} + \addlegendentry{$\varphi_2(x)=\tanh(x)$} + \addlegendentry{$\varphi_3(x)=\max(0, x)$} + \addlegendentry{$\varphi_4(x)=\log(e^x + 1)$} + \addlegendentry{$\varphi_5(x)=\max(x, e^x - 1)$} + \end{axis} +\end{tikzpicture} +\end{document}