当前位置: 首页>>代码示例>>Python>>正文


Python VecEnvWrapper.__init__方法代码示例

本文整理汇总了Python中baselines.common.vec_env.VecEnvWrapper.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python VecEnvWrapper.__init__方法的具体用法?Python VecEnvWrapper.__init__怎么用?Python VecEnvWrapper.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在baselines.common.vec_env.VecEnvWrapper的用法示例。


在下文中一共展示了VecEnvWrapper.__init__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv):
        VecEnvWrapper.__init__(self, venv)

        self.graph = tf.Graph()

        config = tf.ConfigProto(
            device_count = {'GPU': 0}) # Run on CPU
        #config.gpu_options.allow_growth = True
        self.sess = tf.Session(graph=self.graph,config=config)

        with self.graph.as_default():
            with self.sess.as_default():
                self.obs = tf.placeholder(tf.float32,[None,84,84,4])

                self.rewards = tf.reduce_mean(
                    tf.random_normal(tf.shape(self.obs)),axis=[1,2,3]) 
开发者ID:hiwonjoon,项目名称:ICML2019-TREX,代码行数:18,代码来源:custom_reward_wrapper.py

示例2: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv, ob=True, ret=True, clipob=10., cliprew=10., gamma=0.99, epsilon=1e-8):
        VecEnvWrapper.__init__(self, venv)
        try:
            self.num_agents = num_agents = len(self.observation_space)
            self.ob_rms = [RunningMeanStd(shape=self.observation_space[k].shape) for k in range(num_agents)] if ob else None
        except:
            self.num_agents = num_agents = len(self.observation_space.spaces)
            self.ob_rms = [RunningMeanStd(shape=self.observation_space.spaces[k].shape) for k in range(num_agents)] if ob else None

        self.ret_rms = RunningMeanStd(shape=()) if ret else None
        #[RunningMeanStd(shape=()) for k in range(num_agents)] if ret else None
        self.clipob = clipob
        self.cliprew = cliprew
        # self.ret = [np.zeros(self.num_envs) for _ in range(num_agents)]
        self.ret = np.zeros(self.num_envs)
        self.gamma = gamma
        self.epsilon = epsilon 
开发者ID:ermongroup,项目名称:multiagent-gail,代码行数:19,代码来源:vec_normalize.py

示例3: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv, nstack, device=None):
        self.venv = venv
        self.nstack = nstack

        wos = venv.observation_space  # wrapped ob space
        self.shape_dim0 = wos.shape[0]

        low = np.repeat(wos.low, self.nstack, axis=0)
        high = np.repeat(wos.high, self.nstack, axis=0)

        if device is None:
            device = torch.device('cpu')
        self.stacked_obs = torch.zeros((venv.num_envs, ) +
                                       low.shape).to(device)

        observation_space = gym.spaces.Box(
            low=low, high=high, dtype=venv.observation_space.dtype)
        VecEnvWrapper.__init__(self, venv, observation_space=observation_space) 
开发者ID:ikostrikov,项目名称:pytorch-a2c-ppo-acktr-gail,代码行数:20,代码来源:envs.py

示例4: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv, nstack, device=None):
        self.venv = venv
        self.nstack = nstack

        wos = venv.observation_space  # wrapped ob space
        self.shape_dim0 = wos.shape[0]

        low = np.repeat(wos.low, self.nstack, axis=0)
        high = np.repeat(wos.high, self.nstack, axis=0)

        if device is None:
            device = torch.device('cpu')
        self.stacked_obs = torch.zeros((venv.num_envs,) + low.shape).to(device)

        observation_space = gym.spaces.Box(
            low=low, high=high, dtype=venv.observation_space.dtype)
        VecEnvWrapper.__init__(
            self, venv, observation_space=observation_space) 
开发者ID:justinglibert,项目名称:bezos,代码行数:20,代码来源:envs.py

示例5: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv, nstack):
        self.venv = venv
        self.nstack = nstack
        wos = venv.observation_space # wrapped ob space
        low = np.repeat(wos.low, self.nstack, axis=-1)
        high = np.repeat(wos.high, self.nstack, axis=-1)
        self.stackedobs = np.zeros((venv.num_envs,)+low.shape, low.dtype)
        self.stackedobs_next = np.zeros((venv.num_envs,)+low.shape, low.dtype)
        observation_space = spaces.Box(low=low, high=high, dtype=venv.observation_space.dtype)
        VecEnvWrapper.__init__(self, venv, observation_space=observation_space) 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:12,代码来源:vec_frame_stack.py

示例6: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv, ob=True, ret=True, clipob=10., cliprew=10., gamma=0.99, epsilon=1e-8):
        VecEnvWrapper.__init__(self, venv)
        self.ob_rms = RunningMeanStd(shape=self.observation_space.shape) if ob else None
        self.ret_rms = RunningMeanStd(shape=()) if ret else None
        self.clipob = clipob
        self.cliprew = cliprew
        self.ret = np.zeros(self.num_envs)
        self.gamma = gamma
        self.epsilon = epsilon 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:11,代码来源:vec_normalize.py

示例7: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv, nstack):
        self.venv = venv
        self.nstack = nstack
        wos = venv.observation_space # wrapped ob space
        low = np.repeat(wos.low, self.nstack, axis=-1)
        high = np.repeat(wos.high, self.nstack, axis=-1)
        self.stackedobs = np.zeros((venv.num_envs,)+low.shape, low.dtype)
        observation_space = spaces.Box(low=low, high=high, dtype=venv.observation_space.dtype)
        VecEnvWrapper.__init__(self, venv, observation_space=observation_space) 
开发者ID:bowenliu16,项目名称:rl_graph_generation,代码行数:11,代码来源:vec_frame_stack.py

示例8: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv, directory, record_video_trigger, video_length=200):
        """
        # Arguments
            venv: VecEnv to wrap
            directory: Where to save videos
            record_video_trigger:
                Function that defines when to start recording.
                The function takes the current number of step,
                and returns whether we should start recording or not.
            video_length: Length of recorded video
        """

        VecEnvWrapper.__init__(self, venv)
        self.record_video_trigger = record_video_trigger
        self.video_recorder = None

        self.directory = os.path.abspath(directory)
        if not os.path.exists(self.directory): os.mkdir(self.directory)

        self.file_prefix = "vecenv"
        self.file_infix = '{}'.format(os.getpid())
        self.step_id = 0
        self.video_length = video_length

        self.recording = False
        self.recorded_frames = 0 
开发者ID:hiwonjoon,项目名称:ICML2019-TREX,代码行数:28,代码来源:vec_video_recorder.py

示例9: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, venv, directory, video_name, record_video_trigger, video_length=200):
        """
        # Arguments
            venv: VecEnv to wrap
            directory: Where to save videos
            record_video_trigger:
                Function that defines when to start recording.
                The function takes the current number of step,
                and returns whether we should start recording or not.
            video_length: Length of recorded video
        """
        #print("initializing vecvideorecordernamed")
        #print(directory)
        #print(video_name)
        VecEnvWrapper.__init__(self, venv)
        self.record_video_trigger = record_video_trigger
        self.video_recorder = None

        self.directory = os.path.abspath(directory)
        if not os.path.exists(self.directory): os.mkdir(self.directory)
        self.video_name = video_name

        self.file_prefix = "vecenv"
        self.file_infix = '{}'.format(os.getpid())
        self.step_id = 0
        self.video_length = video_length

        self.recording = False
        self.recorded_frames = 0 
开发者ID:hiwonjoon,项目名称:ICML2019-TREX,代码行数:31,代码来源:vec_video_recorder.py

示例10: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self):
        super().__init__()

        self.conv1 = nn.Conv2d(4, 16, 7, stride=3)
        self.conv2 = nn.Conv2d(16, 16, 5, stride=2)
        self.conv3 = nn.Conv2d(16, 16, 3, stride=1)
        self.conv4 = nn.Conv2d(16, 16, 3, stride=1)
        self.fc1 = nn.Linear(784, 64)
        self.fc2 = nn.Linear(64, 1) 
开发者ID:hiwonjoon,项目名称:ICML2019-TREX,代码行数:11,代码来源:custom_reward_wrapper.py

示例11: __init__

# 需要导入模块: from baselines.common.vec_env import VecEnvWrapper [as 别名]
# 或者: from baselines.common.vec_env.VecEnvWrapper import __init__ [as 别名]
def __init__(self, env):
        """Warp frames to 84x84 as done in the Nature paper and later work."""
        gym.ObservationWrapper.__init__(self, env)
        self.width = 11
        self.height = 11
        # self.observation_space = spaces.Box(low=0, high=1,
        #     shape=(self.height, self.width, 6), dtype=np.float32)
        self.observation_space = spaces.Box(low=0, high=1,
            shape=(6, self.width, self.height), dtype=np.float32) 
开发者ID:montrealrobotics,项目名称:dal,代码行数:11,代码来源:envs.py


注:本文中的baselines.common.vec_env.VecEnvWrapper.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。