Rate this Page

SamplerEnsemble#

class torchrl.data.replay_buffers.SamplerEnsemble(*args, **kwargs)[source]#

An ensemble of samplers.

This class is designed to work with ReplayBufferEnsemble. It contains the samplers as well as the sampling strategy hyperparameters.

Parameters:

samplers (sequence of Sampler) – the samplers to make the composite sampler.

Keyword Arguments:
  • p (list or tensor of probabilities, optional) – if provided, indicates the weights of each dataset during sampling.

  • sample_from_all (bool, optional) – if True, each dataset will be sampled from. This is not compatible with the p argument. Defaults to False.

  • num_buffer_sampled (int, optional) – the number of buffers to sample. if sample_from_all=True, this has no effect, as it defaults to the number of buffers. If sample_from_all=False, buffers will be sampled according to the probabilities p.

Warning

The indices provided in the info dictionary are placed in a TensorDict with keys index and buffer_ids that allow the upper ReplayBufferEnsemble and StorageEnsemble objects to retrieve the data. This format is different from with other samplers which usually return indices as regular tensors.