Exemplo n.º 1
0
def log_creator(log_dir):
    result_dir = log_dir
    result_dir = Path(result_dir).expanduser().resolve().absolute()
    logdir_prefix = gen_experiment_name()

    def logger_creator(config):
        if not os.path.exists(result_dir):
            os.makedirs(result_dir)
        logdir = tempfile.mkdtemp(prefix=logdir_prefix, dir=result_dir)
        return UnifiedLogger(config, logdir, loggers=None)

    return logger_creator
Exemplo n.º 2
0
    def __init__(
            self,
            index,
            agents_itr=defaultdict(lambda: 0),
            eval_count=0,
            all_data=defaultdict(
                lambda: defaultdict(lambda: defaultdict(lambda: []))),
            experiment_name=None,
            etag=None,
            tb_writer=None,
            last_eval_iterations=defaultdict(lambda: None),
            log_dir=None,
    ):
        self.info = defaultdict(lambda: defaultdict(lambda: LogInfo()))
        self.all_data = all_data
        self.index = index
        self.eval_count = eval_count

        if experiment_name is None:
            self.experiment_name = gen_experiment_name()
            if etag:
                self.experiment_name = f"{self.experiment_name}-{etag}"
        else:
            self.experiment_name = experiment_name

        if log_dir is None:
            self.log_dir = "logs"
        else:
            self.log_dir = log_dir

        self.experiment_dir = f"{self.log_dir}/{self.experiment_name}"
        self.model_dir = f"{self.log_dir}/{self.experiment_name}/models"
        self.code_dir = f"{self.log_dir}/{self.experiment_name}/codes"
        self.pkls = f"{self.log_dir}/{self.experiment_name}/pkls"
        self.start_time = time.time()
        self.timestep_sec = 0.1
        self.steps = 1
        self.active_tag = None
        self.tb_writer = tb_writer
        self.last_eval_iterations = last_eval_iterations
        self.agents_itr = agents_itr