当前位置: 首页>>代码示例>>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;未经允许,请勿转载。