Skip to main content

Matthew - Blog Post 8

replaymanager.py is only 339 lines long but it feels at least three times that when I'm working on it. The module is definitely due for a refactor. For one, the term subdataset should be renamed to version_set and extracted into a class. version_set more accurately and describes what it is, and the class extraction would clean up the namespace in ReplayManager. There is probably some kind of class extraction possible for replays, so that their names, paths, file streams, and Twitter profiles can all be neatly encapsulated, thereby cleaning up the namespace even more. However, I do not want to worry about having two kinds of replays: the one used by ReplayManager and the one used by ReplayParser. Even though ReplayManager does not use ReplayParser, the prospect of making things more muddier deters me.

There's probably a right way to refactor this code, but, to put it simply, now is not the time. Speaking of time, I came up with a great way to get work done, even when I am sleeping!

One cannot sleep and work
I need sleep
Computer does not need sleep
∴ Computer does all the work while I sleep?

It's been a while since I had to deal with logical arguments, so that may not be entirely sound. Or valid? Anyway, I set the collector agent loose on Rivals of Aether version 1.0.2. Over the course of about a day and a half, where most of that time was during the night, the agent amassed 41.6 GB of frame buffer data. That's at 1/4 scale, too! At full scale that works out to be around 166.4 GB!! That's like two copies of Nioh!!!

That 41.6 GB of 1/4 scale frame buffer data represents 331 replays. We need to know if all of that data is actually usable; otherwise, we'll waste a lot of time training a model on improperly indexed or incomplete data. To address this, I wrote methods in ReplayManager designed to produce a variety of sets. The first variety is the random sample set; it uses NumPy's random choice function to randomly select a given number of replays. These replays are copied into a separate location for later review. The second variety is the one we'll need later; it takes the entire dataset and uses the same random choice function to randomly distribute the dataset into a training and a testing subset, according to a preconfigured distribution. The current distribution is 80% training and 20% testing. This function works, but I haven't run it with the actual copying enabled because it will, literally and by definition, double the storage requirements of the dataset. These methods copy rather than move because the data has reached a stage of processing at which it is expensive to reproduce. I will need to establish more backups before I risk moving data destructively.


Our next step is to review the random samples. Once those are validated (manually, using the demo code), we can finish collecting for version 1.0.2. Then we'll sort the dataset into training and testing sets, finish the replay loader, and start running our LSTM. Then sleep while the LSTM does its thing.


Comments

Popular posts from this blog

Matthew - Capstone Blog Post 4

Finally, our CSI-480 (Advanced Topics: AI) course material is catching up to where we need to be. We are covering perceptrons and sigmoid neurons in the lectures, and we are also using TensorFlow to solve some very simple introductory problems (via tutorials). To supplement this I have been reading Neural Networks and Deep Learning by Michael Nielsen, a textbook available for free on the internet, which dives into neural networks right from the first chapter. Additionally, I have been finding 3Blue1Brown's multi-part video series about deep learning to be extremely helpful for visualizing some of the more advanced concepts. Even if I do not fully understand the calculus and linear algebra involved, at the very least I have a better idea of what goes on inside of neural networks. For example: I know what loss and gradient descentalgorithmsdo, essentially, and I also understand how the latter helps find a local minimum for the former, but I do not necessarily feel confident in my …

Matthew - Blog Post 9

After our last meeting, Professor Auerbach asked us to shift our focus towards building and training our model. So that's what we've been working on lately. The results so far have been interesting and problematic.

The first step was to define a minimal working model and a loading system to feed it our labelled data-set. I wrote a Sequence subclass, which is essentially a kind of generator designed for use with the fit_generator method. With fit_generator and a sequence, we're able to train and test the model with just a couple of one-liners:

model.fit_generator(sequence)
model.evaluate_generator(sequence)

The sequence subclass also has a few other tricks up its proverbial sleeve. For one, it reduces the dimensionality of the frame buffer data from 135×240×3 to 135×240×1 by converting it to gray-scale. This reduces the number of features from 97,200 to 32,400. For two, it does the same with the labels, combining and dropping 26 action types into just 9 atomic classes. This a…

Matthew - Blog Post 7

Since January, we've been working hard to not only finish writing the Replay Parser and Frame Collector but also totally synchronize them. I'm pleased to report our success. This is an amazing milestone for us because it means that we've surmounted one of our most troubling obstacles.


I have also made sure to keep our documentation up to date. So, if you like, you can follow along with this blog post by replicating its results.
The Frame Collector uses timed input sequences to start each replay associated with the currently running game version. Then, after waiting a set amount of time for playback to begin, it starts grabbing 1/4-scale frames at a rate of 10 frames per second. The Frame Collector takes these down-scaled frames, which are NumPy arrays, and rapidly pickles and dumps them into the file system. Here's a screenshot of the Frame Collector in action:

If you look at the image above, you'll see that each pickle (the .np files) is simply assigned …