sample#

OfflineData.sample(num_samples: int, return_iterator: bool = False, num_shards: int = 1, module_state: Dict[str, Any] = None)[source]#

Samples a batch, or returns data iterators, from the offline data.

On the first call, maps the data through the pre-learner class, which converts it into training batches with the Learner connector pipeline.

Parameters:
  • num_samples (int) – The number of rows per batch. Also the batch size for the mapping step, unless config.input_read_batch_size is set.

  • return_iterator (bool) – Whether to return data iterators instead of a single batch.

  • num_shards (int) – The number of shards to split the data stream into, one per Learner. If greater than 1, splits the data with Dataset.streaming_split() into equally sized shards.

  • module_state (Dict[str, Any]) – The RLModule state to build the pre-learners with. If None, fetches it from the first Learner. Only used on the first call, when the data gets mapped.

Returns:

If return_iterator is True, a list of data iterators, one per shard. Otherwise, a single MultiAgentBatch.