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


Python suite.load方法代码示例

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


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

示例1: _dm_control_env

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def _dm_control_env(
    action_repeat, max_length, domain, task, params, normalize=False,
    camera_id=None):
  if isinstance(domain, str):
    from dm_control import suite
    env = suite.load(domain, task)
  else:
    assert task is None
    env = domain()
  if camera_id is None:
    camera_id = int(params.get('camera_id', 0))
  env = control.wrappers.DeepMindWrapper(env, (64, 64), camera_id=camera_id)
  env = control.wrappers.ActionRepeat(env, action_repeat)
  if normalize:
    env = control.wrappers.NormalizeActions(env)
  env = control.wrappers.MaximumDuration(env, max_length)
  env = control.wrappers.PixelObservations(env, (64, 64), np.uint8, 'image')
  env = control.wrappers.ConvertTo32Bit(env)
  return env 
开发者ID:google-research,项目名称:planet,代码行数:21,代码来源:tasks.py

示例2: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(self, args, rand_seed, monitor, width=480, height=480):
        self.width = width
        self.height = height
        task_name = dm_control_util.get_env_names(args.task)
        from dm_control import suite
        self.env = suite.load(
            domain_name=task_name[0], task_name=task_name[1],
            task_kwargs={'random': rand_seed}
        )
        self._base_path = init_path.get_abs_base_dir()
        self.NUM_EPISODE_RECORED = NUM_EPISODE_RECORED
        self._is_dirname = True

        # save the video
        self._monitor = monitor
        self._current_episode = 0
        if self._monitor:
            self.init_save(args) 
开发者ID:WilsonWangTHU,项目名称:neural_graph_evolution,代码行数:20,代码来源:dm_env_wrapper.py

示例3: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(self, env, symbolic, seed, max_episode_length, action_repeat, bit_depth):
    from dm_control import suite
    from dm_control.suite.wrappers import pixels
    domain, task = env.split('-')
    self.symbolic = symbolic
    self._env = suite.load(domain_name=domain, task_name=task, task_kwargs={'random': seed})
    if not symbolic:
      self._env = pixels.Wrapper(self._env)
    self.max_episode_length = max_episode_length
    self.action_repeat = action_repeat
    if action_repeat != CONTROL_SUITE_ACTION_REPEATS[domain]:
      print('Using action repeat %d; recommended action repeat for domain is %d' % (action_repeat, CONTROL_SUITE_ACTION_REPEATS[domain]))
    self.bit_depth = bit_depth 
开发者ID:Kaixhin,项目名称:PlaNet,代码行数:15,代码来源:env.py

示例4: from_suite

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def from_suite(cls, domain_name, task_name):
        return cls(suite.load(domain_name, task_name),
                   name='{}.{}'.format(domain_name, task_name)) 
开发者ID:rlworkgroup,项目名称:garage,代码行数:5,代码来源:dm_control_env.py

示例5: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(
        self,
        domain_name="cartpole",
        task_name="balance",
        visualize_reward: bool = True,
        fixed_steps: int = 1,
        custom_death: "CustomDeath" = None,
    ):
        """
            Creates DMControlEnv and initializes the environment.

            :param domain_name: match dm_control interface.
            :param task_name: match dm_control interface.
            :param visualize_reward: match dm_control interface.
            :param fixed_steps: The number of consecutive times that an action will be applied.
                            This allows us to set the frequency at which the policy will play.
            :param custom_death: Pro hack to beat the shit out of DeepMind even further.
            """
        from dm_control import suite

        name = str(domain_name) + ":" + str(task_name)
        super(DMControlEnv, self).__init__(name=name, state=None)
        self.fixed_steps = fixed_steps
        self._render_i = 0
        self._env = suite.load(
            domain_name=domain_name, task_name=task_name, visualize_reward=visualize_reward
        )
        self._name = name
        self.viewer = []
        self._last_time_step = None

        self._custom_death = custom_death
        self.reset() 
开发者ID:Guillemdb,项目名称:FractalAI,代码行数:35,代码来源:environment.py

示例6: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(
        self,
        name: str = "cartpole-balance",
        visualize_reward: bool = True,
        n_repeat_action: int = 1,
        custom_death: "CustomDeath" = None,
    ):
        """
            Creates DMControlEnv and initializes the environment.
            :param domain_name: match dm_control interface.
            :param task_name: match dm_control interface.
            :param visualize_reward: match dm_control interface.
            :param fixed_steps: The number of consecutive times that an action will be applied.
                            This allows us to set the frequency at which the policy will play.
            :param custom_death: Pro hack to beat the shit out of DeepMind even further.
            """
        from dm_control import suite

        domain_name, task_name = name.split("-")
        super(DMControlEnv, self).__init__(name=name, n_repeat_action=n_repeat_action)
        self._render_i = 0
        self._env = suite.load(
            domain_name=domain_name, task_name=task_name, visualize_reward=visualize_reward
        )
        self._name = name
        self.viewer = []
        self._last_time_step = None
        self._viewer = rendering.SimpleImageViewer()

        self._custom_death = custom_death

        self.reset() 
开发者ID:Guillemdb,项目名称:FractalAI,代码行数:34,代码来源:dm_control.py

示例7: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(self, args, rand_seed, monitor, width=480, height=480):
        self.width = width
        self.height = height
        self.task = args.task
        self.args = args
        assert 'fish3d' in self.task
        self.is_evo = 'evo' in self.task
        if 'easyswim' in self.task:
            self.target_angle = args.fish_target_angle

        from dm_control import suite
        self.env = suite.load(
            domain_name='fish', task_name='swim',
            task_kwargs={'random': rand_seed}
        )
        self._base_path = init_path.get_abs_base_dir()

        self.load_xml(os.path.join(self._base_path, 'env', 'assets/fish3d.xml'))
        self.set_get_observation()  # overwrite the original get_ob function
        self.set_get_reward()  # overwrite the original reward function
        self._JOINTS = ['tail1',
                        'tail_twist',
                        'tail2',
                        'finright_roll',
                        'finright_pitch',
                        'finleft_roll',
                        'finleft_pitch']

        # save the video
        self._monitor = monitor
        self._current_episode = 0
        if self._monitor:
            self.init_save(args) 
开发者ID:WilsonWangTHU,项目名称:neural_graph_evolution,代码行数:35,代码来源:fish_env_wrapper.py

示例8: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(self, args, rand_seed, monitor, width=480, height=480):
        self.width = width
        self.height = height
        self.task = args.task
        assert 'walker' in self.task or 'hopper' in self.task or 'cheetah' in self.task
        self.args = args
        self.is_evo = 'evo' in self.task

        from dm_control import suite
        self.env = suite.load(
            domain_name='walker', task_name='walk',
            task_kwargs={'random': rand_seed}
        )
        self._base_path = init_path.get_abs_base_dir()

        self.load_xml(os.path.join(self._base_path, 'env', 'assets/walker.xml'))
        self.set_get_observation()  # overwrite the original get_ob function
        self.set_get_reward()       # overwrite the original reward function
        self._JOINTS = ['right_hip',
                        'right_knee',
                        'right_ankle',
                        'left_hip',
                        'left_knee',
                        'left_ankle']

        # save the video
        self._monitor = monitor
        self._current_episode = 0
        if self._monitor:
            self.init_save(args) 
开发者ID:WilsonWangTHU,项目名称:neural_graph_evolution,代码行数:32,代码来源:walker_env_wrapper.py

示例9: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(self, domain_name, task_name, horizon, gamma, task_kwargs=None,
                 dt=.01, width_screen=480, height_screen=480, camera_id=0):
        """
        Constructor.

        Args:
             domain_name (str): name of the environment;
             task_name (str): name of the task of the environment;
             horizon (int): the horizon;
             gamma (float): the discount factor;
             task_kwargs (dict, None): parameters of the task;
             dt (float, .01): duration of a control step;
             width_screen (int, 480): width of the screen;
             height_screen (int, 480): height of the screen;
             camera_id (int, 0): position of camera to render the environment;

        """
        # MDP creation
        if task_kwargs is None:
            task_kwargs = dict()
        task_kwargs['time_limit'] = np.inf  # Hack to ignore dm_control time limit.

        self.env = suite.load(domain_name, task_name, task_kwargs=task_kwargs)

        # MDP properties
        action_space = self._convert_action_space(self.env.action_spec())
        observation_space = self._convert_observation_space(self.env.observation_spec())
        mdp_info = MDPInfo(observation_space, action_space, gamma, horizon)

        self._viewer = ImageViewer((width_screen, height_screen), dt)
        self._camera_id = camera_id

        super().__init__(mdp_info) 
开发者ID:MushroomRL,项目名称:mushroom-rl,代码行数:35,代码来源:dm_control_env.py

示例10: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(self, domain_name="cartpole", task_name="balance",
                     visualize_reward: bool=True, fixed_steps: int=1,
                     custom_death: "CustomDeath"=None):
            """
            Creates DMControlEnv and initializes the environment.

            :param domain_name: match dm_control interface.
            :param task_name: match dm_control interface.
            :param visualize_reward: match dm_control interface.
            :param fixed_steps: The number of consecutive times that an action will be applied.
                            This allows us to set the frequency at which the policy will play.
            :param custom_death: Pro hack to beat the shit out of DeepMind even further.
            """
            from dm_control import suite
            name = str(domain_name) + ":" + str(task_name)
            super(DMControlEnv, self).__init__(name=name, state=None)
            self.fixed_steps = fixed_steps
            self._render_i = 0
            self._env = suite.load(domain_name=domain_name, task_name=task_name,
                                   visualize_reward=visualize_reward)
            self._name = name
            self.viewer = []
            self._last_time_step = None

            self._custom_death = custom_death
            self.reset() 
开发者ID:FragileTech,项目名称:FractalAI,代码行数:28,代码来源:environment.py

示例11: __init__

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def __init__(self, name: str = "cartpole-balance",
                     visualize_reward: bool = True, n_repeat_action: int = 1,
                     custom_death: "CustomDeath" = None):
            """
            Creates DMControlEnv and initializes the environment.
            :param domain_name: match dm_control interface.
            :param task_name: match dm_control interface.
            :param visualize_reward: match dm_control interface.
            :param fixed_steps: The number of consecutive times that an action will be applied.
                            This allows us to set the frequency at which the policy will play.
            :param custom_death: Pro hack to beat the shit out of DeepMind even further.
            """
            from dm_control import suite
            domain_name, task_name = name.split("-")
            super(DMControlEnv, self).__init__(name=name, n_repeat_action=n_repeat_action)
            self._render_i = 0
            self._env = suite.load(domain_name=domain_name, task_name=task_name,
                                   visualize_reward=visualize_reward)
            self._name = name
            self.viewer = []
            self._last_time_step = None
            self._viewer = rendering.SimpleImageViewer()

            self._custom_death = custom_death

            self.reset() 
开发者ID:FragileTech,项目名称:FractalAI,代码行数:28,代码来源:dm_control.py

示例12: test_load_without_kwargs

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def test_load_without_kwargs(self):
    env = suite.load('cartpole', 'swingup')
    self.assertIsInstance(env, control.Environment) 
开发者ID:deepmind,项目名称:dm_control,代码行数:5,代码来源:loader_test.py

示例13: test_load_with_kwargs

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def test_load_with_kwargs(self):
    env = suite.load('cartpole', 'swingup',
                     task_kwargs={'time_limit': 40, 'random': 99})
    self.assertIsInstance(env, control.Environment) 
开发者ID:deepmind,项目名称:dm_control,代码行数:6,代码来源:loader_test.py

示例14: make_trajectory

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def make_trajectory(domain, task, seed, **trajectory_kwargs):
  env = suite.load(domain, task, task_kwargs={'random': seed})
  policy = uniform_random_policy(env.action_spec(), random=seed)
  return step_environment(env, policy, **trajectory_kwargs) 
开发者ID:deepmind,项目名称:dm_control,代码行数:6,代码来源:suite_test.py

示例15: test_components_have_names

# 需要导入模块: from dm_control import suite [as 别名]
# 或者: from dm_control.suite import load [as 别名]
def test_components_have_names(self, domain, task):
    env = suite.load(domain, task)
    model = env.physics.model

    object_types_and_size_fields = [
        ('body', 'nbody'),
        ('joint', 'njnt'),
        ('geom', 'ngeom'),
        ('site', 'nsite'),
        ('camera', 'ncam'),
        ('light', 'nlight'),
        ('mesh', 'nmesh'),
        ('hfield', 'nhfield'),
        ('texture', 'ntex'),
        ('material', 'nmat'),
        ('equality', 'neq'),
        ('tendon', 'ntendon'),
        ('actuator', 'nu'),
        ('sensor', 'nsensor'),
        ('numeric', 'nnumeric'),
        ('text', 'ntext'),
        ('tuple', 'ntuple'),
    ]
    for object_type, size_field in object_types_and_size_fields:
      for idx in range(getattr(model, size_field)):
        object_name = model.id2name(idx, object_type)
        self.assertNotEqual(object_name, '',
                            msg='Model {!r} contains unnamed {!r} with ID {}.'
                            .format(model.name, object_type, idx)) 
开发者ID:deepmind,项目名称:dm_control,代码行数:31,代码来源:suite_test.py


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