garage.experiment.task_sampler module¶
Efficient and general interfaces for sampling tasks for Meta-RL.
-
class
ConstructEnvsSampler
(env_constructors)[source]¶ Bases:
garage.experiment.task_sampler.TaskSampler
TaskSampler where each task has its own constructor.
Generally, this is used when the different tasks are completely different environments.
Parameters: env_constructors (list[Callable[gym.Env]]) – Callables that produce environments (for example, environment types).
-
class
EnvPoolSampler
(envs)[source]¶ Bases:
garage.experiment.task_sampler.TaskSampler
TaskSampler that samples from a finite pool of environments.
This can be used with any environments, but is generally best when using in-process samplers with environments that are expensive to construct.
Parameters: envs (list[gym.Env]) – List of environments to use as a pool. -
grow_pool
(new_size)[source]¶ Increase the size of the pool by copying random tasks in it.
Note that this only copies the tasks already in the pool, and cannot create new original tasks in any way.
Parameters: new_size (int) – Size the pool should be after growning.
-
sample
(n_tasks, with_replacement=False)[source]¶ Sample a list of environment updates.
Parameters: Raises: ValueError
– If the number of requested tasks is larger than the pool, or with_replacement is set.Returns: - Batch of sampled environment updates, which, when
invoked on environments, will configure them with new tasks. See
EnvUpdate
for more information.
Return type:
-
-
class
SetTaskSampler
(env_constructor)[source]¶ Bases:
garage.experiment.task_sampler.TaskSampler
TaskSampler where the environment can sample “task objects”.
This is used for environments that implement sample_tasks and set_task. For example,
HalfCheetahVelEnv
, as implemented in Garage.Parameters: env_constructor (Callable[gym.Env]) – Callable that produces an environment (for example, an environment type).
-
class
TaskSampler
[source]¶ Bases:
abc.ABC
Class for sampling batches of tasks, represented as `~EnvUpdate`s.