|
|
|
|
|
|
|
|
|
|
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 |