當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。