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


Python registration.EnvSpec方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from gym.envs import registration [as 別名]
# 或者: from gym.envs.registration import EnvSpec [as 別名]
def __init__(self, env, record_video=True, video_schedule=None,
            log_dir=None, timestep_limit=9999):
        # Ensure the version saved to disk doesn't monitor into our log_dir
        locals_no_monitor = dict(locals())
        locals_no_monitor['log_dir'] = None
        locals_no_monitor['record_video'] = False
        locals_no_monitor['video_schedule'] = None
        Serializable.quick_init(self, locals_no_monitor)

        self.env = env
        self._observation_space = to_rllab_space(env.observation_space)
        self._action_space = to_rllab_space(env.action_space)        
        self.env.spec = EnvSpec('GymEnv-v0')

        monitor.logger.setLevel(logging.WARNING)
        if not record_video:
            self.video_schedule = NoVideoSchedule()
        else:
            if video_schedule is None:
                self.video_schedule = CappedCubicVideoSchedule()
            else:
                self.video_schedule = video_schedule
        self.set_log_dir(log_dir)

        self._horizon = timestep_limit 
開發者ID:vicariousinc,項目名稱:pixelworld,代碼行數:27,代碼來源:gym_env.py

示例2: __init__

# 需要導入模塊: from gym.envs import registration [as 別名]
# 或者: from gym.envs.registration import EnvSpec [as 別名]
def __init__(self, max_episode_steps_coeff=1, scale=20, goal_padding=2.0):
        super(PointMass, self).__init__()
        # define scale such that the each square in the grid is 1 x 1
        self.scale = int(scale)
        self.grid_size = self.scale * self.scale
        self.observation_space = gym.spaces.Box(
            low=np.array([0.0, 0.0]),
            high=np.array([1.0, 1.0]))
        self.action_space = gym.spaces.Box(
            low=np.array([-np.inf, -np.inf]),
            high=np.array([np.inf, np.inf]))
        self.goal_padding = goal_padding
        self.spec = EnvSpec(id='PointMass-v0', max_episode_steps=int(max_episode_steps_coeff*self.scale)) 
開發者ID:xuwd11,項目名稱:cs294-112_hws,代碼行數:15,代碼來源:pointmass.py

示例3: register

# 需要導入模塊: from gym.envs import registration [as 別名]
# 或者: from gym.envs.registration import EnvSpec [as 別名]
def register(id, **kwargs):
    """Idempotent version of gym.envs.registration.registry.

    Needed since aprl.envs can get imported multiple times, e.g. when deserializing policies.
    """
    try:
        existing_spec = registration.spec(id)
        new_spec = registration.EnvSpec(id, **kwargs)
        assert existing_spec.__dict__ == new_spec.__dict__
    except gym.error.UnregisteredEnv:  # not previously registered
        registration.register(id, **kwargs)


# Low-dimensional multi-agent environments 
開發者ID:HumanCompatibleAI,項目名稱:adversarial-policies,代碼行數:16,代碼來源:__init__.py

示例4: meta_reset

# 需要導入模塊: from gym.envs import registration [as 別名]
# 或者: from gym.envs.registration import EnvSpec [as 別名]
def meta_reset(self, seed):
        np.random.seed(seed)

        env = RandomWeightHopperEnv(rand_mass=self.rand_mass,
                                    rand_gravity=self.rand_gravity,
                                    rand_friction=self.rand_friction,
                                    rand_thickness=self.rand_thickness)

        # Based on Hopper-v2
        spec = EnvSpec(
            'RandomWeightHopperEnv-v0',
            entry_point='generic_rl.envs.mujoco:RandomWeightHopperEnv',
            max_episode_steps=1000,
            reward_threshold=3800.0
        )

        env._spec = spec
        env.seed(seed)

        # Wrap the env as needed
        env = TimeLimit(
            env,
            max_episode_steps=spec.max_episode_steps,
            max_episode_seconds=spec.max_episode_seconds
        )

        self.env = env
        # Fix for done flags.
        self.env.reset()
        self.step = env.step
        self.render = env.render
        self.reset = env.reset 
開發者ID:openai,項目名稱:EPG,代碼行數:34,代碼來源:random_robots.py

示例5: __init__

# 需要導入模塊: from gym.envs import registration [as 別名]
# 或者: from gym.envs.registration import EnvSpec [as 別名]
def __init__(self):
        self.action_space = spaces.Discrete(2)
        self.observation_space = DICT_SPACE
        self._spec = EnvSpec("NestedDictEnv-v0")
        self.steps = 0 
開發者ID:ray-project,項目名稱:ray,代碼行數:7,代碼來源:test_nested_observation_spaces.py

示例6: specification

# 需要導入模塊: from gym.envs import registration [as 別名]
# 或者: from gym.envs.registration import EnvSpec [as 別名]
def specification(self) -> EnvSpec:
        """ Return environment specification """
        raise NotImplementedError 
開發者ID:MillionIntegrals,項目名稱:vel,代碼行數:5,代碼來源:env_base.py

示例7: specification

# 需要導入模塊: from gym.envs import registration [as 別名]
# 或者: from gym.envs.registration import EnvSpec [as 別名]
def specification(self) -> EnvSpec:
        """ Return environment specification """
        return gym.spec(self.envname) 
開發者ID:MillionIntegrals,項目名稱:vel,代碼行數:5,代碼來源:classic_control.py

示例8: __init__

# 需要導入模塊: from gym.envs import registration [as 別名]
# 或者: from gym.envs.registration import EnvSpec [as 別名]
def __init__(self, goal_reaching_thresholds=np.array([0.075, 0.075, 0.75]),
                 goal_not_reached_penalty=-1, goal_reached_reward=0, terminate_on_goal_reaching=True,
                 time_limit=1000, frameskip=1, random_goals_instead_of_standing_goal=False,
                 polar_coordinates: bool=False):
        super().__init__()
        dir = os.path.dirname(__file__)
        model = load_model_from_path(dir + "/pendulum_with_goals.xml")

        self.sim = MjSim(model)
        self.viewer = None
        self.rgb_viewer = None

        self.frameskip = frameskip
        self.goal = None
        self.goal_reaching_thresholds = goal_reaching_thresholds
        self.goal_not_reached_penalty = goal_not_reached_penalty
        self.goal_reached_reward = goal_reached_reward
        self.terminate_on_goal_reaching = terminate_on_goal_reaching
        self.time_limit = time_limit
        self.current_episode_steps_counter = 0
        self.random_goals_instead_of_standing_goal = random_goals_instead_of_standing_goal
        self.polar_coordinates = polar_coordinates

        # spaces definition
        self.action_space = spaces.Box(low=-self.sim.model.actuator_ctrlrange[:, 1],
                                       high=self.sim.model.actuator_ctrlrange[:, 1],
                                       dtype=np.float32)
        if self.polar_coordinates:
            self.observation_space = spaces.Dict({
                "observation": spaces.Box(low=np.array([-np.pi, -15]),
                                          high=np.array([np.pi, 15]),
                                          dtype=np.float32),
                "desired_goal": spaces.Box(low=np.array([-np.pi, -15]),
                                           high=np.array([np.pi, 15]),
                                           dtype=np.float32),
                "achieved_goal": spaces.Box(low=np.array([-np.pi, -15]),
                                            high=np.array([np.pi, 15]),
                                            dtype=np.float32)
            })
        else:
            self.observation_space = spaces.Dict({
                "observation": spaces.Box(low=np.array([-1, -1, -15]),
                                          high=np.array([1, 1, 15]),
                                          dtype=np.float32),
                "desired_goal": spaces.Box(low=np.array([-1, -1, -15]),
                                           high=np.array([1, 1, 15]),
                                           dtype=np.float32),
                "achieved_goal": spaces.Box(low=np.array([-1, -1, -15]),
                                            high=np.array([1, 1, 15]),
                                            dtype=np.float32)
            })

        self.spec = EnvSpec('PendulumWithGoals-v0')
        self.spec.reward_threshold = self.goal_not_reached_penalty * self.time_limit

        self.reset() 
開發者ID:NervanaSystems,項目名稱:coach,代碼行數:58,代碼來源:pendulum_with_goals.py


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