RNNs hinzugefügt.

This commit is contained in:
paul-loedige 2022-02-18 16:14:28 +01:00
parent a2294db559
commit 6bb66b91cd
13 changed files with 102 additions and 0 deletions

View File

@ -61,6 +61,9 @@
% {{{ acronyms%
\setabbreviationstyle[acronym]{long-short}
\newacronym{GRU}{GRU}{Gated Recurrent Units}
\newacronym{LSTM}{LSTM}{Long-term Short-term Memory}
\newacronym{BPTT}{BPTT}{Backpropagation through time}
\newacronym{CNN}{CNN}{Convolutional Neural Network}
\newacronym{RNN}{RNN}{Recurrent Neural Network}
\newacronym{SSE}{SSE}{Summed Squared Error}

View File

@ -1,3 +1,102 @@
\chapter{\texorpdfstring{\glsxtrlongpl{RNN}}{\glsfmtlongpl{CNN}}}%
\label{cha:RNNs}
\glspl{RNN} stellen eine Erweiterung von \glspl{CNN} (\cref{cha:CNNs}) dar.
Hierbei wir nicht nur aus einer einmaligen Eingabe eine Ausgabe produziert.
Stattdessen ist die Anzahl der Ein"~ und Ausgabeelemente flexibel gestaltet.
Hierbei ist die Mehrzahl nicht im absoluten Sinne,
sondern im zeitlichen Sinne zu verstehen (mehrere Eingaben\slash\,Ausgaben hintereinander).
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{RNN_process_sequences.png}
\caption{Verschiedene Prozess Sequenzen eines \texorpdfstring{\gls{RNN}}{RNN}}
\label{fig:rnn_process_sequences}
\end{figure}
\begin{wrapfigure}{r}{.3\textwidth}
\centering
\includegraphics[width=0.5\linewidth]{vanilla_rnn.png}
\caption{Vanilla \texorpdfstring{\glsxtrshort{RNN}}{\glsfmtshort{RNN}}}
\label{fig:}
\end{wrapfigure}
\glspl{RNN} unterscheiden sich vor allem darin von \glspl{CNN},
dass sie zu jedem Zeitpunkt einen festen Zustand $h$ haben.
Der Zustand ergibt sich aus der Rekurrenz Gleichung (recurrence formula).
\begin{align} \label{eq:recurrence formula}
&\bm h_t = f_{\bm W}(\bm h_{t-1},\bm x_t)
\end{align}
\begin{itemize}
\item $\bm h_t$: neuer Zustand
\item $f_{\bm W}$: Funktion mit den Parametern $\bm W$
\item $\bm h_{t-1}$: alter Zustand
\item $\bm x_t$ Input zum Zeitpunkt $t$
\end{itemize}
\section{\texorpdfstring{\glsxtrshort{RNN}}{\glsfmtshort{RNN}} Computational Graph}%
\label{sec:RNN Computational Graph}
{\color{red} Vorlesung 09 Folien 58-64}
\section{\texorpdfstring{\glsxtrfull{BPTT}}{\glsfmtfull{BPTT}}}%
\label{sec:BPTT}
Die Gewichte in einem \gls{RNN} können mithilfe von \gls{BPTT} angepasst werden.
Hierbei wird der Gradient wie bei der normalen \nameref{sec:Backpropagation} errechnet,
wobei zusätzlich noch die Differentiation in Zeitrichtung durchgeführt werden muss.
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{BPTT.png}
\caption{\texorpdfstring{\glsxtrlong{BPTT}}{\glsfmtlong{BPTT}}}
\label{fig:BPTT}
\end{figure}
\subsection{Truncated \texorpdfstring{\glsxtrshort{BPTT}}{\glsfmtshort{BPTT}}}%
\label{sub:Truncated BPTT}
Da \gls{BPTT} bei einer langen Zeitfolge sehr rechenintensiv ist,
wird der Algorithmus zumeist nur für die letzten paar Schritte druchgeführt.
\begin{figure}[H]
\centering
\includegraphics[width=0.6\textwidth]{truncated_BPTT.png}
\caption{Truncated \texorpdfstring{\glsxtrshort{BPTT}}{\glsfmtshort{BPTT}}}
\label{fig:truncated_BPTT}
\end{figure}
\subsection{Gradient Flow}%
\label{sub:Gradient Flow}
\includegraphics[scale=.6]{gradient_flow_vanilla_rnns.png}\\
\includegraphics[scale=.6]{gradient_flow_vanilla_rnns2.png}
\section{\texorpdfstring{\glsxtrfull{LSTM}}{\glsfmtfull{LSTM}}}%
\label{sec:LSTM}
Da die Probleme des Gradient Flows bei Vanilla \glspl{RNN} (explodierende oder verschwindende Gradienten) gerade bei langen Zeitfolgen problematisch sind,
wurde das System der \glspl{LSTM} entwickelt.
Hierbei wird zu dem Zustand $\bm h$ noch ein weiterer Speicherzustand $\bm c$ hinzugefügt.
Die Berechnung erfolgt durch
\begin{equation} \label{eq:LSTM function}
\bm c = \bm f_t\circ\bm c_{t-1} + \bm i_t\circ\bm g_t,\quad \bm h_t = \bm o_t\circ\tanh{\bm c_t}
\end{equation}
\begin{wrapfigure}{r}{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{LSTM.png}
\caption{\texorpdfstring{\glsxtrshort{LSTM}}{\glsfmtshort{LSTM}}}
\label{fig:LSTM}
\end{wrapfigure}
\begin{itemize}
\item $\bm c$ Speicherzustand zum Zeitpunkt $t$ bzw. $t-1$
\item $\bm f$ Forget Gate: \tabto{3cm}$\bm f_t = \nomeq{sigmoid}\left(\bm W_f \begin{bmatrix} \bm h_{t-1} \\ \bm x_t \end{bmatrix}\right)$
\item $\bm i$ Input Gate: \tabto{3cm}$\bm i_t = \nomeq{sigmoid}\left( \bm W_i \begin{bmatrix} \bm h_{t-1} \\ \bm x_t \end{bmatrix}\right) $
\item $\bm g$ Gate Gate: \tabto{3cm}$\bm g_t = \tanh \left(\bm W_g \begin{bmatrix} \bm h_{t-1} \\ \bm x_t \end{bmatrix}\right)$
\item $\bm o$ Output Gate: \tabto{3cm}$\bm o_t = \tanh \left(\bm W_o \begin{bmatrix} \bm h_{t-1} \\ \bm x_t \end{bmatrix}\right)$
\end{itemize}
Die Gatter sind dafür da,
zu entscheiden,
wann das \gls{RNN} sich ein Zwischenergebnis merkt und wann nicht
\subsection{Gradient Flow}%
\label{sub:LSTM:Gradient Flow}
\includegraphics[scale=.6]{LSTM_gradient_flow.png}\\
\includegraphics[scale=.6]{LSTM_gradient_flow2.png}
\subsection{Deep \texorpdfstring{\glsxtrshortpl{LSTM}}{\glsfmtshortpl{LSTM}}}%
\label{sub:Deep LSTMs}
\includegraphics[scale=.6]{deep_lstms.png}
\section{\texorpdfstring{\glsxtrfull{GRU}}{\glsfmtfull{GRU}}}%
\label{sec:GRU}
\includegraphics[scale=.6]{GRU.png}

BIN
images/BPTT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
images/GRU.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 KiB

BIN
images/LSTM.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
images/deep_lstms.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
images/truncated_BPTT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
images/vanilla_rnn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB