forked from rubenvereecken/thesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp.tex
1175 lines (1064 loc) · 39.1 KB
/
exp.tex
1
\chapter{Architecture Evaluation}\label{chap:experiments}% TODO maybe get rid of this section\section{Problem Statement}\label{sec:problem_statement}In the Deep Q-Network section (\ref{sec:dqn})I described an approach to deep reinforcement learning.While the approach works well,it has not managed to beat all games under considerationnor would it generalize well to just any gamethat fits the input description.Much care has been taken to make DQN as generic as possible,yet one detail stands out.A single state consists of four consecutive image framesin order to make the problem more Markovian,a useful trait because it allows us to rely onuseful theoretical properties that have been establishedfor Markov settings.However, not all games carry sufficient informationin the last four frames alone.Some need a few more,while others could conceivablyshow informationthat will then be needed to act correctlyafter a long period of time has passed.In other words, there could be hidden statethat the agent nevertheless had access toat some point in the past.A good example of such a game is Blackjackwhere cards used in previous roundsaffect the odds for later rounds.\paragraph{}My goal is now to explore different alternativesto this approach,to explore different ways of dealing with time.I will explore two approachesthat still make use of a fixed time windowlike DQN uses- though they do so differently -and one without window at allthat is more apt at learning long-term dependencies.\paragraph{}The rest of this chapter is organized as follows.First, I will examine the Arcade Learning Environmentin close detail in so far as this benefitsthe following sections.Then, I will closely investigatethe different approachesto the time problem.I start out by examiningwhether the 4 stacked frames approach taken by DQNis actually beneficial to the learning processin section \ref{sec:stacked_frames_approach}.The three alternatives I will discuss afterwards are\textit{Late Fusion}(\ref{sec:late_fusion_network_approach}),\textit{3D Convolutions}(\ref{sec:3d_convolutional_network_approach}),and \textit{LSTMs}(\ref{sec:long_short_term_memory_approach}).Each in turn will be discussed,then explored and evaluated.Finally,an overview and comparisoncan be found in section \ref{sec:overview}.\section{Arcade Learning Environment}\label{sec:ale}In order to fully understand the experiments that followand the implications of their results,it is important to first have a closerlook at the Arcade Learning Environment\parencite{Bellemare2013}.ALE is built on top of Stella\footnote{http://stella.sourceforge.net},an open-source Atari emulator.It enables one to programmatically interactwith any compatible Atari game file.This includes getting the screen in raw pixels,access to the Atari's emulated RAM,the game's current scoreand actually interacting with the game by sending actions.\paragraph{}To appreciate the setting completely we will need toinvestigate the hardware the games considered here used to run on.The Atari 2600 was released in 1977.Its CPU ran at 1.19 Mhz,more than a 1000 times slowerthan a single average core used for personal computers nowadays.The size of the RAM was especially small compared towhat is used in modern days, with 128 bytes.Of special interest to us is the console's graphic component.The screen is 210 by 160 pixelsand could display up to 128 colors.The Atari 2600 console is interacted with usinga joystick and a button.The joystick can move in 8 directions.Combining that,along with pushing the buttonwhile moving the joystick(or not moving it)gets us to 17 distinguishable actions.Add one for not doing anything at alland we have a total of 18 actions for our learning agent.% just thought it was nice to see wtf it is\begin{figure}[h]\center\begin{subfigure}[t]{.5\textwidth} \centering \includegraphics[width=\textwidth]{ntsc_palette.png} \vspace{.1\baselineskip} \caption[NTSC Palette]{ The Atari 2600 NTSC Palette used by many games. It allows 3 bytes for luminiscence and 4 bytes for chrominance, resulting in the 128 distinct colors you see here. } \label{fig:ntsc_palette}\end{subfigure}\hfill\begin{subfigure}[t]{.4\textwidth} \centering \includegraphics[width=\textwidth]{atari.jpg} \vspace{.1\baselineskip} \caption[Atari]{ The Atari 2600 with its joystick. } \label{fig:atari}\end{subfigure}\caption[Atari]{}\label{fig:dqn_networks}\end{figure}\subsection{Shortcomings}\label{sub:shortcomings}While the Atari's computational simplicity,small screenand relatively straightforward gamesmake it a great testbed for reinforcement learning,the same characteristicsbring along a few shortcomingsthat bear discussing.\paragraph{}First off, the Atari 2600is entirely deterministic.This allows some games to be abusedby learning how to exploit bugsor otherwise causing situationsthat would be very hard for a human to replicate,yet that a learning algorithm could easily managein a deterministic setting.This exploitation of a game's weak pointsdoes not sound bad on its own- after all, the agent is learning -but it is obviously a case of overfittingwhich should preferably be avoided.DQN tries to avoid this by adding a random amountof nullops at the start of the turn,that is, the agent waits a random amount of turnsbefore it can play.\paragraph{}The console's determinism makes it sothat given the agent's history,the next state given an actioncan be known exactly.However,very few games actually need more thana few frames of historyin order to achieve this Markov property.Since the main interest of this thesisis dealing with time,long-term time dependencies would be especially interesting to investigate.Sadly, however good of a testing environment ALE may seem,it lacks thoroughly in this regard.A good POMDP game is Blackjack,though this is not supported by ALE.We will discuss an additional benchmarkto circumvent this in section\ref{sec:flickering_pong}.\paragraph{}I will now discuss two games in some detailand shed light on their core distinctionsin order to later understand and explainthe differences between their learning results.\subsection{Space Invaders}\label{sub:space_invaders}Space Invaders is an arcade game published in 1978.The player controls a laser cannonwhich it can move along the bottom of the screenand to fire at aliens that move left to right and gradually downwardsand can even shoot back.The player can even hide below shieldswhich can get destroyed by lasers from either side.As the player progresses,the aliens start to move faster and faster.The game is overonce they reach the bottom of the screen.\begin{figure}[htpb] \centering \begin{subfigure}[t]{.49\textwidth} \includegraphics[width=1\textwidth]{space_invaders.png} \end{subfigure} \begin{subfigure}[t]{.49\textwidth} \includegraphics[width=1\textwidth]{space_invaders2.png} \end{subfigure} \caption{Space Invaders} \label{fig:space_invaders}\end{figure}Each time an alien gets killed the agent gets a rewardthat depends on the type.The agent needs to learn to associate this rewardwith the action that ultimately caused it,namely firing at the place where an alien would beat the time the laser arrives.This can be rather tricky as alienscan move in multiple directions,so ideally the agent must somehow learn this patternin order to excel at the game.An agent receives a large bonus rewardwhen it destroys a periodically appearing fast-flying saucerat the top of the screen.This event is especially hard to learn becauseof its rarity compared to other situations.\subsection{Pong}\label{sub:pong}Pong was originally an arcade game by Atari.It was then ported to the Atari 2600under the name \textit{Video Olympics},though in this text I will refer to it simply as Pong.\begin{figure}[htpb] \centering \includegraphics[width=0.5\linewidth]{pong.png} \caption{Pong} \label{fig:pong}\end{figure}The game is a simulation of badmin.It features two paddles,each controlled by a different player (or AI).A ball is hit back and forth between the playersby moving the paddle up and downand intercepting the ball to bounce it back.A point is scored when the opponentfails to do so.\subsubsection{Flickering Pong}\label{sec:flickering_pong}Since regular Pong and indeed most Atari gamesbecome at least approximately Markoviangiven a small history,we would like a different benchmarkto compare techniquesfor partially observable MDP's.Such a one has been introduced by \citeauthor{Hausknecht2015} (\citeyear{Hausknecht2015})with \textit{Flickering Pong}.It is entirely the same game as Pong,except a frame can only be observed with some probability $p$and becomes obscured, that is, entirely black, otherwise.This results in a stochastic screen flickering for the learning agent.In order to be successful at Flickering Pong,an agent must learn to robustlyestimate variables such as ball velocityacross multiple frames,half of which are expected to be obscured.\section{Stacked Frames Approach}\label{sec:stacked_frames_approach}In order to get a better feelingof why the dimension of time in reinforcement learningmerits closer examination and further research,this section will elaborate on the current approachas described by\citeauthor{Mnih2013} (\citeyear{Mnih2013}).\citeauthor{Mnih2013}found that for most games under discussion4 frames of history is sufficient to render the game approximatelyor completely Markovian.This means that when considering not only a single framebut also the 3 prior to it,all information that could ever be required to make an optimal decisionat that point is encompassed within this small fixed window.\paragraph{}In order to combine these frames,it is sufficient to make sure each image frame only has a single image channel(e.g. grayscale or luminiscence)so the image depth dimension can be reusedto simply stack the frames on top of each other.This limitation is present because 2D convolutional networkscan only handle three dimensions,of which over the third one(often referred to as depth or image channels)has no control in terms of filter size;it always reaches across the whole depth.This way of stacking frames along with the rest of the standard DQNis depicted in Figure \ref{fig:nips_network2}.\begin{figure}[htpb] \centering \includegraphics[width=0.8\linewidth]{nips_network2.pdf} \caption[DQN architecture]{ DQN architecture by \cite{Mnih2013}. Note that the frames can not have any depth because of the limitations imposed by 2D convolutions. } \label{fig:nips_network2}\end{figure}In order to determinewhether this frame stacking approachactually benefits from the extra history,I investigated multiplethe learning process for multiple gameswith both architectures.We are interested in the learning curvewhich can be characterized withtotal accumulated reward over time,as suggested by \citeauthor{Bellemare2013} \citeyear{Bellemare2013}.This is done by periodicallyholding greedy playthroughs for 50000 stepsand then averaging the accumulated rewardsover the episodes.In Figure \ref{fig:stacked_vs_single_rewards}we can see rewards over time as the agent progresses.While it does show general tendencies quite well,the graphs are noisy even though results are averaged over 5 runs.This is especially the case for DQN with 4 frames.As \citeauthor{Mnih2013} (\citeyear{Mnih2013}) note,this is due to the fact that small policy weight changescan result in vastly different visited states for the policy.\begin{figure}[htpb] \centering \includegraphics[width=\linewidth]{stacked_vs_single.pdf} \caption[DQN reward over time]{ Rewards over time for 4 stacked frames as input compared to just a single one for five different games with experiment parameters as in Table \ref{tab:boost}. Shaded areas depict the $95\%$ confidence interval. } \label{fig:stacked_vs_single_rewards}\end{figure}\paragraph{}It can be often hard to tell if the agent is making steady progressusing the reward curvesand it can be even harder to compare different approaches.To combat this I will often employ an alternative methodfor evaluating an agent's learning behavior.At the start of a learning experiment, 3200 states are gatheredusing a random policy.Periodically,at the same time of the greedy playthroughs,for each of these states the maximum Q-value is computedand the average over all these states then collectedas an indication of learning behavior.\begin{figure}[htpb] \centering \includegraphics[width=\linewidth]{stacked_vs_single_qs.pdf} \caption[DQN Q-values over time]{ Average maximum Q-value over time for 3200 holdout states. Shaded areas depict the $95\%$ confidence interval. } \label{fig:stacked_vs_single_qs}\end{figure}\paragraph{}The resulting graphs in Figure \ref{fig:stacked_vs_single_qs}are much less noisyand give a decent indication of how well thedifferent agents learn the games' value functions.From here on out,all experiments will be set up according tothe experiment descriptionFigure \ref{fig:basic_setup}.\paragraph{}We can now analyse the experiment's results.For 4 out 5 games we can say that the stacked frames approachperforms noticeably better,although for the game Freeway results are so noisywe can not make a strong statement.The game Seaquest seems to form an outlierin that the stacked approach forms no immediately obvious advantage.It does look like it might not have stagnated entirelyand is actually improving beyond the single frame DQNbut we do not have data beyond that pointand it has not helped within the employed 5 million training steps.\paragraph{}These data indicate that the stacked approach doesfare better compared to just using a single framealthough it is heavily dependent on each game's specific mechanicsand it is not true for any and all games.What we can not conclude with certainty howeveris whether the results are due to the historic informationor increased capacity of the first convolutional layerin order to cope with the extra frames.\section{Late Fusion Network Approach}\label{sec:late_fusion_network_approach}The first alternative to the standard DQNconsidered here isthe Late Fusion DQN architectureinspired by \citeauthor{Karpathy2014} (\citeyear{Karpathy2014})who successfully deployed it foraction recognition in video clips.The base premise for this architectureis that in order to capture time dependenciesit is sufficient to look at differencesbetween frames.Presumably,this works better with short-term dependenciesas differences between frames close to each other in timeare smaller.Also, Late Fusionconsiders two frames with a fixed distance in time in between.This can only yield good results for longer time dependenciesif the dependency always spans approximately the same amount of time,a requirement that is undesirableand not always satisfiable.\paragraph{}The Late Fusion DQN is based on the default DQN implementation.In fact, the learning algorithm is entirely the sameand parameters are as depicted in Table \ref{tab:base}.Instead of a single stack of convolutional layers,we now have two towers that each take as input a single frame.The frames are separated by a fixed amount of framesthat go unused for the pass.Each of the two towers has no access to the framethat is input to the other one.Rather, the towers get combined by a fully connected layerthat is also the first of the layers that has accessto both time steps.Since each convolutional network now only has a single frame as input,we suddenly get back the image channel input dimension (depth)that was previously used to stack frames together.In order to use that dimension for time,DQN uses a grayscalewhich only requires a single scalar valueand as such this channel dimension was implicit before.Now that we have access to an extra input dimensionwe can again use color channelssuch as RGB,which might add useful information to the model.\paragraph{}The general gist to the Late Fusion architectureis that the convolutional layerscompute high-level featureswhich the fully-connected layer can then comparein order to compute the correct output.The full architecture is depicted in Figure \ref{fig:late_fusion}.\begin{figure}[htpb] \centering % \captionof{figure}{Late Fusion Network} \includegraphics[width=0.8\linewidth]{late_fusion.pdf} \caption[Late Fusion]{ Late Fusion DQN. A sample of $n$ consecutive frames is chosen but only the outer two frames feed into the network. The features learned by the two convolutional networks is combined through the fully-connected layer that combines both. Only from the fully-connected layer up is information from two different time steps available. } \label{fig:late_fusion}\end{figure}\subsection{Tuning}\label{sub:late_fusion_tuning}We can try a few different alterations to the basic late fusion architecture.First off we can decide whether convolutional layer weights should be sharedbetween layers at the same levelor separate for each tower.Then there is the extra image dimension we have access to.In order to make use of it,I used frames with 3 color channelsto hold RGB values.A performance comparison for the game Pong is depicted inFigure \ref{fig:late_fusion_pong_rewards}.\begin{figure}[htpb] \centering \includegraphics[width=.9\linewidth]{late_fusion_pong_rewards.pdf} \caption[Late Fusion rewards over time]{ Rewards over time for Late Fusion architectures compared to standard DQN.} \label{fig:late_fusion_pong_rewards}\end{figure}\begin{table}[htpb] \center \renewcommand{\arraystretch}{1.3} \input{tables/lf_ttt.tex} \caption[Late Fusion time to threshold]{ Time to threshold of an accumulated reward of 10 for Pong on Late Fusion architectures. }\end{table}\paragraph{}Keeping the weights the same between convolutional layers on the same levelseems to offer an advantage over separate weights.What this effectively doesis force the convolutional layers to learn the same featuresso the output of the top convolutional layershas exactly the same semantics.This way the fully-connected layer has accessto the difference between frames at different time steps.When not sharing weights each convolutional layerhas to learn features independently which slows down learningand does not guarantee the same features will be learned.In fact, this approach does not even outperformthe single-frame DQN.\paragraph{}While the shared weights networkstill does not learn as quickly as regular DQN,giving the network access to RGB values offers obvious gainsin terms of learning speed.The motivation behind access to three separate color channelsis that it is easier to learn a function on three variablesthan just a single onethat is trying to encompass the same information.With multiple inputs (color channels)the network gains more representational power.Figure \ref{fig:nips_vs_nature_rewards}illustrates how some games can benefitfrom added network capacity.\paragraph{}We can conclude that using two separate time stepsas input to the networkthat are represented by the same learned featuresoffers gains\section{3D Convolutional Network Approach}\label{sec:3d_convolutional_network_approach}Building on the idea that time is an extra spatial dimensionand should not be handled differentlyfrom image width or height,I investigate 3D convolutional layers next.The idea of convolutions over time has already beenapplied successfully by \citeauthor{claessens} (\citeyear{claessens}).In the original DQN implementationthe time dimension gets flattened immediatelyby the first convolutional layerand is not present explicitlyin its output;only the first convolutional layerhas explicit access to timebecause the 2D convolutional layer implementationextends along the entire depth of the input.Intuitively this means that only low-levelfeatures over time can be learnedwhereas we can easily imaginemore abstract featuresthat relate to time.This is where the 3D convolutional network comes in,in order to allow us to specify step size and stride across timein order to control how time is propagated through the entire network.\paragraph{}The original 2D convolution setup in DQNis exactly the same as a 3D convolutionwith 4 input frames and only a single image channel (grayscale),where the filter over time spans across all 4 input frames,as illustrated by Figure \ref{fig:conv2d_time}.A 3D convolutional layer gains an extra dimensionwhich can be used for image depth, like colors.It also allows us to specify the filter size and stride over time.Figure \ref{fig:conv3d_time} for exampleemploys a time filter size of 2 and a stride of 1.Since this comes down to combining every consecutive pair of frames,the output of the convolutional layer has a time dimensionthat is shrunk by 1 compared to the number of input frames.\begin{figure}[!htpb] \begin{subfigure}[t]{.45\textwidth} \centering \includegraphics[width=.8\textwidth]{conv2d_time.pdf} \caption{ 2D convolution for a single feature as used by \cite{Mnih2013}. Since time is treated as image depth, a feature always spans across all time frames. } \label{fig:conv2d_time} \end{subfigure} \hfill \begin{subfigure}[t]{.45\textwidth} \centering \includegraphics[width=.8\textwidth]{conv3d_time.pdf} % \vspace{.1\baselineskip} \caption{ 3D convolution for a single feature (depth slice of the convolutional layer) with 4 input frames and a time filter size of 2. Connections of the same color depict shared weights. } \label{fig:conv3d_time} \end{subfigure} \caption{ Convolutions over time. } \label{fig:conv3d}\end{figure}\paragraph{}The 3D Convolutional DQNis again based entirely on the original DQN implementationwith parameters in table \ref{tab:base}.An example instantiation of the 3D convolutional DQNcan be found in Figure \ref{fig:conv3d_network}.It leaves the amount if input channels unspecified;in our case this can either be 1 for grayscaleor 3 for RGB values.There are again two convolutional layers.Since these make use of 3D convolutions,filters over time can be specified.Both layers in Figure \ref{fig:conv3d_network}use a time filter size of 2,so the time dimensions shrinks by 1 after each.The fully-connected layerstill has a time dimension of size 2 to cope with in this example,as opposed to a flattened time dimension in the original DQN architecture.\begin{figure}[htpb] \centering \includegraphics[width=\textwidth]{conv3d_network.pdf} % \vspace{.1\baselineskip} \caption[3D Conv DQN]{ 3D convolutional DQN. The input consists of 4 frames that can each have $C$ image channels. Both convolutional layers employ a time filter size of 2, meaning a single weight corresponds to two frames of the layer's input. Combined with a time stride of 1, the time dimension of the output of each consecutive layer is 1 smaller than its input. } \label{fig:conv3d_network}\end{figure}\subsection{Tuning}\label{sub:conv3d_tuning}There are different ways to combine time frames throughout the network.A decision can be made between `merging'(feeding multiple frames into a layer at a time)early or later on.For readability,a network with time filter sizes$n1$ and $n2$ for its two convolutional layers respectivelyis denoted as a $(n1, n2)$ 3D convolutional network.Next to varying time filter sizesI also attempt a variation with an extra max pooling layerright after the second convolutional layerwith a filter size of 2 across all dimensions.Just like with the late fusion architecturea variation that uses RGB image channels has also been attempted.The learning curves for all of these networksare shown in Figure \ref{fig:conv3d_both}.\begin{figure}[htpb] \centering \begin{subfigure}[t]{.49\linewidth} \caption{Reward learning curve} \includegraphics[width=1\textwidth]{conv3d_rewards} \end{subfigure} \begin{subfigure}[t]{.49\linewidth} \caption{Average Q learning curve} \includegraphics[width=1\textwidth]{conv3d_qs} \end{subfigure} \caption[3D Conv DQN comparison]{ 3D convolutional architecture comparison for Pong } \label{fig:conv3d_both}\end{figure}\paragraph{}It can easily be seen that the max pooling variantperforms worst.Not incidentally,this is the one that supplies the least informationto the fully-connected layer.Among the networks with different time filter sizes,the $(2,2)$ variant seems to learn the fastest,followed by the $(3,1)$ variant.These are the ones that significantly outperform DQN,along with the RGB variant.The two that perform worse and indeedare closest in performance to the standard DQNare also the ones that perform the most time merges;these provide less information to the fully-connected layeror at least provide information in a more compact mannersince their output is smallest.\paragraph{}Just as in the late fusion scenario,using RGB-colored input performs noticeably betterand even fares better than standard DQN.\begin{table} \center \renewcommand{\arraystretch}{1.3} \input{tables/conv3d_ttt.tex} \caption[3D Conv time to threshold]{ Time to threshold of an accumulated reward of 10 for Pong on 3D convolutional architectures. The max pooling architecture is left out because it did not always manage the threshold within the allotted time. } \label{tab:conv3d_ttt}\end{table}\paragraph{}Another way to characterize learning speed is\textit{time to threshold} reward.Table \ref{tab:conv3d_ttt}shows this value for all 3D convolutional networksfor a threshold reward of 10which can be considered more than decentas it is the point at whichthe agent beats the AI75\% of the times.The time to threshold metricconfirms the above deductions madefrom Figure \ref{fig:conv3d_both}.Statistical tests to back up conclusionscan be found in Table \ref{tab:conv3d_wilcoxon}.\section{Long Short-Term Memory Approach}\label{sec:long_short_term_memory_approach}The last approach I consider involvesthe use of Long Short-Term Memory,a specific kind of recurrent neural networkthat is capable of learning time dependenciesover arbitrary and unknown amounts of time(section \ref{sec:lstm}).While I use LSTMsas part of a deeper neural network,LSTM units have already been successfully appliedto simpler problems\parencite{Bakker2001}.The very same architecture I will discuss herehas been attempted by\citeauthor{Hausknecht2015} (\citeyear{Hausknecht2015})who found favorable results for some few games.\citeauthor{Hausknecht2015}concluded that few significant differenceswere found with the original DQN architectureand that no general benefit could be gained comparedto simply stacking frames.One could however arguethat merely getting rid of the fixed windowwhich stacking automatically impliespresents a merit in its own rightand allows for better generalization of the architectureto other problem domains.\paragraph{}Recall that the LSTM unit as we consider it herecontains three \textit{gates}and an internal cell state (Section \ref{sec:lstm}).The input gate and forget gate together governthe content of the internal state,which forms the memorizing core of the unit,whereas the output gatelearns how to output the internal statein order to create the gate's output.\paragraph{}The intuitive idea behind the use of LSTMsis that the units will learn to remember important eventsand then use that information at some later timewhen it is required.Given their goal,they are especially useful in Partially Observable Markov Decision Processessuch as we have when considering only one Atari frame at a time.Sadly, Atari games generally only have very short time dependencieswhich make them an imperfect testbed forlong-term dependency learningso we will focus on learning those instead.\begin{figure}[htpb] \centering \includegraphics[width=.85\linewidth]{lstm_network.pdf} \caption[LSTM DQN]{LSTM DQN} \label{fig:lstm_network}\end{figure}\subsection{Design and Training}\label{sub:lstm_design_and_training}The Long Short-Term Memory variantof the deep Q-network- or Deep Recurrent Q-Network,as named by \cite{Hausknecht2015} -is once again based on the DQN versionby \cite{Mnih2013},with common parameters in Table \ref{tab:base}and LSTM-specific parameters in Table \ref{tab:lstm_params}.\paragraph{}The network is constructed by taking outthe first fully-connected layerand replacing it with an LSTM layerwith the same or different amount of units.Everything else except the input stays the same.Instead of stacking frames along the depth dimension of the input,only one frame at a time now gets fed to the network.It is up the LSTM layer to handle memorization across time.Just like with the previous two approaches,ridding ourselves of the stacked frames opens up the input depth dimensiononce againto be used for image channels like RGB values.The network architecture is displayed in Figure \ref{fig:lstm_network}.\paragraph{}In the original Deep Q-Learning algorithm,after each action selectiona mini-batch learning update would occur.LSTMs require input frames to be observed in chronological order, however.This learning approach would not workbecause data gathering steps would be interleaved with mini-batch updates,breaking the required flow of time,so the LSTM unitswould consider the mini-batch to follow the observed frame right before the updatewhich is of course not the case.On top of that, mini-batches contain random samplesin order to break correlationbetween consecutive frameswhile LSTMs, again, require uninterrupted sequences.\paragraph{}In order to accomodate the new requirements,I adapted the Deep Q-Learning algorithmto keep sequential information intact at all times.First off,this required a new sampling method.Instead of sampling mini-abtches of 32 random samples,I now sample \textit{random sequences}.This is done by selecting a single random time step,then including consecutive time stepsuntil either the batch sizeis reached or the episode terminates.In the following experiments,batch size is always equal tothe amount of unroll steps:this is the number of steps includedin the backpropagated gradient.The batch then gets treated like it would be normally,feeding it into the learning update while keeping the order intactso the LSTM's internal state can follow along.\paragraph{}This brings me to the internal state reset and backup.At the start of any episode,the LSTM's internal state along with its output historygets reset to initial values.These initial values can be fixed and suppliedby the network designeror even learned dynamically.The reset is required to make clear to the LSTMthat the first state of an episodedoes not follow the terminal state of the last episode.A parameter \textit{backup} and subsequent reseton the other handoccur at the start of every mini-batch learning update.This is done so the sequential mini-batchforms an isolated sequence of eventsand no accidental information from before the update gets carried into the updateby the LSTM's internal memory.After the updatethe internal state and output historyare restored from the backupso the agent can go on gathering dataas if no interruption had just occurred.\subsection{Tuning}\label{sub:lstm_tuning}There are a couple of hyper parameters to an LSTM unitthat one could consider exploring.I will restrict myself to two here:number of units in the layer,which effectively determines layer capacity,and number of unroll stepswhich affectshow many time steps are included in the update.Reward and average Q curves are depicted in Figure \ref{fig:lstm_both}.\begin{figure}[htpb] \centering \begin{subfigure}[t]{.49\linewidth} \caption{Reward learning curve} \includegraphics[width=1\textwidth]{lstm_rewards.pdf} \end{subfigure} \begin{subfigure}[t]{.49\linewidth} \caption{Average Q learning curve} \includegraphics[width=1\textwidth]{lstm_qs.pdf} \end{subfigure} \caption{LSTM learning curves} \label{fig:lstm_both}\end{figure}It is hard to make out results from the reward curve becauseof its extreme noisiness.Interestingly,the network with fewer unitsand more unroll steps included in the gradientis noisiest both in its performanceand in its Q learning curve,yet it is also the one that reaches highestin terms of reward.It also seems that it might still be learningat the time the experiment is stopped.The network with more units seems to learn most stably.It gets a good start and its Q-values stay approximately stablefor a long time.Yet it still does not outperformthe network with radically different settings(less units and less gradient steps).\paragraph{}Compared relatively,the different architectures do not differ radicallyin terms of performance.However,they do underwhelm heavilywhen compared to regular DQNwhich is not displayed in order to not distort the graphs too much.While the reward curves do seem to go up,they do so a lot more slowlythan with the previous methodsthis thesis considers.Next section will form an overview of all methods.\section{Overview}\label{sec:overview}For this section,each architecture has its hyper parameters setto the variant that performed bestin each of the previous tuning sections.\begin{table}[htpb] \center \begin{tabular}{ll} Architecture & Parameters \\ \hline Late Fusion & Shared parameters \\ 3D Conv & time filters of both conv layers of size 2 \\ LSTM & 256 units, 30 rollout \\ \end{tabular} \caption[Best architecture hyper parameters]{ Best hyper parameters for each architecture insofar as these are explored in the corresponding tuning sections. }\end{table}\begin{figure}[htpb] \centering \includegraphics[width=.9\linewidth]{combined_rewards.pdf} \caption[Architecture performance comparison]{ Rewards over time for the best-performing instantiations of each architecture for Pong. } \label{fig:combined_rewards}\end{figure}\paragraph{}Figure \ref{fig:combined_rewards}offers an overview of each architecture'slearning curve in terms of accumulated reward.I have included the RGB variantsthough as noted before there is a strong suspicionthat these outperform others because of the added network capacity.Still, it is interesting to compare the two against one another.\paragraph{}Note that for Late Fusion and 3D Conv,the difference between their RGB variantsis far smaller than the differencebetween their regular versions.Or, viewed otherwise,employing multiple channelsgives the Late Fusion networkmuch more of a boost in performance than it does 3D Conv.Using RGB seems to close the gap somewhat,it levels the playing field.The Late Fusion variant with RGBoutperforms both regular 3D Conv and standard DQN,meaning the added information and capacitymake a vast difference.\paragraph{}Without making use of extra input channels,the only method I considered that outperforms standard DQNis the 3D convolutional network.It is capable of learning features over space and timeat each level of abstraction.\paragraph{}While the network that employs an LSTM layerdoes seem to be learningand does not look like it has finished doing so,it learns terribly slowlywhich makes it an infeasible approachfor the problems considered here.The goal was for the LSTM unitsto learn short-term dependencies between frames,just like the networks that worked over multiple frames did.Sadly,the test problems at hand did not contain any long-term dependenciesthat could be learned to improve performanceso we cannot compare LSTM to other networkson this alleged strength,only short-term dependencies.\paragraph{}Upon closer examination of the LSTM layer's internal stateafter an episode,it seems like it has shifted only small amountsfrom its initial zero initializationat the start of an episode.It may be the case that the LSTM's internal statestruggles to keep up with the changes in its input.The way the input affects the internal stateis regulated by the input gate,the training of which is in turn affectedby the combined interplay with the other gatesthat all have to be trained themselves.It is not inconceivable that the trainingof this whole contraption that is the LSTM unittakes longer thanit would the training of a simpler layersuch as the fully-connected one in DQN.\subsection{Flickering Pong}\label{sub:comb_flickering_pong}\paragraph{}The Flickering Pong experimentis intended to obscure observed state tremendouslyin order to further discern which architecturesperform well on a partially observable MDP.For the following analysisI ran all architectureson the Flickering Pong game with $p=0.5$so half of the observations are expected to be completely obscured.Each observations is stored in the replay memory as it is perceivedand testing occurs in the same flickering environment.\paragraph{}Architectures are tested with both 4 and 10 frames as input.The LSTM architecture is left out in the following discussionbecause its learning progresswas already terribly slow compared to other architectures.Indeed, preliminary experimentsshowed that the LSTM architecturebarely learned anything in terms of Q-values for the durationof the experiments.\begin{figure}[htpb] \centering \includegraphics[width=0.9\linewidth]{comb_flicker_rewards.pdf} \caption[Architecture performance comparison on Flickering Pong]{ Rewards over time for the best-performing instantiations of each architecture for Flickering Pong with $p=0.5$. } \label{fig:comb_flicker_rewards}\end{figure}Perhaps not unexpected,Figure \ref{fig:comb_flicker_rewards}demonstrates how poorly the Late Fusion networkperforms on the Flickering Pong game.The idea behind the architectureis that differences between two frames can be learned.In this experiment however,there is only a $25\%$ chancethat both input frames are unobscured.With no internal memory to guide the network,it cannot be expected to learn meaningful representationsover input that mostly contains blacked out frames.\paragraph{}The surprising result is that the 3D convolutional network given 10 framesdid spectactulary better than any other approach in this comparison.From the learning curve it can not be excluded that it iseven still learning while the other approachesseem to have stagnated.The fact that the network requires more than 4 frames as inputto exhibit this behavior is maybe not all that surprising,given that there is still a $6.25\%$ chancethat the input consists entirely of obscured frames.\paragraph{}It looks like the 3D convolutional networkgiven sufficient frames is the only architecturethat keeps learning steadily from its inputwhile others have stagnated.We expect this is due to the wayfeatures over multiple time frames are learnedand time information is preserved throughout the network.Given 10 input frames,the 3D convolutional network considered herestill contains a time dimension of 8 as input to the fully-connected layeras each convolutional layer merges every two adjacent frames,decreasing the time dimension by 1.