當前位置: 首頁>>代碼示例>>Python>>正文


Python vec_env.CloudpickleWrapper方法代碼示例

本文整理匯總了Python中baselines.common.vec_env.CloudpickleWrapper方法的典型用法代碼示例。如果您正苦於以下問題:Python vec_env.CloudpickleWrapper方法的具體用法?Python vec_env.CloudpickleWrapper怎麽用?Python vec_env.CloudpickleWrapper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在baselines.common.vec_env的用法示例。


在下文中一共展示了vec_env.CloudpickleWrapper方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from baselines.common import vec_env [as 別名]
# 或者: from baselines.common.vec_env import CloudpickleWrapper [as 別名]
def __init__(self, env_fns, spaces=None):
        """
        envs: list of gym environments to run in subprocesses
        """
        self.waiting = False
        self.closed = False
        nenvs = len(env_fns)
        self.remotes, self.work_remotes = zip(*[Pipe() for _ in range(nenvs)])
        self.ps = [Process(target=worker, args=(work_remote, remote, CloudpickleWrapper(env_fn)))
            for (work_remote, remote, env_fn) in zip(self.work_remotes, self.remotes, env_fns)]
        for p in self.ps:
            p.daemon = True # if the main process crashes, we should not cause things to hang
            p.start()
        for remote in self.work_remotes:
            remote.close()

        self.remotes[0].send(('get_spaces', None))
        observation_space, action_space = self.remotes[0].recv()
        VecEnv.__init__(self, len(env_fns), observation_space, action_space) 
開發者ID:Hwhitetooth,項目名稱:lirpg,代碼行數:21,代碼來源:subproc_vec_env.py

示例2: __init__

# 需要導入模塊: from baselines.common import vec_env [as 別名]
# 或者: from baselines.common.vec_env import CloudpickleWrapper [as 別名]
def __init__(self, env_fns, spaces=None):
        """
        envs: list of gym environments to run in subprocesses
        """
        self.waiting = False
        self.closed = False
        nenvs = len(env_fns)
        self.remotes, self.work_remotes = zip(*[Pipe() for _ in range(nenvs)])



        self.ps = [Process(target=worker, args=(work_remote, remote, CloudpickleWrapper(env_fn)))
            for (work_remote, remote, env_fn) in zip(self.work_remotes, self.remotes, env_fns)]
        for p in self.ps:
           p.daemon = True # if the main process crashes, we should not cause things to hang
           p.start()
        for remote in self.work_remotes:
            remote.close()

        self.remotes[0].send(('get_spaces', None))
        observation_space, action_space =  self.remotes[0].recv()
        VecEnv.__init__(self, len(env_fns), observation_space, action_space) 
開發者ID:vik-goel,項目名稱:MOREL,代碼行數:24,代碼來源:subproc_vec_env.py

示例3: __init__

# 需要導入模塊: from baselines.common import vec_env [as 別名]
# 或者: from baselines.common.vec_env import CloudpickleWrapper [as 別名]
def __init__(self, env_fns, is_multi_agent=False):
        """
        envs: list of gym environments to run in subprocesses
        """
        nenvs = len(env_fns)
        self.remotes, self.work_remotes = zip(*[Pipe() for _ in range(nenvs)])        
        self.ps = [Process(target=worker, args=(work_remote, CloudpickleWrapper(env_fn), is_multi_agent))
            for (work_remote, env_fn) in zip(self.work_remotes, env_fns)]
        for p in self.ps:
            p.daemon = True
            p.start()
        for remote in self.work_remotes:
            remote.close()

        self.remotes[0].send(('get_spaces', None))
        self.action_space, self.observation_space = self.remotes[0].recv()
        self.is_multi_agent = is_multi_agent
        self.num_agents = None
        if is_multi_agent:
            try:
                n = len(self.action_space)
            except:
                n = len(self.action_space.spaces)
            self.num_agents = n 
開發者ID:ermongroup,項目名稱:multiagent-gail,代碼行數:26,代碼來源:subproc_vec_env.py

示例4: __init__

# 需要導入模塊: from baselines.common import vec_env [as 別名]
# 或者: from baselines.common.vec_env import CloudpickleWrapper [as 別名]
def __init__(self, env_fns, spaces=None):
        """
        envs: list of gym environments to run in subprocesses
        """
        self.waiting = False
        self.closed = False
        nenvs = len(env_fns)
        self.remotes, self.work_remotes = zip(*[Pipe() for _ in range(nenvs)])
        self.ps = [Process(target=worker, args=(work_remote, remote, CloudpickleWrapper(env_fn)))
            for (work_remote, remote, env_fn) in zip(self.work_remotes, self.remotes, env_fns)]
        for p in self.ps:
            p.daemon = True # if the main process crashes, we should not cause things to hang
            p.start()
        for remote in self.work_remotes:
            remote.close()

        self.remotes[0].send(('get_spaces', None))
        observation_space, action_space = self.remotes[0].recv()
        self.remotes[0].send(('get_agent_types', None))
        self.agent_types = self.remotes[0].recv()
        VecEnv.__init__(self, len(env_fns), observation_space, action_space) 
開發者ID:shariqiqbal2810,項目名稱:MAAC,代碼行數:23,代碼來源:env_wrappers.py

示例5: __init__

# 需要導入模塊: from baselines.common import vec_env [as 別名]
# 或者: from baselines.common.vec_env import CloudpickleWrapper [as 別名]
def __init__(self, env_fns, spaces=None):
        """
        envs: list of gym environments to run in subprocesses
        """
        self.waiting = False
        self.closed = False
        nenvs = len(env_fns)
        self.remotes, self.work_remotes = zip(*[Pipe() for _ in range(nenvs)])
        self.ps = [Process(target=worker, args=(work_remote, remote, CloudpickleWrapper(env_fn)))
            for (work_remote, remote, env_fn) in zip(self.work_remotes, self.remotes, env_fns)]
        for p in self.ps:
            p.daemon = True # if the main process crashes, we should not cause things to hang
            p.start()
        for remote in self.work_remotes:
            remote.close()

        self.remotes[0].send(('get_spaces', None))
        observation_space, action_space = self.remotes[0].recv()
        VecEnv.__init__(self, len(env_fns), observation_space, action_space)
        self.sensor_names = set(observation_space.spaces.keys()) 
開發者ID:alexsax,項目名稱:midlevel-reps,代碼行數:22,代碼來源:subproc_vec_embodied_env.py


注:本文中的baselines.common.vec_env.CloudpickleWrapper方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。