Example #1
0
    def __init__(self):
        self._alpha = self.ALPHA  # Learning rate
        self._gamma = self.GAMMA  # Future reward discount

        self._state_interpreter = StateInterpreter()
        self._device = 'cuda' if torch.cuda.is_available() else 'cpu'
        self._policy_net = self._create_neural_network()
        self._loss = nn.MSELoss()
        self._optim = optim.Adam(self._policy_net.parameters(), self._alpha)

        if self.LOAD_PATH is not None:
            self.load(self.LOAD_PATH)

        self._save_dir_path = Utils.get_base_dir().joinpath(self.SAVE_DIR)
Example #2
0
 def _create_default_log(self) -> None:
     log_dir_name = 'log'
     project_path = Utils.get_base_dir()
     log_dir_path = project_path.joinpath(log_dir_name)
     Utils.create_directory(log_dir_path)
     self._create_unique_log_file(log_dir_path)
Example #3
0
 def _generate_log_dir_path(self) -> str:
     comment = self._generate_comment()
     return str(Utils.get_base_dir().joinpath('runs').joinpath(
         f'{Utils.get_now_as_str()}: {comment}'))