• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is the code for "How Does DeepMind's AlphaGo Zero Work?" Siraj Raval on Youtube

MuGo: A minimalist Go engine modeled after AlphaGo

This is a pure Python implementation of a neural-network based Go AI, using TensorFlow.

Currently, the AI consists solely of a policy network, trained using supervised learning. I have implemented Monte Carlo Tree Search, but the simulations are too slow, due to being written in Python. I am hoping to bypass this issue entirely by replacing the simulations with a value network which will take one NN evaluation. (After all, random simulations are but a crude approximation to a value function, so if you have a good enough value function, you won't need a playout...)

The goal of this project is to see how strong a Go AI based purely on neural networks can be. In other words, a UCT-based tree search with moves seeded by a policy network, and a value network to evaluate the choices. An explicit non-goal is diving into the fiddly bits of optimizing Monte Carlo simulations.

Getting Started

Install Tensorflow

Start by installing Tensorflow. This should be as simple as

pip install -r requirements.txt

Optionally, you can install TensorFlow with GPU support, if you intend on training a network yourself.

Play against MuGo

If you just want to get MuGo working, you can download a pretrained network from Releases. You will have to be sure to match the code version with the version specified in the release, or else the neural network configuration may not line up correctly, and you'll get errors like "tensorflow.python.framework.errors_impl.NotFoundError: Key not found in checkpoint". So if the release is v0.1, then run git checkout v0.1.

MuGo uses the GTP protocol, and you can use any gtp-compliant program with it. To invoke the raw policy network, use

python main.py gtp policy --read-file=saved_models/20170718

(An MCTS version of MuGo has been implemented, using the policy network to simulate games, but it's not that much better than just the raw policy network, because Python is slow at simulating full games.)

One way to play via GTP is to use gogui-display (which implements a UI that speaks GTP.) You can download the gogui set of tools at http://gogui.sourceforge.net/. See also documentation on interesting ways to use GTP.

gogui-twogtp -black 'python main.py gtp policy --read-file=saved_models/20170718' -white 'gogui-display' -size 19 -komi 7.5 -verbose -auto

Another way to play via GTP is to play against GnuGo, while spectating the games

BLACK="gnugo --mode gtp"
WHITE="python main.py gtp policy --read-file=saved_models/20170718"
TWOGTP="gogui-twogtp -black \"$BLACK\" -white \"$WHITE\" -games 10 \
  -size 19 -alternate -sgffile gnugo"
gogui -size 19 -program "$TWOGTP" -computer-both -auto

Another way to play via GTP is to connect to CGOS, the Computer Go Online Server. The CGOS server hosted by boardspace.net is actually abandoned; you'll want to connect to the CGOS server at yss-aya.com.

After configuring your cgos.config file, you can connect to CGOS with cgosGtp -c cgos.config and spectate your own game with cgosView yss-aya.com 6819

Training MuGo

Get SGFs for supervised learning

You can find 15 years of KGS high-dan games at u-go.net. A database of Tygem 9d games is also out there, and finally, a database of professional games can be purchased from a variety of sources.

Preprocess SGFs

To use the game data for training, the game positions must first be processed into feature planes describing location of stones, liberty counts, and so on, as well as noting the correct location of the next move.

python main.py preprocess data/kgs-*

This will generate a series of data chunks and will take a while. It must be repeated if you change the feature extraction steps in features.py (This example takes advantage of bash wildcard expansion - say, if the KGS directories are named data/kgs-2006-01, data/kgs-2006-02, and so on.)

Supervised learning (policy network)

With the preprocessed SGF data (default output directory is ./processed_data/), you can train the policy network.

python main.py train processed_data/ --save-file=/tmp/savedmodel --epochs=1 --logdir=logs/my_training_run

As the network is trained, the current model will be saved at --save-file. If you reexecute the same command, the network will pick up training where it left off.

Additionally, you can follow along with the training progress with TensorBoard - if you give each run a different name (logs/my_training_run, logs/my_training_run2), you can overlay the runs on top of each other.

tensorboard --logdir=logs/

Running unit tests

python -m unittest discover tests

Credits

The credits for this code go to brilee. I've merely created a wrapper to get people started.

More Repositories

1

Learn_Machine_Learning_in_3_Months

This is the code for "Learn Machine Learning in 3 Months" by Siraj Raval on Youtube
7,557
star
2

learn_math_fast

This is the Curriculum for "How to Learn Mathematics Fast" By Siraj Raval on Youtube
Python
3,183
star
3

Learn_Data_Science_in_3_Months

This is the Curriculum for "Learn Data Science in 3 Months" By Siraj Raval on Youtube
2,701
star
4

Learn_Deep_Learning_in_6_Weeks

This is the Curriculum for "Learn Deep Learning in 6 Weeks" by Siraj Raval on Youtube
2,680
star
5

Learn_Computer_Science_in_5_Months

This is the Curriculum for "Learn Computer Science in 5 Months" By Siraj Raval on Youtube
1,856
star
6

Learn_Blockchain_in_2_months

This is the code for "Learn Blockchain in 2 Months" by Siraj Raval on Youtube
1,725
star
7

YOLO_Object_Detection

This is the code for "YOLO Object Detection" by Siraj Raval on Youtube
Python
1,687
star
8

tensorflow_chatbot

Tensorflow chatbot demo by @Sirajology on Youtube
Python
1,422
star
9

Learn_Computer_Vision

This is the curriculum for "Learn Computer Vision" by Siraj Raval on Youtube
1,078
star
10

Learn-Natural-Language-Processing-Curriculum

This is the curriculum for "Learn Natural Language Processing" by Siraj Raval on Youtube
1,054
star
11

Machine_Learning_Journey

This is the Curriculum for "Machine Learning Journey" By Siraj Raval on Youtube
973
star
12

deepfakes

This is the code for "DeepFakes" by Siraj Raval on Youtube
Python
946
star
13

100_Days_of_ML_Code

These are the instructions for "100 Days of ML Code" By Siraj Raval on Youtube
865
star
14

How-to-Predict-Stock-Prices-Easily-Demo

How to Predict Stock Prices Easily - Intro to Deep Learning #7 by Siraj Raval on Youtube
Jupyter Notebook
764
star
15

Programming_Interview_Study_Plan

This is the Programming Interview Study Plan by Siraj Raval on Youtube
689
star
16

Reinforcement_Learning_for_Stock_Prediction

This is the code for "Reinforcement Learning for Stock Prediction" By Siraj Raval on Youtube
Python
610
star
17

ChatGPT_Trading_Bot

This is the code for the "ChatGPT Trading Bot" Video by Siraj Raval on Youtube
Jupyter Notebook
587
star
18

capsule_networks

This is the code for "Capsule Networks: An Improvement to Convolutional Networks" by Siraj Raval on Youtube
Python
569
star
19

tensorflow_image_classifier

TensorFlow Image Classifier Demo by @Sirajology on Youtube
Python
530
star
20

Make_Money_with_Tensorflow_2.0

This is the code for "Make Money with Tensorflow 2.0" by Siraj Raval
Jupyter Notebook
527
star
21

LearnML

This is the Study Guide for Learn Machine Learning in 3 Months (PyTorch Curriculum) by Siraj Raval on Youtube
520
star
22

Mathematics_for_Beginners

This is the formula sheet for "Mathematics for Beginners" by Siraj Raval on Youtube
484
star
23

How_to_make_a_text_summarizer

This is the code for "How to Make a Text Summarizer - Intro to Deep Learning #10" by Siraj Raval on Youtube
Jupyter Notebook
481
star
24

Pokemon_GAN

This is the code for "Generating Pokemon with a Generative Adversarial Network" by Siraj Raval on Youtube
Python
432
star
25

Watch-Me-Build-a-Trading-Bot

This is the code for "Watch Me Build a Trading Bot" by Siraj Raval on Youtube
JavaScript
419
star
26

Learn_Physics_in_2_Months

This is the curriculum for "Learn Physics in 2 Months" by Siraj Raval on Youtube
414
star
27

How_to_simulate_a_self_driving_car

This is the code for "How to Simulate a Self-Driving Car" by Siraj Raval on Youtube
Python
413
star
28

Your_First_Decentralized_Application

This is the code for "A Guide to Building Your First Decentralized Application" by Siraj Raval on Youtube
Jupyter Notebook
413
star
29

AI_in_Finance

This is the code for "AI in Finance" By Siraj Raval on Youtube
JavaScript
410
star
30

The_Math_of_Intelligence

This is the Syllabus for Siraj Raval's new course "The Math of Intelligence"
394
star
31

tensorflow_speech_recognition_demo

This is the code for 'How to Make a Simple Tensorflow Speech Recognizer' by @Sirajology on Youtube
Python
383
star
32

Convolutional_neural_network

This is the code for "Convolutional Neural Networks - The Math of Intelligence (Week 4)" By Siraj Raval on Youtube
Jupyter Notebook
368
star
33

AI_Startup_Prototype

This is the code for "Watch Me Build an AI Startup" By Siraj Raval on Youtube
Python
364
star
34

Neural_Network_Voices

This is the code for "Neural Network Voices" by Siraj Raval on Youtube
Python
358
star
35

A_Guide_to_Running_Tensorflow_Models_on_Android

This is the code for"A Guide to Running Tensorflow Models on Android" By SIraj Raval on Youtube
Java
344
star
36

pose_estimation

This is the code for "Webcam Tracking with Tensorflow.js" By Siraj Raval on Youtube
TypeScript
318
star
37

Everybody_Dance_Now

This is the code for "Everybody Dance Now!" By Siraj Raval on Youtube
Python
313
star
38

Q-Learning-for-Trading

Python
311
star
39

ethereum_future

This is the Code for "Ethereum Future Prices" by Siraj Raval on Youtube
Jupyter Notebook
299
star
40

AI_Composer

AI Composer for Machine Learning for Hackers #2
Python
294
star
41

How-to-Use-GitHub

This is the supplementary material for "How to Use GitHub" By Siraj Raval on Youtube
294
star
42

how_to_deploy_a_keras_model_to_production

This is the code for the "How to Deploy a Keras Model to Production" by Siraj Raval on Youtube
Python
288
star
43

predicting_stock_prices

This is the coding challenge for "Predicting Stock Prices" by @Sirajology on Youtube
Python
282
star
44

How-to-Deploy-a-Tensorflow-Model-in-Production

This is the code for the "How to Deploy a Tensorflow Model in Production" by Siraj Raval on YouTube
Python
280
star
45

linear_regression_live

This is the code for the "How to Do Linear Regression the Right Way" live session by Siraj Raval on Youtube
Python
269
star
46

Chatbot-AI

Chatbot AI for Machine Learning for Hackers #6
Lua
261
star
47

Predicting_Winning_Teams

This is the code for "Predicting the Winning Team with Machine Learning" by Siraj Raval on Youtube
Jupyter Notebook
249
star
48

Music_Generator_Demo

Music Generator Demo by @Sirajology on Youtube
Python
246
star
49

Data_Science_Interview_Guide

These are the tips for "5 Steps to Pass Data Science Interviews" By Siraj Raval on Youtube
245
star
50

quantum_machine_learning

This is the code for "Quantum Machine Learning" By Siraj Raval on Youtube
HTML
245
star
51

AI_Freelancing

This is the code for "How to Do Freelance AI Programming" By Siraj Raval on Youtube
245
star
52

AI_Artist

AI Artist for Machine Learning for Hackers #5
Python
237
star
53

bitcoin_prediction

This is the code for "Bitcoin Prediction" by Siraj Raval on Youtube
Jupyter Notebook
234
star
54

tensorflow_demo

Tensorflow Demo for my TF in 5 Min Video on Youtube
Python
227
star
55

Neural_Differential_Equations

This is the code for "Neural DIfferential Equations" By Siraj Raval on Youtube
Jupyter Notebook
225
star
56

Stock_Market_Prediction

This is the code for "Stock Market Prediction" by Siraj Raval on Youtube
Jupyter Notebook
218
star
57

Build-an-AI-Startup-with-PyTorch

This is the code for 'Build an AI Startup with Pytorch" by Siraj Raval
Java
217
star
58

ChatGPT_Sports_Betting_Bot

This is the code for "I Built a Sports Betting Bot with ChatGPT" by Siraj Raval on Youtube
Jupyter Notebook
216
star
59

Move_37_Syllabus

This is the syllabus for "Move 37", Siraj Raval's new course at School of AI
215
star
60

Classifying_Data_Using_a_Support_Vector_Machine

This is the code for the "Classifying Data using Gradient Descent" by Siraj Raval on Youtube
Jupyter Notebook
212
star
61

A-Guide-to-DeepMinds-StarCraft-AI-Environment

This is the code for "A Guide to DeepMind's StarCraft AI Environment" by Siraj Raval on Youtube
Python
210
star
62

Landing-a-SpaceX-Falcon-Heavy-Rocket

This is the code for "Landing a SpaceX Falcon Heavy Rocket" By Siraj Raval on Youtube
Python
209
star
63

How_to_Build_a_healthcare_startup

This is the code for "How to Build a Healthcare Startup" by Siraj Raval on Youtube
Dart
203
star
64

AI_For_Music_Composition

This is the code for "AI for Music Composition" by Siraj Raval on Youtube
Python
202
star
65

How_to_make_a_chatbot

This is the code for "How to Make a Chatbot - Intro to Deep Learning #12' by Siraj Raval on YouTube
Python
199
star
66

LSTM_Networks

This is the code for "LSTM Networks - The Math of Intelligence (Week 8)" By Siraj Raval on Youtube
Jupyter Notebook
194
star
67

Make_a_neural_network

This is the code for the "Make a Neural Network" - Intro to Deep Learning #2 by Siraj Raval on Youtube
Python
193
star
68

AI_For_Business_Curriculum

This is the curriculum for the "AI for Business" Course By Siraj Raval on Youtube
189
star
69

Time_Series_Prediction

This is the code for "Time Series Prediction" By Siraj Raval on Youtube
Jupyter Notebook
187
star
70

3D_Pose_Estimation

This is the code for "Machine Vision" By Siraj Raval on Youtube
Python
185
star
71

Financial_Forecasting_with_TensorflowJS

This is the code for "Financial Forecasting with Tensorflow.js" By Siraj Raval on Youtube
JavaScript
184
star
72

linear_regression_demo

This is the code for "How to Make a Prediction - Intro to Deep Learning #1' by Siraj Raval on YouTube
Python
182
star
73

ethereum_demo

This is the code for "Ethereum Explained" by Siraj Raval on Youtube
Jupyter Notebook
178
star
74

chatbot_tutorial

This is the code for "Chatbot Tutorial" by Siraj Raval on Youtube
Python
176
star
75

Watch-Me-Build-a-Finance-Startup

This is the code for "Watch Me Build a Finance Startup" by Siraj Raval on Youtube
Java
172
star
76

word_vectors_game_of_thrones-LIVE

This is the code for the "How to Make Word Vectors from Game of Thrones (LIVE) " Siraj Raval on Youtube
Jupyter Notebook
170
star
77

AI_in_Medicine_Clinical_Imaging_Classification

This is the code for "AI in Medicine " By Siraj Raval on Youtube
Python
165
star
78

deep_q_learning

This is the Code for "Deep Q Learning - The Math of Intelligence #9" By Siraj Raval on Youtube
Jupyter Notebook
163
star
79

AI_Writer

AI Writer for Machine Learning for Hackers #8
Python
163
star
80

Bitcoin_Trading_Bot

This is the code for "Bitcoin Trading Bot" By Siraj Raval on Youtube
Jupyter Notebook
163
star
81

Unity_ML_Agents

This is the code for "Unity AI" by Siraj Raval on Youtube
Python
161
star
82

how_to_convert_text_to_images

This is the code for "How to Convert Text to Images - Intro to Deep Learning #16' by Siraj Raval on YouTube
Python
155
star
83

Game-AI

Game AI for Machine Learning for Hackers #3
Python
154
star
84

Intro_to_the_Math_of_intelligence

This is the code for "Intro - The Math of Intelligence" by Siraj Raval on Youtube
Python
152
star
85

Sentiment_Analysis

This is the code for "Sentiment Analysis - Data Lit #1" by Siraj Raval on Youtube
Jupyter Notebook
151
star
86

recommender_live

Jupyter Notebook
149
star
87

recurrent_neural_network

This is the code for "Recurrent Neural Networks - The Math of Intelligence (Week 5)" By Siraj Raval on Youtube
Jupyter Notebook
147
star
88

How-to-Learn-from-Little-Data

This is the code for "How to Learn from Little Data - Intro to Deep Learning #17' by Siraj Raval on YouTube
Python
144
star
89

How_to_generate_music_in_tensorflow_LIVE

Python
140
star
90

Kaggle_Earthquake_challenge

This is the code for the Kaggle Earthquake Challenge by Siraj Raval on Youtube
Jupyter Notebook
139
star
91

OpenAI_Five_vs_Dota2_Explained

This is the code for "OpenAI Five vs DOTA 2 Explained" By Siraj Raval on Youtube
Python
138
star
92

Learn_Synthetic_Biology

137
star
93

How-to-Build-a-Biomedical-Startup

This is the code for "How to Build a Biomedical Startup" by Siraj Raval on Youtube
Dart
134
star
94

Gaussian_Mixture_Models

This is the code for "Gaussian Mixture Models - The Math of Intelligence (Week 7)" By Siraj Raval on Youtube
Jupyter Notebook
134
star
95

Make_Money_with_Tensorflow

This is the code for "Make Money with Tensorflow" by Siraj Raval on Youtube
Python
129
star
96

Machine-Learning-API-Tutorial

This is the code for "Machine Learning API tutorial" By Siraj Raval on Youtube
Python
128
star
97

AI_Supply_Chain

This is the code for "AI for Supply Chain" by Siraj Raval on Youtube
Jupyter Notebook
128
star
98

how_to_build_a_bitcoin_startup

This is the code for "How to Build a Bitcoin Startup" by Siraj Raval on Youtube
JavaScript
126
star
99

machine_learning_and_neuroscience

This is the code for "Machine Learning & Neuroscience" By Siraj Raval on Youtube
JavaScript
123
star
100

k_means_clustering

This is the code for "K-Means Clustering - The Math of Intelligence (Week 3)" By SIraj Raval on Youtube
Jupyter Notebook
122
star