garage.replay_buffer.path_buffer module

A replay buffer that efficiently stores and can sample whole paths.

class PathBuffer(capacity_in_transitions)[source]

Bases: object

A replay buffer that stores and can sample whole paths.

This buffer only stores valid steps, and doesn’t require paths to have a maximum length.

Parameters:capacity_in_transitions (int) – Total memory allocated for the buffer.
add_path(path)[source]

Add a path to the buffer.

Parameters:path (dict) – A dict of array of shape (path_len, flat_dim).
Raises:ValueError – If a key is missing from path or path has wrong shape.
clear()[source]

Clear buffer.

n_transitions_stored

Return the size of the replay buffer.

Returns:Size of the current replay buffer.
Return type:int
sample_path()[source]

Sample a single path from the buffer.

Returns:A dict of arrays of shape (path_len, flat_dim).
Return type:path
sample_transitions(batch_size)[source]

Sample a batch of transitions from the buffer.

Parameters:batch_size (int) – Number of transitions to sample.
Returns:A dict of arrays of shape (batch_size, flat_dim).
Return type:dict