Skip to content

Commit

Permalink
Merge pull request pytorch#45 from pytorch/analysis
Browse files Browse the repository at this point in the history
add instructions for analysis mode
  • Loading branch information
jma127 authored May 12, 2018
2 parents 9621c27 + 3914880 commit a4edc96
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,18 @@ Here is a basic set of commands to run and play the bot via the GTP protocol:
We've found that the above settings work well for playing the bot. You may change ``mcts_rollout_per_thread`` to tune the thinking time per move.

After the environment is set up and the model is loaded, you can start to type gtp commands to get the response from the engine.

Analysis mode
-------------

Here is the command to analyze an existing sgf file:

1) Build ELF and run ``source scripts/devmode_set_pythonpath.sh`` as described above.

2) Train a model, or grab a pretrained model from the repository's Github "Releases" tab.

3) Change directory to ``scripts/elfgames/go/``

4) Run ``./analysis.sh /path/to/model --preload_sgf /path/to/sgf --preload_sgf_move_to [move_number] --dump_record_prefix [tree] --verbose --gpu 0 --mcts_puct 1.50 --batchsize 16 --mcts_rollout_per_batch 16 --mcts_threads 2 --mcts_rollout_per_thread 8192 --resign_thres 0.0 --mcts_virtual_loss 1 --num_games 1``

The settings for rollouts are similar as above. The process should run automatically after loading the environment, models and previous moves. You should see the move suggested by the AI after each move, along with its value and prior. This process will also generate a lot of tree files, prefixed with ``tree`` (you can change it with ``--dump_record_prefix`` option above.) The tree files will contain the full search at each move along with its prior and value. To abort the process simply kill it as the current implementation will run it to the end of the game.
22 changes: 22 additions & 0 deletions scripts/elfgames/go/analysis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

MODEL=$1
shift

game=elfgames.go.game model=df_pred model_file=elfgames.go.df_model3 python3 selfplay.py --mode selfplay --keys_in_reply V rv \
--use_mcts --use_mcts_ai2 --mcts_verbose_time --mcts_use_prior --mcts_persistent_tree --load0 $MODEL --load1 $MODEL \
--selfplay_timeout_usec 10 \
--server_addr localhost --port 1234 \
--replace_prefix0 resnet.module,resnet \
--replace_prefix1 resnet.module,resnet \
--eval_model_pair loaded \
--dim0 224 --dim1 224 --num_block0 20 --num_block1 20 \
--no_check_loaded_options0 --no_check_loaded_options1 \
--dump_record_prefix tree --num_games 1 \
"$@"

0 comments on commit a4edc96

Please sign in to comment.