garage.tf.samplers package

Samplers which run agents that use Tensorflow in environments.

class BatchSampler(algo, env, n_envs)[source]

Bases: garage.sampler.sampler_deprecated.BaseSampler

Collects samples in parallel using a stateful pool of workers.

Parameters:
obtain_samples(itr, batch_size=None, whole_paths=True)[source]

Collect samples for the given iteration number.

Parameters:
  • itr (int) – Number of iteration.
  • batch_size (int) – Number of environment steps in one batch.
  • whole_paths (bool) – Whether to use whole path or truncated.
Returns:

A list of paths.

Return type:

list[dict]

shutdown_worker()[source]

Terminate workers if necessary.

start_worker()[source]

Initialize the sampler.

class TFWorkerClassWrapper(wrapped_class)[source]

Bases: object

Acts like a Worker class, but is actually an object.

When called, constructs the wrapped class and wraps it in a TFWorkerWrapper.

Parameters:wrapped_class (type) – The class to wrap. Should be a subclass of garage.sampler.Worker.
class TFWorkerWrapper[source]

Bases: garage.sampler.worker.Worker

Wrapper around another workers that initializes a TensorFlow Session.

agent

Returns the worker’s agent.

Returns:the worker’s agent.
Return type:garage.Policy
collect_rollout()[source]

Collect the current rollout, clearing the internal buffer.

Returns:
Batch of sampled trajectories. May be
truncated if the rollouts haven’t completed yet.
Return type:garage.TrajectoryBatch
env

Returns the worker’s environment.

Returns:the worker’s environment.
Return type:gym.Env
rollout()[source]

Sample a single rollout of the agent in the environment.

Returns:
Batch of sampled trajectories. May be
truncated if max_path_length is set.
Return type:garage.TrajectoryBatch
shutdown()[source]

Perform shutdown processes for TF.

start_rollout()[source]

Begin a new rollout.

step_rollout()[source]

Take a single time-step in the current rollout.

Returns:
True iff the path is done, either due to the environment
indicating termination of due to reaching max_path_length.
Return type:bool
update_agent(agent_update)[source]

Update the worker’s agent, using agent_update.

Parameters:agent_update (object) – An agent update. The exact type of this argument depends on the Worker implementation.
update_env(env_update)[source]

Update the worker’s env, using env_update.

Parameters:env_update (object) – An environment update. The exact type of this argument depends on the Worker implementation.
worker_init()[source]

Initialize a worker.