aboutsummaryrefslogtreecommitdiffstats
path: root/buch/papers/transfer
diff options
context:
space:
mode:
Diffstat (limited to 'buch/papers/transfer')
-rw-r--r--buch/papers/transfer/main.tex4
-rw-r--r--buch/papers/transfer/packages.tex5
-rw-r--r--buch/papers/transfer/references.bib27
-rw-r--r--buch/papers/transfer/teil0.tex242
-rw-r--r--buch/papers/transfer/teil1.tex89
-rw-r--r--buch/papers/transfer/teil2.tex92
-rw-r--r--buch/papers/transfer/teil3.tex50
-rw-r--r--buch/papers/transfer/teil4.tex218
8 files changed, 601 insertions, 126 deletions
diff --git a/buch/papers/transfer/main.tex b/buch/papers/transfer/main.tex
index ed16998..60f8230 100644
--- a/buch/papers/transfer/main.tex
+++ b/buch/papers/transfer/main.tex
@@ -3,7 +3,7 @@
%
% (c) 2020 Hochschule Rapperswil
%
-\chapter{Transferfunktionen\label{chapter:transfer}}
+\chapter{Transferfunktion Tangens hyperbolicus\label{chapter:transfer}}
\lhead{Thema}
\begin{refsection}
\chapterauthor{Marc Benz}
@@ -12,6 +12,8 @@
\input{papers/transfer/teil1.tex}
\input{papers/transfer/teil2.tex}
\input{papers/transfer/teil3.tex}
+%\input{papers/transfer/teil4.tex}
+
\printbibliography[heading=subbibliography]
\end{refsection}
diff --git a/buch/papers/transfer/packages.tex b/buch/papers/transfer/packages.tex
index ee51b71..fa7069a 100644
--- a/buch/papers/transfer/packages.tex
+++ b/buch/papers/transfer/packages.tex
@@ -8,3 +8,8 @@
% following example
%\usepackage{packagename}
+\usetikzlibrary{positioning}
+\usetikzlibrary{arrows}
+\usetikzlibrary{fit}
+\usetikzlibrary{shapes.geometric}
+%\usepackage{subcaption}
diff --git a/buch/papers/transfer/references.bib b/buch/papers/transfer/references.bib
index 75f5d68..181682c 100644
--- a/buch/papers/transfer/references.bib
+++ b/buch/papers/transfer/references.bib
@@ -4,6 +4,30 @@
% (c) 2020 Autor, Hochschule Rapperswil
%
+
+
+@article{transfer:DBLP:journals/corr/abs-1909-07729,
+ author = {Abhisek Kundu and
+ Sudarshan Srinivasan and
+ Eric C. Qin and
+ Dhiraj D. Kalamkar and
+ Naveen K. Mellempudi and
+ Dipankar Das and
+ Kunal Banerjee and
+ Bharat Kaul and
+ Pradeep Dubey},
+ title = {K-TanH: Hardware Efficient Activations For Deep Learning},
+ journal = {CoRR},
+ volume = {abs/1909.07729},
+ year = {2019},
+ url = {http://arxiv.org/abs/1909.07729},
+ eprinttype = {arXiv},
+ eprint = {1909.07729},
+ timestamp = {Sat, 04 Apr 2020 17:18:32 +0200},
+ biburl = {https://dblp.org/rec/journals/corr/abs-1909-07729.bib},
+ bibsource = {dblp computer science bibliography, https://dblp.org}
+}
+
@online{transfer:bibtex,
title = {BibTeX},
url = {https://de.wikipedia.org/wiki/BibTeX},
@@ -31,5 +55,4 @@
volume = 47,
pages = {607--627},
url = {https://doi.org/10.1016/j.acha.2017.11.004}
-}
-
+} \ No newline at end of file
diff --git a/buch/papers/transfer/teil0.tex b/buch/papers/transfer/teil0.tex
index 19d4961..f8c8cb4 100644
--- a/buch/papers/transfer/teil0.tex
+++ b/buch/papers/transfer/teil0.tex
@@ -3,20 +3,232 @@
%
% (c) 2020 Prof Dr Andreas Müller, Hochschule Rapperswil
%
-\section{Teil 0\label{transfer:section:teil0}}
-\rhead{Teil 0}
-Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
-nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
-erat, sed diam voluptua \cite{transfer:bibtex}.
-At vero eos et accusam et justo duo dolores et ea rebum.
-Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
-dolor sit amet.
-
-Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
-nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
-erat, sed diam voluptua.
-At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
-kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
-amet.
+\section{Motivation\label{transfer:section:teil0}}
+\rhead{Einleitung}
+
+Die Transferfunktion ist einer der wichtigsten Bestandteile moderner neuraler Netzwerke. Sie verleiht ihnen die nicht Linearität, die benötigt wird um komplexere Aufgaben zu lösen. Dabei kann theoretisch jede nicht lineare Funktion eingesetzt werden. In der Praxis tauchen aber nur sehr wenige Funktionen mit ähnlichen Eigenschaften auf. Einige davon sind in der Tabelle \ref{tab:aktfkt} zu sehen. In der heutigen Zeit sind vor allem die Variationen der ReLu Funktion beliebt. Der Tangens hyperbolicus wird aber dank dem Aufkommen der Recurrent Neural Networks, zum Beispiel dem Long short term memory Netzwerk, das aus Zellen wie in \ref{motivation:figure:LSTM} gezeigt bestehen, wieder vermehrt eingesetzt.
+Die klassische Berechnung ist aber sehr aufwendig und basiert auf Gleitkommaoperationen und relativ komplizierten Funktionen. Diese benötigen einen grossen Rechenaufwand. Vor allem auf Systemen die keine Gleitkommaarithmetik Hardware besitzen wie das zum Beispiel bei gewissen Mikrocontrollern der Fall ist.
+\begin{table}[h]
+ \centering
+ \begin{tabular}{llll}
+ \hline
+ \multicolumn{1}{l}{Name} & \multicolumn{1}{l}{Function} & \multicolumn{1}{l}{Figure} \\
+ \hline
+ Sigmoid & $\sigma(x)=\frac{1}{1+e^{-x}}$ &
+ \begin{tikzpicture}[baseline={(0,0.2)}]
+ \draw (-1,0) -- (1,0);
+ \draw (0,0) -- (0,1);
+ \draw[red] plot[domain=-1:1,variable=\x] ({\x},{1/(1+exp(-4*\x))});
+ \end{tikzpicture}\\
+ ReLU & $f(x) =\begin{cases}
+ 0 & ~\text{if}~ x<0 \\
+ x & ~\text{if}~x \geq 0.
+ \end{cases}$ &
+ \begin{tikzpicture}[baseline={(0,0.5)}]
+ \draw (-1,0) -- (1,0);
+ \draw (0,0) -- (0,1);
+ \draw[red] plot[domain=-1:1,variable=\x] ({\x},{ifthenelse(\x<0,0,\x)});
+ \end{tikzpicture}\\
+ Leaky ReLu & $f(x) =\begin{cases}
+ 0 & ~\text{if}~ x<0 \\
+ x & ~\text{if}~x \geq a \cdot x.
+ \end{cases}$ &
+ \begin{tikzpicture}[baseline={(0,0.5)}]
+ \draw (-1,0) -- (1,0);
+ \draw (0,0) -- (0,1);
+ \draw[red] plot[domain=-1:1,variable=\x] ({\x},{ifthenelse(\x<0,0.1*\x,\x)});
+ \end{tikzpicture}
+ \end{tabular}
+ \caption{Transferfunktionen}
+ \label{tab:aktfkt}
+\end{table}
+
+\begin{figure}
+\centering
+\begin{tikzpicture}
+ \begin{axis}[
+ xmin=-2.5, xmax=2.5,
+ ymin=-1.5, ymax=1.5,
+ axis lines=center,
+ axis on top=true,
+ domain=-2.5:2.5,
+ ylabel=$y$,
+ xlabel=$x$,
+ ]
+
+ \addplot [mark=none,draw=red,ultra thick] {tanh(\x)};
+ \node [right, red] at (axis cs: 1,0.7) {$\tanh(x)$};
+
+ %% Add the asymptotes
+ \draw [blue, dotted, thick] (axis cs:-2.5,-1)-- (axis cs:0,-1);
+ \draw [blue, dotted, thick] (axis cs:+2.5,+1)-- (axis cs:0,+1);
+ \end{axis}
+\end{tikzpicture}
+\caption{Tangens hyperbolicus
+\label{anleitung:figure:tanhyp}}
+\end{figure}
+
+\begin{figure}
+\centering
+\tikzset{
+ every node/.style={
+ font=\scriptsize
+ },
+ decision/.style={
+ shape=rectangle,
+ minimum height=1cm,
+ text width=3cm,
+ text centered,
+ rounded corners=1ex,
+ draw,
+ label={[yshift=0.2cm]left:ja},
+ label={[yshift=0.2cm]right:nein},
+ },
+ outcome/.style={
+ shape=ellipse,
+ fill=gray!15,
+ draw,
+ text width=1.5cm,
+ text centered
+ },
+ decision tree/.style={
+ edge from parent path={[-latex] (\tikzparentnode) -| (\tikzchildnode)},
+ sibling distance=4cm,
+ level distance=1.5cm
+ }
+}
+
+\begin{tikzpicture}
+
+ \node [decision] { $x>k \cdot \frac{\ln 10}{2}$ }
+ [decision tree]
+ child { node [outcome] { $+1$ } }
+ child { node [decision] { $x<-k \cdot \frac{\ln 10}{2}$}
+ child { node [outcome] { $-1$ } }
+ child { node [decision] { $-0,1<x<+0,1$ }
+ child { node [outcome] { $\frac{\sinh x}{e^{x}-\sinh x}$ } }
+ child { node [outcome] { $\frac{e^{2 x}-1}{e^{2 x}+1}$ } }
+ }
+ };
+\end{tikzpicture}
+\caption{Annäherung für Tangens hyperbolicus
+\label{anleitung:figure:approxtanhhypalgo}}
+\end{figure}
+
+
+\begin{figure}
+\centering
+\newcommand{\empt}[2]{$#1^{\langle #2 \rangle}$}
+
+\begin{tikzpicture}[
+ % GLOBAL CFG
+ font=\sf \scriptsize,
+ >=LaTeX,
+ % Styles
+ cell/.style={% For the main box
+ rectangle,
+ rounded corners=5mm,
+ draw,
+ very thick,
+ },
+ operator/.style={%For operators like + and x
+ circle,
+ draw,
+ inner sep=-0.5pt,
+ minimum height =.2cm,
+ },
+ function/.style={%For functions
+ ellipse,
+ draw,
+ inner sep=1pt
+ },
+ ct/.style={% For external inputs and outputs
+ circle,
+ draw,
+ line width = .75pt,
+ minimum width=1cm,
+ inner sep=1pt,
+ },
+ gt/.style={% For internal inputs
+ rectangle,
+ draw,
+ minimum width=4mm,
+ minimum height=3mm,
+ inner sep=1pt
+ },
+ mylabel/.style={% something new that I have learned
+ font=\scriptsize\sffamily
+ },
+ ArrowC1/.style={% Arrows with rounded corners
+ rounded corners=.25cm,
+ thick,
+ },
+ ArrowC2/.style={% Arrows with big rounded corners
+ rounded corners=.5cm,
+ thick,
+ },
+ ]
+
+ %Start drawing the thing...
+ % Draw the cell:
+ \node [cell, minimum height =4cm, minimum width=6cm] at (0,0){} ;
+
+ % Draw inputs named ibox#
+ \node [gt] (ibox1) at (-2,-0.75) {$\sigma$};
+ \node [gt] (ibox2) at (-1.5,-0.75) {$\sigma$};
+ \node [function, draw=red!60, fill=red!5] (ibox3) at (-0.5,-0.75) {$\tanh$};
+ \node [gt] (ibox4) at (0.5,-0.75) {$\sigma$};
+
+ % Draw opérators named mux# , add# and func#
+ \node [operator] (mux1) at (-2,1.5) {$\times$};
+ \node [operator] (add1) at (-0.5,1.5) {+};
+ \node [operator] (mux2) at (-0.5,0) {$\times$};
+ \node [operator] (mux3) at (1.5,0) {$\times$};
+ \node [function, draw=red!60, fill=red!5] (func1) at (1.5,0.75) {$\tanh$};
+
+ % Draw External inputs named as basis c,h,x
+ \node[ct, label={[mylabel]}] (c) at (-4,1.5) {\empt{c}{t-1}};
+ \node[ct, label={[mylabel]}] (h) at (-4,-1.5) {\empt{h}{t-1}};
+ \node[ct, label={[mylabel]}] (x) at (-2.5,-3) {\empt{x}{t}};
+
+ % Draw External outputs? named as basis c2,h2,x2
+ \node[ct, label={[mylabel]}] (c2) at (4,1.5) {\empt{c}{t}};
+ \node[ct, label={[mylabel]}] (h2) at (4,-1.5) {\empt{h}{t}};
+ \node[ct, label={[mylabel]}] (x2) at (2.5,3) {\empt{h}{t}};
+
+ % Start connecting all.
+ %Intersections and displacements are used.
+ % Drawing arrows
+ \draw [ArrowC1] (c) -- (mux1) -- (add1) -- (c2);
+
+ % Inputs
+ \draw [ArrowC2] (h) -| (ibox4);
+ \draw [ArrowC1] (h -| ibox1)++(-0.5,0) -| (ibox1);
+ \draw [ArrowC1] (h -| ibox2)++(-0.5,0) -| (ibox2);
+ \draw [ArrowC1] (h -| ibox3)++(-0.5,0) -| (ibox3);
+ \draw [ArrowC1] (x) -- (x |- h)-| (ibox3);
+
+ % Internal
+ \draw [->, ArrowC2] (ibox1) -- (mux1);
+ \draw [->, ArrowC2] (ibox2) |- (mux2);
+ \draw [->, ArrowC2] (ibox3) -- (mux2);
+ \draw [->, ArrowC2] (ibox4) |- (mux3);
+ \draw [->, ArrowC2] (mux2) -- (add1);
+ \draw [->, ArrowC1] (add1 -| func1)++(-0.5,0) -| (func1);
+ \draw [->, ArrowC2] (func1) -- (mux3);
+
+ %Outputs
+ \draw [-, ArrowC2] (mux3) |- (h2);
+ \draw (c2 -| x2) ++(0,-0.1) coordinate (i1);
+ \draw [-, ArrowC2] (h2 -| x2)++(-0.5,0) -| (i1);
+ \draw [-, ArrowC2] (i1)++(0,0.2) -- (x2);
+
+\end{tikzpicture}
+\caption{Long short term memory cell
+\label{motivation:figure:LSTM}}
+\end{figure}
+
+
+
diff --git a/buch/papers/transfer/teil1.tex b/buch/papers/transfer/teil1.tex
index c60f1ea..f117fc0 100644
--- a/buch/papers/transfer/teil1.tex
+++ b/buch/papers/transfer/teil1.tex
@@ -3,53 +3,54 @@
%
% (c) 2020 Prof Dr Andreas Müller, Hochschule Rapperswil
%
-\section{Teil 1
+\section{Taylorapproximation
\label{transfer:section:teil1}}
-\rhead{Problemstellung}
-Sed ut perspiciatis unde omnis iste natus error sit voluptatem
-accusantium doloremque laudantium, totam rem aperiam, eaque ipsa
-quae ab illo inventore veritatis et quasi architecto beatae vitae
-dicta sunt explicabo.
-Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit
-aut fugit, sed quia consequuntur magni dolores eos qui ratione
-voluptatem sequi nesciunt
+\subsection{Idee}
+Die Taylorreihe kann eine glatte Funktion in einer Umgebung durch Polynome beliebig genau annähern. Beschränkt man sich auf einen bestimmten Grad dieser Polynome, spricht man von einer Taylorapproximation. Diese entwickelt sich immer um einen Punkt und kann über die Ableitungen berechnet werden.
+
+\subsection{Definition der Taylorreihe}
+Sei $I \subset \mathbb{R}$ ein offenes Intervall, $f: I \rightarrow \mathbb{R}$ eine glatte Funktion und $a$ ein Element von $I$. Dann ist die unendliche Reihe
\begin{equation}
-\int_a^b x^2\, dx
-=
-\left[ \frac13 x^3 \right]_a^b
-=
-\frac{b^3-a^3}3.
-\label{transfer:equation1}
+ T_{f(x ; a)}=\sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n !}(x-a)^{n}=f(a)+f^{\prime}(a)(x-a)+\frac{f^{\prime \prime}(a)}{2}(x-a)^{2}+\frac{f^{\prime \prime \prime}(a)}{6}(x-a)^{3}+\ldots
\end{equation}
-Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet,
-consectetur, adipisci velit, sed quia non numquam eius modi tempora
-incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
-
-Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis
-suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?
-Quis autem vel eum iure reprehenderit qui in ea voluptate velit
-esse quam nihil molestiae consequatur, vel illum qui dolorem eum
-fugiat quo voluptas nulla pariatur?
-
-\subsection{De finibus bonorum et malorum
-\label{transfer:subsection:finibus}}
-At vero eos et accusamus et iusto odio dignissimos ducimus qui
-blanditiis praesentium voluptatum deleniti atque corrupti quos
-dolores et quas molestias excepturi sint occaecati cupiditate non
-provident, similique sunt in culpa qui officia deserunt mollitia
-animi, id est laborum et dolorum fuga \eqref{000tempmlate:equation1}.
+eine Taylorreihe.
-Et harum quidem rerum facilis est et expedita distinctio
-\ref{transfer:section:loesung}.
-Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil
-impedit quo minus id quod maxime placeat facere possimus, omnis
-voluptas assumenda est, omnis dolor repellendus
-\ref{transfer:section:folgerung}.
-Temporibus autem quibusdam et aut officiis debitis aut rerum
-necessitatibus saepe eveniet ut et voluptates repudiandae sint et
-molestiae non recusandae.
-Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis
-voluptatibus maiores alias consequatur aut perferendis doloribus
-asperiores repellat.
+\subsection{Beispiel}
+In diesem Beispiel wird die Taylorapproximation mit dem Grad 2 des Tangens hyperbolicus um den Punkt Null berechnet.
+$$
+ \tanh \approx T_{2} \tanh(x ; a)=\tanh(a)+\tanh^{\prime}(a) \cdot(x-a)+\frac{\tanh^{\prime \prime}(a) \cdot(x-a)^{2}}{2}
+$$
+mit $a = 0$ folgt
+$$
+ T_{2} \tanh(x ; 0)=\tanh(0)+\tanh^{\prime}(0) \cdot(x)+\frac{\tanh^{\prime \prime}(0) \cdot(x)^{2}}{2} = 0 + x + 0 = x
+$$
+\begin{figure}
+\centering
+\begin{tikzpicture}
+ \begin{axis}[
+ xmin=-2.5, xmax=2.5,
+ ymin=-1.5, ymax=1.5,
+ axis lines=center,
+ axis on top=true,
+ domain=-2.5:2.5,
+ ylabel=$y$,
+ xlabel=$x$,
+ ]
+
+ \addplot [mark=none,draw=red,thick] {tanh(\x)};
+ \node [right, red] at (axis cs: 1.4,0.7) {$\tanh(x)$};
+ \addplot [mark=none,draw=blue,ultra thick, samples=100, smooth] expression{x-(x^3)/3+ (2*x^5)/15-(17 * x^7)/315};
+ \node [right, blue] at (axis cs: -1.8,0.7) {$Taylorapprox.$};
+
+ %% Add the asymptotes
+ \draw [blue, dotted, thick] (axis cs:-2.5,-1)-- (axis cs:0,-1);
+ \draw [blue, dotted, thick] (axis cs:+2.5,+1)-- (axis cs:0,+1);
+ \end{axis}
+\end{tikzpicture}
+\caption{Taylorapproximation des Grades 7
+\label{motivation:figure:Taylor}}
+\end{figure}
+\subsection{Problem}
+Wie in Abbildung \ref{motivation:figure:Taylor} ersichtlich, ist der Approximationsfehler sogar bei Grad 7 des Polynoms sehr gross. Dies liegt ist unter anderem an der Unbeschränktheit, die solche Polynome besitzen.
diff --git a/buch/papers/transfer/teil2.tex b/buch/papers/transfer/teil2.tex
index ce8f798..aae81a7 100644
--- a/buch/papers/transfer/teil2.tex
+++ b/buch/papers/transfer/teil2.tex
@@ -1,40 +1,68 @@
%
-% teil2.tex -- Beispiel-File für teil2
+% teil1.tex -- Beispiel-File für das Paper
%
% (c) 2020 Prof Dr Andreas Müller, Hochschule Rapperswil
%
-\section{Teil 2
+\section{Padé-Approximation
\label{transfer:section:teil2}}
-\rhead{Teil 2}
-Sed ut perspiciatis unde omnis iste natus error sit voluptatem
-accusantium doloremque laudantium, totam rem aperiam, eaque ipsa
-quae ab illo inventore veritatis et quasi architecto beatae vitae
-dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit
-aspernatur aut odit aut fugit, sed quia consequuntur magni dolores
-eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam
-est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
-velit, sed quia non numquam eius modi tempora incidunt ut labore
-et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima
-veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam,
-nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
-reprehenderit qui in ea voluptate velit esse quam nihil molestiae
-consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla
-pariatur?
+\rhead{}
+
+\subsection{Idee
+ \label{transfer:pade:idee}}
+Die Taylorapproximation ist für den Gebrauch als Ersatz des Tangenshyperbolicus als Transferfunktion nicht brauchbar. Die Padé-Approximation kann die grössten Probleme aber entschärfen und dies mit sehr begrenztem zusätzlichen Rechenaufwand. Dafür wird die Taylorapproximation in einen Bruch von zwei Polynom zerlegt.
+
+\subsection{Definition
+\label{transfer:pade:definition}}
+Sei
+\begin{equation}
+ R(x)=\frac{\sum_{j=0}^{m} a_{j} x^{j}}{1+\sum_{k=1}^{n} b_{k} x^{k}}=\frac{a_{0}+a_{1} x+a_{2} x^{2}+\cdots+a_{m} x^{m}}{1+b_{1} x+b_{2} x^{2}+\cdots+b_{n} x^{n}}
+\end{equation}
+und gilt
+\begin{gather*}
+ f(0) =R(0) \\
+ f^{\prime}(0) =R^{\prime}(0) \\
+ f^{\prime \prime}(0) =R^{\prime \prime}(0) \\
+ \vdots \\
+ f^{(m+n)}(0) =R^{(m+n)}(0),
+\end{gather*}
+so ist $R(x)$ die Padé-Approximation von $f(x)$.
+\subsection{Beispiel
+ \label{transfer:pade:beispiel}}
+Sei $f(x) = \tanh (x)$ und $T_{5} \tanh(x ; a) = x-\frac{x^{3}}{3}+\frac{2 x^{5}}{15}$, dann gilt
+$$
+ \begin{gathered}
+ [3 / 2]_{f}(x) = \frac{A_{0}+A_{1} x+A_{2} x^{2}+A_{3} x^{3}}{B_{0}+B_{1} x+B_{2} x^{2}}=x-\frac{x^{3}}{3}+\frac{2 x^{5}}{15}+O\left(x^{6}\right), B_{0} = 1,\\
+ \Downarrow \\
+ [3 / 2]_{f}(x) = \frac{15x+x^3}{15+6x^2}
+\end{gathered}
+$$
+
+\begin{figure}
+\centering
+\begin{tikzpicture}
+ \begin{axis}[
+ xmin=-3.5, xmax=3.5,
+ ymin=-1.5, ymax=1.5,
+ axis lines=center,
+ axis on top=true,
+ domain=-3.5:3.5,
+ ylabel=$y$,
+ xlabel=$x$,
+ ]
+
+ \addplot [mark=none,draw=red,thick] {tanh(\x)};
+ \node [right, red] at (axis cs: 1.4,0.7) {$\tanh(x)$};
+ \addplot [mark=none,draw=blue,ultra thick, samples=100, smooth] expression{x*(15+x^2)/(15+6*x^2)};
+ \node [right, blue] at (axis cs: -1.8,0.7) {$Padé$};
+
+ %% Add the asymptotes
+ \draw [blue, dotted, thick] (axis cs:-2.5,-1)-- (axis cs:0,-1);
+ \draw [blue, dotted, thick] (axis cs:+2.5,+1)-- (axis cs:0,+1);
+ \end{axis}
+\end{tikzpicture}
+\caption{$[3 / 2]_{f}(x)$
+\label{motivation:figure:Pade32}}
+\end{figure}
-\subsection{De finibus bonorum et malorum
-\label{transfer:subsection:bonorum}}
-At vero eos et accusamus et iusto odio dignissimos ducimus qui
-blanditiis praesentium voluptatum deleniti atque corrupti quos
-dolores et quas molestias excepturi sint occaecati cupiditate non
-provident, similique sunt in culpa qui officia deserunt mollitia
-animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis
-est et expedita distinctio. Nam libero tempore, cum soluta nobis
-est eligendi optio cumque nihil impedit quo minus id quod maxime
-placeat facere possimus, omnis voluptas assumenda est, omnis dolor
-repellendus. Temporibus autem quibusdam et aut officiis debitis aut
-rerum necessitatibus saepe eveniet ut et voluptates repudiandae
-sint et molestiae non recusandae. Itaque earum rerum hic tenetur a
-sapiente delectus, ut aut reiciendis voluptatibus maiores alias
-consequatur aut perferendis doloribus asperiores repellat.
diff --git a/buch/papers/transfer/teil3.tex b/buch/papers/transfer/teil3.tex
index f707587..5bbe0c1 100644
--- a/buch/papers/transfer/teil3.tex
+++ b/buch/papers/transfer/teil3.tex
@@ -1,40 +1,26 @@
%
-% teil3.tex -- Beispiel-File für Teil 3
+% teil2.tex -- Beispiel-File für teil2
%
% (c) 2020 Prof Dr Andreas Müller, Hochschule Rapperswil
%
-\section{Teil 3
+\section{MiniMax-Polynom
\label{transfer:section:teil3}}
-\rhead{Teil 3}
-Sed ut perspiciatis unde omnis iste natus error sit voluptatem
-accusantium doloremque laudantium, totam rem aperiam, eaque ipsa
-quae ab illo inventore veritatis et quasi architecto beatae vitae
-dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit
-aspernatur aut odit aut fugit, sed quia consequuntur magni dolores
-eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam
-est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
-velit, sed quia non numquam eius modi tempora incidunt ut labore
-et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima
-veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam,
-nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
-reprehenderit qui in ea voluptate velit esse quam nihil molestiae
-consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla
-pariatur?
+\rhead{MiniMax-Polynom}
-\subsection{De finibus bonorum et malorum
-\label{transfer:subsection:malorum}}
-At vero eos et accusamus et iusto odio dignissimos ducimus qui
-blanditiis praesentium voluptatum deleniti atque corrupti quos
-dolores et quas molestias excepturi sint occaecati cupiditate non
-provident, similique sunt in culpa qui officia deserunt mollitia
-animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis
-est et expedita distinctio. Nam libero tempore, cum soluta nobis
-est eligendi optio cumque nihil impedit quo minus id quod maxime
-placeat facere possimus, omnis voluptas assumenda est, omnis dolor
-repellendus. Temporibus autem quibusdam et aut officiis debitis aut
-rerum necessitatibus saepe eveniet ut et voluptates repudiandae
-sint et molestiae non recusandae. Itaque earum rerum hic tenetur a
-sapiente delectus, ut aut reiciendis voluptatibus maiores alias
-consequatur aut perferendis doloribus asperiores repellat.
+
+
+\subsection{Idee
+\label{transfer:subsection:idee}}
+Finde das Polynom eines bestimmten Grades, welches eine Funktion in einem Intervall am besten approximiert.
+
+
+\subsection{Definition
+ \label{transfer:subsection:definition}}
+Das Polynom welches
+ $$ \max _{a \leq x \leq b}|f(x)-P(x)| , a \in \mathbb{R}, b \in \mathbb{R}.$$
+minimiert.
+\subsection{Beispiel
+ \label{transfer:subsection:beispiel}}
+Um ein MiniMax-Polynom zu berechnen, kann der Remez-Algorithmus verwendet werden. Dieser basiert im wesentlichen auf dem Alternantensatz von Tschebyschow.
diff --git a/buch/papers/transfer/teil4.tex b/buch/papers/transfer/teil4.tex
new file mode 100644
index 0000000..d652e2d
--- /dev/null
+++ b/buch/papers/transfer/teil4.tex
@@ -0,0 +1,218 @@
+%
+% teil4.tex
+%
+% (c) 2020 Prof Dr Andreas Müller, Hochschule Rapperswil
+%
+\section{K-Tanh
+\label{transfer:section:teil4}}
+\rhead{K-Tanh}
+
+\subsection{Idee
+ \label{transfer:subsection:Ktanh-Idee}}
+Um die Berechnung des Tangens hyperbolicus wirklich zu beschleunigen, braucht es einen Algorithmus, der ohne Gleitkommaoperationen auskommt. Um dies zu bewerkstelligen, ist eine Unterteilung der Funktion in mehrere Abschnitte nötig. Diese können dann linear approximiert werden. Die dazugehörigen Parameter können einmal berechnet werden und zu Rechenzeit aus einem LUT????? gelesen und danach mit integer Operationen verrechnet werden.
+
+
+\subsection{Definitionen
+ \label{transfer:subsection:Ktanh-Definition}}
+
+\subsubsection{Gleitkommazahlen nach IEEE-754
+ \label{transfer:subsection:Ktanh-Algorithmus:Gleitkommazahl}}
+Da ein Computer nur mit binären Werten arbeiten kann, müssen Zahlen durch sogenannte Gleitkommazahlen approximiert werden. Dafür wird die Zahl in zwei Teile aufgeteilt, die Mantisse und den Exponenten. Die Zahl setzt sich dann wie folgt zusammen:
+$$
+\begin{array}{|l|l|l|}
+ \hline S & E & M \\
+ \hline
+\end{array}
+$$
+Aus dem sich die Dezimalzahl wie folgt berechnet
+$$
+x=s \cdot m \cdot b^{e}
+$$
+wobei
+$$
+\begin{aligned}
+ &s=(-1)^{S} \\
+ &e=E-B\\
+ &B=2^{r-1}-1
+ &m=1+M / 2^{p}
+\end{aligned}
+$$
+mit $r$ = Anzahl der Exponenten bits und p = Anzahl mantisse Bits.
+
+
+\subsubsection{K-tanh Algorithmus
+\label{transfer:subsection:Ktanh-Algorithmus}}
+\cite{transfer:DBLP:journals/corr/abs-1909-07729}
+
+Negative Werte werden nicht separat behandelt. Diese werden dank der Symertrie um den Ursprung mit einem einfachen Vorzeichenwechsel aus den positiven berechnet.
+Für $x < 0.25$ gilt $y = x$.
+Ist $x > 3.75$ gitl $y = 1$.
+Ist der Wert zwischen diesen Grenzen, werden über einen Lookuptable geeignete Werte gefunden um aus dem $x$ die Approximation des Tanh zu berechnen.
+Dafür werden eine bestimmte Anzahl LSBs des Exponenten und MSBs der Mantisse zu einem Index $t$ zusammengestzt. Der dann die Stelle im Lookuptable zeigt.
+Damit werden die richtigen Werte für $E_{t}, r_{t}, b_{t}$ aus der Tabelle, die im Vorhinein schon berechnet wurden, ausgelesen.
+Damit hat man das $E$ bereits gefunden und mit der Formel
+\[
+ M_{o} \leftarrow\left(M_{i} \gg r\right)+b
+\]
+
+kann das neue $M$ berechnet werden.
+
+\begin{figure}
+\centering
+\tikzset{
+ every node/.style={
+ font=\scriptsize
+ },
+ decision/.style={
+ shape=rectangle,
+ minimum height=1cm,
+ text width=3cm,
+ text centered,
+ rounded corners=1ex,
+ draw,
+ label={[yshift=0.2cm]left:ja},
+ label={[yshift=0.2cm]right:nein},
+ },
+ outcome/.style={
+ shape=ellipse,
+ fill=gray!15,
+ draw,
+ text width=1.5cm,
+ text centered
+ },
+ decision tree/.style={
+ edge from parent path={[-latex] (\tikzparentnode) -| (\tikzchildnode)},
+ sibling distance=4cm,
+ level distance=1.5cm
+ }
+}
+\begin{tikzpicture}
+
+ \node [decision] { $x<0.25$ }
+ [decision tree]
+ child { node [outcome] { $x$ } }
+ child { node [decision] { $x>3.75$}
+ child { node [outcome] { $1$ } }
+ child { node [outcome] { $K-tanh$ } }
+ };
+
+\end{tikzpicture}
+\caption{Gesamter Algorithmus
+\label{motivation:figure:gesalgo}}
+\end{figure}
+
+\begin{figure}
+\centering
+\begin{tikzpicture}
+ [>=stealth', auto, node distance=2cm, scale=1.2]
+
+ \tikzstyle{dot} = [circle, draw, fill, inner sep=0.03cm]
+
+ \tikzstyle{brace} = [decorate, decoration={brace,amplitude=4pt}]
+
+ \begin{scope}[]
+
+ \node[ minimum width=0.5cm] (s) at (0, 0) {$s$};
+ \node[anchor=west, minimum width=1.5cm] (e) at (s.east) {$E_i$};
+ \node[anchor=west, minimum width=1.5cm] (m) at (e.east) {$M_i$};
+ \draw[blue] (e.north west) -- (e.south west) (e.north east) -- (e.south east);
+ \node[draw, green!50!black, rounded corners=0.1cm, fit=(s) (e) (m), inner sep = 0] (a) {};
+
+ \node[minimum width=0.5cm] (s) at (5, 0) {$s$};
+ \node[anchor=west, minimum width=1.5cm] (e) at (s.east) {$E_o$};
+ \node[anchor=west, minimum width=1.5cm] (m) at (e.east) {$M_o$};
+ \draw[blue] (e.north west) -- (e.south west) (e.north east) -- (e.south east);
+ \node[draw, green!50!black, rounded corners=0.1cm, fit=(s) (e) (m), inner sep = 0] (b) {};
+
+ \draw[yshift=-0.4cm, decorate,decoration={brace,amplitude=4pt}] (a.south) ++(0, -0.2) +(0.5,0) -- +(-0.5,0 );
+
+ \node[draw=black, fill=black!20, minimum width=1.5cm, minimum height= 2cm, below=1cm of a] (lut) {};
+
+ \node[draw=blue, inner sep=0.2cm, right = 1.5cm of lut, align=left] (box) {$E_0 \gets E$ \\ $M_0 \gets (M_i \gg r) + b$};
+
+ \draw[->] (a.south) +(0, -0.5) -- (lut);
+ \draw[->] (lut) -- node[above]{$(E,r,b)$} (box);
+ \draw[->] (box) -| ([xshift=0.5cm, yshift=-0.3cm]b.south);
+
+ \end{scope}
+
+\end{tikzpicture}
+\caption{Ablauf der K-tanh Berechnung
+\label{motivation:figure:Ktanhablauf}}
+\end{figure}
+
+
+\subsection{Beispiel
+\label{transfer:subsection:Ktanh-Algorithmus:Beispiel}}
+
+%TODO
+
+In diesem Abschnitt wird das Verfahren am einem Beispiel mit dem BFloat16 erklärt. Das bedeutet die Gleitkommazahlen werden mit 8 Exponenten, 7 Mantisse und einem Vorzeichen bit dargestellt.
+
+\subsubsection{Algorithmus für die Bestimmung der Parameter
+ \label{transfer:subsection:Ktanh-Algorithmus:Algo}}
+
+\begin{enumerate}
+ \item Wir berechnen zuerst den Tanh für ein gegebenes x und finden die zugehörige BFloat16-Darstellung.
+ \[
+ y_{i}=\operatorname{TanH}\left(x_{i}\right)=(-1)^{s} \cdot 2^{E_{i}} \cdot\left(1+M_{i} / 2^{q}\right)
+ \]
+
+ \item Sollten die Exponenten in einem Intervall $t$ nicht gleich sein, muss ein gemeinsamer Exponent gefunden werden, so dass
+ $$
+ \underset{E, \hat{M}_{i} \in \mathbb{Z}}{\operatorname{argmin}} \sum_{i}\left(y_{i}-\hat{y}_{i}\right)^{2}, \quad \text { mit } \quad E \in\left\{E_{i}\right\}, \hat{M}_{i} \in[0,127]
+ $$
+ minimiert wird. Was bedeutet, dass der Exponent mit welchem der kleinsten quadrierten und aufsummierten Fehler entsteht gewählt wird.
+ ?????We pick E from the set of exponents {Ei}. If E = Ej ,
+ then, Mˆ
+ j = Mj , for all j. If E > Ej , then, Mˆ
+ j = 0.
+ Similarly, for E < Ej , Mˆ
+ j = 2q − 1. Store this E in the
+ parameter table TE.?????
+ \item Um den Verschiebungsparameter r und den Additionsterm b zu finden, muss das folgende Optimierungsproblem gelöst werden. Auch hier wird einfach der kleinste quadrierte und aufsummierte Fehler gesucht wird.
+ $$
+ \begin{array}{ll}
+ & \underset{r, b \in \mathbb{Z}}{\operatorname{argmin}} \sum_{i}\left(\hat{M}_{i}-\left(m_{i} / 2^{r}+b\right)\right)^{2} \\
+ \text { mit } & 0 \leq r \leq r_{\max } \leq p, \quad b_{\min } \leq b \leq b_{\max }
+ \end{array}
+ $$
+ Dabei müssen $r_max$, $b_min$ und $b_max$ sorgfältig gewählt werden, so dass kein
+\end{enumerate}
+
+\subsubsection{Numerisches Beispiel
+ \label{transfer:subsection:Ktanh-Algorithmus:Num}}
+Zum Index $t = 00000$ gehört neben Anderen der Wert $x_i = 2$. Denn mit \ref{transfer:subsection:Ktanh-Algorithmus:Gleitkommazahl} folgt
+
+$$
+\begin{array}{|l|l|l|}
+ \hline S_i & E_{i} & M_{i} \\
+ \hline 0 & 100000 \textbf{00} & \textbf{000} 0000 \\
+ \hline
+\end{array}
+$$
+Der dazugehörige Tanh Wert ist
+$y_i = \tanh{x_i}=0.96402758\ldots$. Es lässt sich die dazugehörige BFloat-16-Darstellung finden
+
+$$
+\begin{array}{|l|l|l|}
+ \hline S_{y_{i}} & E_{y_{i}} & M_{y_{i}} \\
+ \hline 0 & 01111110 & 1110110 \\
+ \hline
+\end{array}
+$$
+Nun müssen alle anderen Werte dieses Intervalls $t = 00000$ ausgewertet werden. Stimmen nicht alle Exponenten der $S_{y}$ überein, so muss noch ein gemeinsamer Exponent mit dem Optimierungproblem \ref{} gefunden werden. Danach kann der Verschiebe- und Additionsfaktor für das Intervall berechnet werden.
+Es ergeben sich die Werte:
+$$
+\begin{array}{c|ccc}
+ \text { Index } t & E_{t} & r_{t} & b_{t} \\
+ \hline 00111 & 126 & 2 & 119
+\end{array}
+$$
+
+
+
+
+
+
+