ray.rllib.utils.replay_buffers.replay_buffer.ReplayBuffer.sample#
- ReplayBuffer.sample(num_items: int | None = None, **kwargs) SampleBatch | MultiAgentBatch | Dict[str, Any] | None[source]#
- Samples - num_itemsitems from this buffer.- The items depend on the buffer’s storage_unit. Samples in the results may be repeated. - Examples for sampling results: - 1) If storage unit ‘timesteps’ has been chosen and batches of size 5 have been added, sample(5) will yield a concatenated batch of 15 timesteps. - 2) If storage unit ‘sequences’ has been chosen and sequences of different lengths have been added, sample(5) will yield a concatenated batch with a number of timesteps equal to the sum of timesteps in the 5 sampled sequences. - 3) If storage unit ‘episodes’ has been chosen and episodes of different lengths have been added, sample(5) will yield a concatenated batch with a number of timesteps equal to the sum of timesteps in the 5 sampled episodes. - Parameters:
- num_items – Number of items to sample from this buffer. 
- **kwargs – Forward compatibility kwargs. 
 
- Returns:
- Concatenated batch of items.