浏览代码

Merge pull request #1419 from Unity-Technologies/develop-multi-delay

Wait between environment launches
/develop-generalizationTraining-TrainerController
GitHub 6 年前
当前提交
a60e1853
共有 1 个文件被更改,包括 14 次插入5 次删除
  1. 19
      ml-agents/mlagents/trainers/learn.py

19
ml-agents/mlagents/trainers/learn.py


import logging
import os
import multiprocessing
from multiprocessing import Process, Queue
import numpy as np
from docopt import docopt

def run_training(sub_id, run_seed, run_options):
def run_training(sub_id, run_seed, run_options, process_queue):
:param process_queue: Queue used to send signal back to main.
:param sub_id: Unique id for training session.
:param run_seed: Random seed used for training.
:param run_options: Command line arguments for training.

no_graphics = run_options['--no-graphics']
trainer_config_path = run_options['<trainer-config-path>']
# Create controller and begin training.
# Create controller and launch environment.
# Signal that environment has been launched.
process_queue.put(True)
# Begin training
tc.start_learning()

for i in range(num_runs):
if seed == -1:
run_seed = np.random.randint(0, 10000)
p = multiprocessing.Process(target=run_training, args=(i, run_seed, options))
process_queue = Queue()
p = Process(target=run_training, args=(i, run_seed, options, process_queue))
# Wait for signal that environment has successfully launched
while process_queue.get() is not True:
continue
正在加载...
取消
保存