|
|
|
|
|
|
from mlagents.trainers.trainer_util import TrainerFactory, handle_existing_directories |
|
|
|
from mlagents.trainers.stats import ( |
|
|
|
TensorboardWriter, |
|
|
|
CSVWriter, |
|
|
|
StatsReporter, |
|
|
|
GaugeWriter, |
|
|
|
ConsoleWriter, |
|
|
|
|
|
|
os.path.join(run_logs_dir, "training_status.json") |
|
|
|
) |
|
|
|
|
|
|
|
# Configure CSV, Tensorboard Writers and StatsReporter |
|
|
|
# We assume reward and episode length are needed in the CSV. |
|
|
|
csv_writer = CSVWriter( |
|
|
|
write_path, |
|
|
|
required_fields=[ |
|
|
|
"Environment/Cumulative Reward", |
|
|
|
"Environment/Episode Length", |
|
|
|
], |
|
|
|
) |
|
|
|
# Configure Tensorboard Writers and StatsReporter |
|
|
|
tb_writer = TensorboardWriter( |
|
|
|
write_path, clear_past_data=not checkpoint_settings.resume |
|
|
|
) |
|
|
|
|
|
|
StatsReporter.add_writer(csv_writer) |
|
|
|
StatsReporter.add_writer(gauge_write) |
|
|
|
StatsReporter.add_writer(console_writer) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_environment_factory( |
|
|
|
env_path: Optional[str], |
|
|
|
no_graphics: bool, |
|
|
|
seed: int, |
|
|
|
start_port: Optional[int], |
|
|
|
env_args: Optional[List[str]], |
|
|
|
log_folder: str, |
|
|
|
env_path: Optional[str], |
|
|
|
no_graphics: bool, |
|
|
|
seed: int, |
|
|
|
start_port: Optional[int], |
|
|
|
env_args: Optional[List[str]], |
|
|
|
log_folder: str, |
|
|
|
worker_id: int, side_channels: List[SideChannel] |
|
|
|
worker_id: int, side_channels: List[SideChannel] |
|
|
|
) -> UnityEnvironment: |
|
|
|
# Make sure that each environment gets a different seed |
|
|
|
env_seed = seed + worker_id |
|
|
|