While computers are amazing devices for computation there are many problems that aren’t tractable to solutions using strict logic. Some problems are too big, hard, or ambiguous to write explicit instructions for. In this talk I will go over one particular use case of machine learning where many examples of a task being done well could be used to train a neural network to also perform that task well. In this talk I will demo a trained neural network that plays a game from the Google 2011 AI challenge as well as hand written bots.
2. • Senior Software Engineer working on every stack since 2009
• Spent my career working as a full stack developer and have been involved in all aspects
of delivering high quality software
• Started with Daugherty in February of 2015
– Since then I have been working for many different brand name clients in the Saint Louis area
developing and delivering pragmatic solutions for their business needs
• Clients
– AEP River Operations
– Anheuser Busch
– New Balance
– Bryan Cave
– Express Scripts
– Bayer
2
Instructor Biography
3. Confidential and Proprietary to Daugherty
Business Solutions
3
• Terminology
– Machine Learning
– Convolutional Neural Networks
• Frameworks
– TensorFlow
– Keras
• Problem Statement
• Solution
– Architecture
– Data/Encoding
– Training Technique
• Demo
– Model Configuration
– Game Replay
• Questions?
Presentation Outline
4. • Machine Learning
– The study of computer algorithms that improve automatically through experience
• Convolutional Neural Networks
– A class of deep neural networks most commonly applied to analyzing visual imagery
4
Terminology
5. • TensorFlow
– Symbolic math library frequently used for machine learning applications such as neural
networks
– Developed by Google and released as open source in 2015
• Keras
– Open source neural-network library designed to enable fast experimentation with deep neural
networks
5
Frameworks
7. 7
Solution – Data Generation
Java Virtual Machine (JVM)
Bots
Python Interpreter
Engine
Game state Orders
Inter-Process
Communication
done via TCP
using Py4J
Play Results
File System
8. 8
Solution – Training
Python Interpreter
Training File System
Keras
Tensorflow
Encode
Play
Results
Train
Model
Load Play Results
Create
Model
Save Model
9. 9
Solution – Play
Java Virtual Machine (JVM)
Bots
Python Interpreter
Engine
Game state Orders
Inter-Process
Communication
done via TCP
using Py4J
Neural Network
Orders
Game state
10. • Game State
– The replay data from the data generation phase are loaded from the file system
– These are converted into turn slices that have a representation of every ant at every turn and the
movement decision that was made for that ant
– All ant move decisions up to the point where the bot got the most points are included in the
training set
– The examples for training then become a classification problem where the view of the ant at a
specific turn should be labeled with the direction that the ant was moved to
• Encoding
– Dense, 1d convolutional neural networks, and 2d convolutional neural networks were tested for
this problem
• 2d Convolutional networks seemed to have the best performance
– input shape of n (examples) x 12 (rows) x 12 (columns) x 7 channels (game_state)
– Output shape of n (examples) x 5 (direction)
– ~68% test accuracy with ~700k examples
– The view of the ant and the movement decision are all categorical data so one hot encoding is
used to convert enumeration values into binary arrays
10
Game State Representation and Data Encoding
11. • Categorical cross entropy used for loss function and categorical accuracy used for the
testing metric.
• Tested variations of models with different values
– Learning_rate
– Strides
– Channel count
• Tensorboard
– Pretty useful tool that can provide visualizations of the model training run loss and accuracy
– The visualations of model weights is very cool looking but I’m still not sure how to use that
• Custom graphs that would plot the learning rate as a function of batch size to evaluate
whether the model had a high bias or a high variance problem
11
Training Technique
Link to github page for model
https://github.com/Jason-Turan0/ants/blob/43e4eb32eef4113917930270653143a2cfa67b73/ants_ai/training/neural_network/model_factory.py#L76
Demo game played by neural network