Neural Networks Grundlagen hinzugefügt.
@ -80,6 +80,9 @@
|
|||||||
\newacronym{RBF}{RBF}{Radial Basis Function Kernel}
|
\newacronym{RBF}{RBF}{Radial Basis Function Kernel}
|
||||||
\newacronym{SVM}{SVM}{Support Vector Machine}
|
\newacronym{SVM}{SVM}{Support Vector Machine}
|
||||||
\newacronym{ARD}{ARD}{Automatic Relevance Determination}
|
\newacronym{ARD}{ARD}{Automatic Relevance Determination}
|
||||||
|
\newacronym{MLP}{MLP}{Multi-Layer Perceptron}
|
||||||
|
\newacronym{ReLU}{ReLU}{Rectified Linear Unit}
|
||||||
|
\newacronym{ELU}{ELU}{Exponential Linear Units}
|
||||||
|
|
||||||
%--------------------
|
%--------------------
|
||||||
%nomenclature
|
%nomenclature
|
||||||
@ -134,6 +137,7 @@
|
|||||||
\newnom{gaussian_distribution}{Gaußsche Normalverteilung}{\mathcal{N}}{}
|
\newnom{gaussian_distribution}{Gaußsche Normalverteilung}{\mathcal{N}}{}
|
||||||
\newnom{gaussian_process}{Gaußscher Prozess}{\mathcal{GP}}{}
|
\newnom{gaussian_process}{Gaußscher Prozess}{\mathcal{GP}}{}
|
||||||
\newnom{hyper_parameters}{Hyper-Parameter}{\bm{\beta}}{}
|
\newnom{hyper_parameters}{Hyper-Parameter}{\bm{\beta}}{}
|
||||||
|
\newnom{activation_function}{Aktivierungsfunktion}{\phi}{}
|
||||||
\shorthandoff{"}
|
\shorthandoff{"}
|
||||||
|
|
||||||
\makeglossaries
|
\makeglossaries
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
|
|
||||||
\part{Neural Networks}
|
\part{Neural Networks}
|
||||||
\label{part:Neural Networks}
|
\label{part:Neural Networks}
|
||||||
|
\input{chapters/Neural_Networks/Basics.tex}
|
||||||
\input{chapters/Neural_Networks/Neural_Networks_and_Backpropagation.tex}
|
\input{chapters/Neural_Networks/Neural_Networks_and_Backpropagation.tex}
|
||||||
\input{chapters/Neural_Networks/CNNs_and_LSTMs.tex}
|
\input{chapters/Neural_Networks/CNNs_and_LSTMs.tex}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
\usepackage{svg}
|
\usepackage{svg}
|
||||||
%subfigures
|
%subfigures
|
||||||
\usepackage{subcaption}
|
\usepackage{subcaption}
|
||||||
|
%borders around images
|
||||||
|
\usepackage[export]{adjustbox}
|
||||||
|
|
||||||
%--------------------
|
%--------------------
|
||||||
%german quotation
|
%german quotation
|
||||||
@ -117,6 +119,7 @@ rightsub = \grq%
|
|||||||
\DeclareMathOperator*{\lik}{lik}
|
\DeclareMathOperator*{\lik}{lik}
|
||||||
\DeclareMathOperator*{\loss}{loss}
|
\DeclareMathOperator*{\loss}{loss}
|
||||||
\DeclareMathOperator*{\loglik}{loglik}
|
\DeclareMathOperator*{\loglik}{loglik}
|
||||||
|
\DeclareMathOperator*{\softmax}{softmax}
|
||||||
%special symbols
|
%special symbols
|
||||||
\usepackage{fontawesome}
|
\usepackage{fontawesome}
|
||||||
\usepackage{amssymb}
|
\usepackage{amssymb}
|
||||||
|
169
chapters/Neural_Networks/Basics.tex
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
\chapter{Basics}%
|
||||||
|
\label{cha:Neural Networks:Basics}
|
||||||
|
Neuronale Netze sind vom menschlichen Gehirn inspiriert.
|
||||||
|
Dieses besteht aus einer Vielzahl ($\approx 10^11$) Neuronen,
|
||||||
|
die untereinander stark verknüpft sind ($\approx 10^4$ Verknüpfungen pro Neuron).
|
||||||
|
Das Signal der eingehenden Neuronen muss stark genug sein,
|
||||||
|
damit ein angesteuertes Neuron ein Signal ausgibt.
|
||||||
|
|
||||||
|
Diesem Prinzip folgend bestehen auch Neuronale Netze aus einfachen Bestandteilen (den Neuronen\slash\,Perzeptronen).
|
||||||
|
Ein Neuron hat dabei mehrere Eingänge und einen Ausgang.
|
||||||
|
Die Berechnung des Ausgabewertes ergibt sich durch
|
||||||
|
|
||||||
|
\begin{equation} \label{eq:perceptron_output_function}
|
||||||
|
y = \nomeq{activation_function}(\bm{w}^T\bm x + b)
|
||||||
|
\end{equation}
|
||||||
|
\begin{wrapfigure}{r}{.5\textwidth}
|
||||||
|
\vspace*{-5mm}
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=0.8\linewidth]{perceptron.png}
|
||||||
|
\caption{Aufbau eines Perzeptron}
|
||||||
|
\label{fig:perceptron}
|
||||||
|
\vspace*{-20mm}
|
||||||
|
\end{wrapfigure}
|
||||||
|
\begin{itemize}
|
||||||
|
\item $y$:\tabto{15mm}Output
|
||||||
|
\item \nomsym{activation_function}:\tabto{15mm}\noms{activation_function}
|
||||||
|
\item $\bm w$:\tabto{15mm}Gewichte
|
||||||
|
\item $\bm x$:\tabto{15mm} Inputs
|
||||||
|
\item $b$:\tabto{15mm}Bias
|
||||||
|
\end{itemize}
|
||||||
|
Ein Beispiel für eine solche Output-Funktion ist schon aus \cref{cha:Linear Regression} bekannt.
|
||||||
|
|
||||||
|
\section{Feedforward Neural Networks}%
|
||||||
|
\label{sec:Feedforward Neural Networks}
|
||||||
|
\begin{wrapfigure}{r}{.4\textwidth}
|
||||||
|
\vspace*{-10mm}
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{feedforward_neural_network.png}
|
||||||
|
\caption{Feedforward Neural Network}
|
||||||
|
\label{fig:feedforward_neural_network}
|
||||||
|
\end{wrapfigure}
|
||||||
|
Ein Feedforward Neural Network ist ein Neurales Netzwerk,
|
||||||
|
bei dem die einzelnen Neuronen in Schichten aufgebaut sind,
|
||||||
|
wobei jedes Neutronen nur Inputs aus der darunterliegenden Schicht erhält und an die darüberliegende Schicht weitergibt.
|
||||||
|
Feedforward Neural Networks werden daher auch als \glspl{MLP} bezeichnet.
|
||||||
|
Das Netzwerk hat daher die Form eines gerichteten azyklischen Graphens (Directed Acyclic Graph).
|
||||||
|
|
||||||
|
Hierbei werden die Eingabewerte an die Eingabeschicht (Input Layer) übergeben und die Ausgabe des Neuralen Netzwerkes erfolgt an der Output Layer.
|
||||||
|
Alle Schichten zwischen Input und Output Layer werden als verdeckte Schichten (Hidden Layer) bezeichnet.
|
||||||
|
|
||||||
|
Die Gewichte zwischen den einzelnen Layern bilden eine Matrix $\bm W$.
|
||||||
|
Der Ausgabevektor $\bm y$,
|
||||||
|
bestehend aus den Ausgabewerten der in der Schicht enthaltenen Neuronen,
|
||||||
|
ergibt sich durch:
|
||||||
|
|
||||||
|
\begin{equation} \label{eq:output_function_feedforward_layer}
|
||||||
|
\bm y = \nomeq{activation_function}(\bm W\bm x + \bm b)
|
||||||
|
\end{equation}
|
||||||
|
\begin{wrapfigure}{r}{.3\textwidth}
|
||||||
|
\vspace*{-8mm}
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=0.8\linewidth]{feedforward_neural_network_composition.png}
|
||||||
|
\caption{Feedforward Neural Network mit Funktionen}
|
||||||
|
\label{fig:feedforward_neural_network_composition}
|
||||||
|
\vspace*{-20mm}
|
||||||
|
\end{wrapfigure}
|
||||||
|
Da jede Layer einen Vektor als Eingabe und Ausgabe hat,
|
||||||
|
kann man sie auch als vektorwertige Funktion schreiben
|
||||||
|
\begin{align} \label{eq:feedforward_neural_network_vector_valued_function}
|
||||||
|
\bm h^{(1)} &= f^{(1)}(\bm x)\\
|
||||||
|
\bm h^{(2)} &= f^{(2)}(\bm h^{(1)})\\
|
||||||
|
\vdots\\
|
||||||
|
\bm y &= f^{(L)}(\bm h^{(L-1)})
|
||||||
|
\end{align}
|
||||||
|
Daher kann man die Ausgabe eines Feedforward Neural Networks auch als Komposition der Funktionen der einzelnen Schichten betrachten.
|
||||||
|
\begin{equation} \label{eq:feedforward_neural_network_composition}
|
||||||
|
\bm y = f^{(L)}\circ f^{(L-1)}\circ\dots f^{(1)}(\bm x)
|
||||||
|
\end{equation}
|
||||||
|
Hieraus ergibt sich allerdings auch,
|
||||||
|
dass jedes mehrschichtige Feedforward Neural Network auch durch ein Netzwerk mit nur einer Schicht ersetzt werden kann (Universal Representation).
|
||||||
|
Hierzu wären allerdings eine exponentielle Anzahl an Neuronen nötig,
|
||||||
|
weshalb in der Praxis mehrschichtige Netzwerke verwendet werden (Compact Representation).
|
||||||
|
|
||||||
|
\subsection{Example: XOR}%
|
||||||
|
\label{sub:Example: XOR}
|
||||||
|
({\color{red}siehe Vorlesung 08 Folie 25 und 26})
|
||||||
|
|
||||||
|
\section{\nomf{activation_function}}%
|
||||||
|
\label{sec:Activation Function}
|
||||||
|
Die \nomf{activation_function} gibt vor,
|
||||||
|
ab welchem Schwellwert das Produkt aus Eingangswerten und Gewichten zu relevanten Ausgabewert führt.
|
||||||
|
In den meisten Fällen wird die \glsxtrshort{ReLU} \noms{activation_function} verwendet,
|
||||||
|
wobei es sich auch lohnt, die Leaky \glsxtrshort{ReLU} oder \glsxtrshort{ELU} auszubrobieren.
|
||||||
|
Die Sigmoid Funktion (\cref{ssub:Logistic sigmoid function}) sollte ausschließlich als \noms{activation_function} in Klassifikationsproblemen verwendet werden.\\
|
||||||
|
\includegraphics[scale=.7]{sigmoid_activation_function.png}\\
|
||||||
|
\hrule{\textwidth,1mm}
|
||||||
|
\includegraphics[scale=.7]{tanh_activation_function.png}\\
|
||||||
|
\hrule{\textwidth,1mm}
|
||||||
|
\includegraphics[scale=.7]{ReLU_activation_function.png}\\
|
||||||
|
\hrule{\textwidth,1mm}
|
||||||
|
\includegraphics[scale=.7]{Leaky_ReLU_activation_function.png}\\
|
||||||
|
\hrule{\textwidth,1mm}
|
||||||
|
\includegraphics[scale=.7]{exponential_linear_units_activation_function.png}\\
|
||||||
|
|
||||||
|
|
||||||
|
\section{Optimization}%
|
||||||
|
\label{sec:Optimization}
|
||||||
|
Die Optimierung der Parameter $\bm \theta$ erfolgen nach allgemeinen ML Rezept:
|
||||||
|
\begin{equation} \label{eq:neural_network_parameter_optimization}
|
||||||
|
\bm\theta^* = \argmin_{\bm\theta} \sum_{i=1}^N l(\bm x_i,\bm\theta) + \nomeq{regularization_factor}\text{ penalty}(\bm\theta)
|
||||||
|
\end{equation}
|
||||||
|
Welche Loss Function $l$ verwendet werden sollte hängt dabei vom Anwendungsgebiet ab:
|
||||||
|
\begin{table}[H]
|
||||||
|
\centering
|
||||||
|
\caption{Loss Functions für verschiedene Anwendungsaufgaben}
|
||||||
|
\label{tab:loss_functions_for_different_tasks}
|
||||||
|
\begin{tabularx}{\textwidth}{|c|Y|Y|}
|
||||||
|
\hline
|
||||||
|
& \bfseries Deterministic & \bfseries Probabilistic \\
|
||||||
|
\hline
|
||||||
|
\hline
|
||||||
|
\multicolumn{3}{|c|}{\bfseries Regression} \\
|
||||||
|
\hline
|
||||||
|
\bfseries Output Layer &
|
||||||
|
\begin{tabular}{@{}c@{}} linear \\ $\bm f = \bm W^{(L)}\bm h^{(L-1)}+\bm b^{(L)}$ \end{tabular} &
|
||||||
|
\begin{tabular}{@{}c@{}} linear Gaussian \\ $p(\bm y|\bm x) = \nomeq{gaussian_distribution}(\bm y|\bm W^{(L)}\bm h^{(L-1)} + \bm b^{(L)}, \nomeq{covariance})$\end{tabular}\\
|
||||||
|
\hline
|
||||||
|
\bfseries Loss &
|
||||||
|
\begin{tabular}{@{}c@{}} squared error \\ $l_i(\bm x_i,\bm\theta) = \frac{1}{2}(\bm f(\bm x_i)-\bm y_i)^2$\end{tabular} &
|
||||||
|
\begin{tabular}{@{}c@{}} negative log-likelihood \\ $l_i(\bm x_i,\bm\theta) = -\log\nomeq{gaussian_distribution}(\bm y_i|\bm\mu(\bm x_i),\nomeq{covariance})$ \end{tabular}\\
|
||||||
|
\hline
|
||||||
|
\hline
|
||||||
|
\multicolumn{3}{|c|}{\bfseries Binary Classification} \\
|
||||||
|
\hline
|
||||||
|
\bfseries Output Layer &
|
||||||
|
\begin{tabular}{@{}c@{}} linear \\ $\bm f = \bm W^{(L)}\bm h^{(L-1)}+ b^{(L)}$ \end{tabular} &
|
||||||
|
\begin{tabular}{@{}c@{}} sigmoid \\ $f = \sigma(\bm W^{(L)}\bm h^{(L-1)} + b^{(L)})$\end{tabular}\\
|
||||||
|
\hline
|
||||||
|
\bfseries Loss &
|
||||||
|
\begin{tabular}{@{}c@{}} \nameref{sub:Hinge Loss} \\ $l(\bm x_i, \bm\theta) = \max(0,1-y_i f(\bm x_i))$\end{tabular} &
|
||||||
|
\begin{tabular}{@{}c@{}} negative log-likelihood \\ $l_i(\bm x_i,\bm\theta) = -c_i \log f(\bm x_i)$\end{tabular}\\
|
||||||
|
\hline
|
||||||
|
\hline
|
||||||
|
\multicolumn{3}{|c|}{\bfseries Multi-class Classification} \\
|
||||||
|
\hline
|
||||||
|
\bfseries Output Layer &
|
||||||
|
\begin{tabular}{@{}c@{}} linear \\ $\bm f = \bm W^{(L)}\bm h^{(L-1)} + \bm b^{(L)}$\end{tabular} &
|
||||||
|
\begin{tabular}{@{}c@{}} sigmoid \\ $\bm f = \softmax(\bm W^{(L)}\bm h^{(L-1)} + \bm b^{(L)})$\end{tabular}\\
|
||||||
|
\hline
|
||||||
|
\bfseries Loss &
|
||||||
|
\begin{tabular}{@{}c@{}} Multi-class SVM loss \\ {\color{red} in diesem Fach nicht behandelt} \end{tabular} &
|
||||||
|
\begin{tabular}{@{}c@{}} negative log-likelihood \\ $l_i(\bm x_i,\bm\theta) = -\sum_{k=1}^K \bm h_{c_i,k} \log y_k(\bm x_i)$\end{tabular}\\
|
||||||
|
\hline
|
||||||
|
\end{tabularx}
|
||||||
|
\end{table}
|
||||||
|
|
||||||
|
\section{Feature Learning}%
|
||||||
|
\label{sec:Feature Learning}
|
||||||
|
Die letzte Schicht eines Neural Networks macht im Prinzip nur eine \nameref{cha:Linear Regression},
|
||||||
|
welche durch die vorhergegangenen Schichten vorbereitet wird.
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=0.7\textwidth]{feature_learning.png}
|
||||||
|
\caption{Schichten vor dem letzten Layer bereiten die Daten für eine \nameref{cha:Linear Regression} vor}
|
||||||
|
\label{fig:feature_learning}
|
||||||
|
\end{figure}
|
||||||
|
\subsection{Beispiel}%
|
||||||
|
\label{sub:Feature Learning:Beispiel}
|
||||||
|
{\color{red} siehe Vorlesung 08 Folie 35}
|
BIN
images/Leaky_ReLU_activation_function.png
Normal file
After Width: | Height: | Size: 658 KiB |
BIN
images/ReLU_activation_function.png
Normal file
After Width: | Height: | Size: 574 KiB |
BIN
images/activation_functions.png
Normal file
After Width: | Height: | Size: 192 KiB |
BIN
images/exponential_linear_units_activation_function.png
Normal file
After Width: | Height: | Size: 560 KiB |
BIN
images/feature_learning.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
images/feedforward_neural_network.png
Normal file
After Width: | Height: | Size: 160 KiB |
BIN
images/feedforward_neural_network_composition.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
images/perceptron.png
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
images/sigmoid_activation_function.png
Normal file
After Width: | Height: | Size: 664 KiB |
BIN
images/tanh_activation_function.png
Normal file
After Width: | Height: | Size: 379 KiB |