Rate this Page
★ ★ ★ ★ ★

Sampler#

class torchrl.data.replay_buffers.Sampler(*args, **kwargs)#

A generic sampler base class for composable Replay Buffers.

Variables:

requires_shared_state (bool) – True when sampling mutates state that every consumer of the buffer must observe, such as without-replacement bookkeeping, priorities, consumption marks, staleness counters or streaming queues. Such a sampler cannot be copied into torch.utils.data.DataLoader workers. Defaults to True; samplers whose draws depend only on the storage content and their configuration, such as RandomSampler and SliceSampler, set it to False.

can_sample(storage: Storage, batch_size: int) → bool[source]#

Returns whether the sampler can draw the requested batch.