From d2e6c517ea57d3433f5dfbe4ed080dc2b167086f Mon Sep 17 00:00:00 2001 From: sproblvem Date: Mon, 6 Nov 2017 20:35:53 +0800 Subject: [PATCH 1/3] Update README.md add potential bugs of leela. --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 4d69fec..78ce717 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,27 @@ MCTS ## agent (optional) DQNAgent etc. + +Pontential Bugs: +0. Wrong calculation of eval value +UCTNode.cpp +106 if (to_move == FastBoard::WHITE) { +107 net_eval = 1.0f - net_eval; +108 } + +309 if (tomove == FastBoard::WHITE) { +310 score = 1.0f - score; +311 } + +1. create children only on leaf node +UCTSearch.cpp + 60 if (!node->has_children() && m_nodes < MAX_TREE_SIZE) { + 61 float eval; + 62 auto success = node->create_children(m_nodes, currstate, eval); + 63 if (success) { + 64 result = SearchResult(eval); + 65 } + 66 } + + + From 2bb02294df6b76ea902090e0726c2c1dfa734213 Mon Sep 17 00:00:00 2001 From: sproblvem Date: Mon, 6 Nov 2017 20:39:09 +0800 Subject: [PATCH 2/3] Update README.md format modify --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 78ce717..3bf198f 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,12 @@ MCTS DQNAgent etc. -Pontential Bugs: +## Pontential Bugs: + 0. Wrong calculation of eval value + UCTNode.cpp +``` 106 if (to_move == FastBoard::WHITE) { 107 net_eval = 1.0f - net_eval; 108 } @@ -39,9 +42,12 @@ UCTNode.cpp 309 if (tomove == FastBoard::WHITE) { 310 score = 1.0f - score; 311 } +``` 1. create children only on leaf node + UCTSearch.cpp +``` 60 if (!node->has_children() && m_nodes < MAX_TREE_SIZE) { 61 float eval; 62 auto success = node->create_children(m_nodes, currstate, eval); @@ -49,6 +55,7 @@ UCTSearch.cpp 64 result = SearchResult(eval); 65 } 66 } +``` From 2fc87f70202fac449c21a7d8ed626be8d0192a68 Mon Sep 17 00:00:00 2001 From: Dong Yan Date: Mon, 6 Nov 2017 23:13:11 +0800 Subject: [PATCH 3/3] add test interface for Network --- .gitignore | 2 +- AlphaGo/Network.py | 38 +++++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 28665b5..8caffae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .idea leela-zero -.pyc +*.pyc parameters diff --git a/AlphaGo/Network.py b/AlphaGo/Network.py index ef77e21..72852d6 100644 --- a/AlphaGo/Network.py +++ b/AlphaGo/Network.py @@ -3,6 +3,7 @@ import numpy as np import time import multi_gpu import tensorflow.contrib.layers as layers +import sys def residual_block(input, is_training): normalizer_params = {'is_training': is_training, @@ -96,15 +97,30 @@ def train(): def forward(board): result_path = "./results/" - with multi_gpu.create_session() as sess: - sess.run(tf.global_variables_initializer()) - ckpt_file = tf.train.latest_checkpoint(result_path) - if ckpt_file is not None: - print('Restoring model from {}...'.format(ckpt_file)) - saver.restore(sess, ckpt_file) - else: - raise ValueError("No model loaded") - return sess.run([p,v], feed_dict={x:board}) + itflag = False + res = None + if board is None: + board = np.load("/home/yama/tongzheng/AG/self_play_204/d7d7d552b7be4b51883de99d74a8e51b.npz") + board = board["boards"][100].reshape(-1, 19, 19, 17) + result_path = "../parameters/checkpoints" + itflag = True + with multi_gpu.create_session() as sess: + sess.run(tf.global_variables_initializer()) + ckpt_file = tf.train.latest_checkpoint(result_path) + if ckpt_file is not None: + print('Restoring model from {}...'.format(ckpt_file)) + saver.restore(sess, ckpt_file) + else: + raise ValueError("No model loaded") + res = sess.run([tf.nn.softmax(p),v], feed_dict={x:board, is_training:itflag}) + #res = sess.run([tf.nn.softmax(p),v], feed_dict={x:fix_board["boards"][300].reshape(-1, 19, 19, 17), is_training:False}) + #res = sess.run([tf.nn.softmax(p),v], feed_dict={x:fix_board["boards"][50].reshape(-1, 19, 19, 17), is_training:True}) + print(res) + #print(res[0].tolist()[0]) + #print(np.argmax(res[0])) + return res -if __name__='main': - train() +if __name__=='__main__': + #train() + if sys.argv[1] == "test": + forward(None)