未验证 提交 3ff55408 编写于 作者: G goshawk22 提交者: GitHub

Seed AlphaZero Threads (#402)

* Fix seed in Actor.py

* Fix seed coach.py

* Update Coach.py

* Change i to seed in actor.py

* Change i to seed in Coach.py
上级 b14e688a
......@@ -54,9 +54,9 @@ class Coach():
self.test_dataset = get_test_dataset()
def _run_remote_tasks(self, signal_queue):
def _run_remote_tasks(self, signal_queue, seed):
# The remote actor will actually run on the local machine or other machines of xparl cluster
remote_actor = Actor(self.game, self.args)
remote_actor = Actor(self.game, self.args, seed)
while True:
# receive running task signal
......@@ -91,12 +91,12 @@ class Coach():
# connect to xparl cluster to submit jobs
parl.connect(self.args.master_address)
for i in range(self.args.actors_num):
for seed in range(self.args.actors_num):
signal_queue = queue.Queue()
self.remote_actors_signal_queues.append(signal_queue)
remote_thread = threading.Thread(
target=self._run_remote_tasks, args=(signal_queue, ))
target=self._run_remote_tasks, args=(signal_queue, seed))
remote_thread.setDaemon(True)
remote_thread.start()
......
......@@ -23,7 +23,8 @@ from utils import win_loss_draw
@parl.remote_class
class Actor(object):
def __init__(self, game, args):
def __init__(self, game, args, seed):
np.random.seed(seed)
os.environ['OMP_NUM_THREADS'] = "1"
self.game = game
self.args = args
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册