Exemplo n.º 1
0
 def _build_buffer(self):
     if self.use_priority:
         from rls.memories.per_buffer import PrioritizedDataBuffer
         buffer = PrioritizedDataBuffer(n_copies=self.n_copies,
                                        batch_size=self.batch_size,
                                        buffer_size=self.buffer_size,
                                        chunk_length=self._chunk_length,
                                        max_train_step=self._max_train_step,
                                        **load_config(f'rls/configs/buffer/off_policy_buffer.yaml')[
                                            'PrioritizedDataBuffer'])
     else:
         from rls.memories.er_buffer import DataBuffer
         buffer = DataBuffer(n_copies=self.n_copies,
                             batch_size=self.batch_size,
                             buffer_size=self.buffer_size,
                             chunk_length=self._chunk_length)
     return buffer
Exemplo n.º 2
0
def UpdateConfig(config: Dict, file_path: str, key_name: str = 'algo') -> Dict:
    '''
    update configurations from a readable file.
    params:
        config: current configurations
        file_path: path of configuration file that needs to be loaded
        key_name: a specified key in configuration file that needs to update current configurations
    return:
        config: updated configurations
    '''
    _config = load_config(file_path)
    key_values = _config[key_name]
    try:
        for key in key_values:
            config[key] = key_values[key]
    except Exception as e:
        logger.info(e)
        sys.exit()
    return config
Exemplo n.º 3
0
    def __init__(self,
                 worker_id=0,
                 file_name=None,
                 port=5005,
                 render=False,
                 seed=42,
                 timeout_wait=60,
                 env_copies=12,
                 env_name='3DBall',
                 real_done=True,
                 initialize_config={},
                 engine_config={
                     'width': 84,
                     'height': 84,
                     'quality_level': 5,
                     'time_scale': 20,
                     'target_frame_rate': -1,
                     'capture_frame_rate': 60
                 },
                 **kwargs):
        self._n_copies = env_copies
        self._real_done = real_done

        self._side_channels = self.initialize_all_side_channels(
            initialize_config, engine_config)
        env_kwargs = dict(seed=seed,
                          worker_id=worker_id,
                          timeout_wait=timeout_wait,
                          side_channels=list(
                              self._side_channels.values()))  # 注册所有初始化后的通讯频道
        if file_name is not None:
            env_dict = load_config('rls/configs/unity/env_dict.yaml')
            env_kwargs.update(file_name=file_name,
                              base_port=port,
                              no_graphics=not render,
                              additional_args=[
                                  '--scene',
                                  str(env_dict.get(env_name, 'None'))
                              ])
        self.env = UnityEnvironment(**env_kwargs)
        self.env.reset()
        self.initialize_environment()