The code is based on KataGo project https://github.com/lightvector/KataGo. We incorporate the Bayesian neural network model with mixture of normal prior into the original code, which allow us to prune network.
Example instructions to start up these things (assuming you have appropriate machines set up), with some base directory $BASEDIR to hold the all the models and training data generated with a few hundred GB of disk space. The below commands assume you're running from the root of the repo and that you can run bash scripts. In addition, we need a 'selfplay' folder in $BASEDIR which contains all selfplay result and a 'models' folder to put the saved model.
cd python_sparse; ./selfplay/shuffle_and_export_loop.sh $BASEDIR/ $SCRATCH_DIRECTORY $NUM_THREADS $USE_GATING
- This starts both the shuffler and exporter. The shuffler will use the scratch directory with the specified number of threads to shuffle in parallel. Make sure you have some disk space. You probably want as many threads as you have cores. If not using the gatekeeper, specify
0
for$USE_GATING
, else specify1
. - Also, if you're low on disk space, take a look also at the
./selfplay/shuffle.sh
script (which is called byshuffle_and_export_loop.sh
). Right now it's very conservative about cleaning up old shuffles but you could tweak it to be a bit more aggressive.
- This starts both the shuffler and exporter. The shuffler will use the scratch directory with the specified number of threads to shuffle in parallel. Make sure you have some disk space. You probably want as many threads as you have cores. If not using the gatekeeper, specify
cd python_sparse; ./selfplay/train.sh $BASEDIR/ $TRAININGNAME b20c256 0 >> log.txt 2>&1 & disown
- This starts the training. b20c256 specify the model and 0 specify the 'do_prune' parameter. You may want to look at or edit the train.sh script, it also snapshots the state of the repo for logging, as well as contains some training parameters that can be tweaked. Especially when use different board size, you need to change -pos-len parameter in train.sh
- Compared to original KataGo, we add one parameter for train.sh. The fourth parameter give the 'do_prune' value for train.py, which specify whether we do pruning or not. If 0 is specified, then we only train the model with a mixture of normal prior, which will typically result in a lot of parameters with very small magnitude. If '1' is specified, then we do pruning at beginning of training and fix the pruned parameter to be 0.
- Typically we will set 'do_prune' to be 0(i.e. no pruning) and train the model for a while. Then stop the training process, restart training with same $BASEDIR and same $TRAININGNAME but set 'do_prune' to be 1. This will prune the current model first and then continue training.