Skip to content

unienv_data.samplers.step_sampler

StepSampler

StepSampler(data: BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType], batch_size: int, seed: Optional[int] = None, device: Optional[BDeviceType] = None)

Bases: BatchSampler[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType, BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType]

data instance-attribute

data = data

batch_size instance-attribute

batch_size = batch_size

data_rng instance-attribute

data_rng = random_number_generator(seed, device=device)

backend property

backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]

device property

device: Optional[BDeviceType]

is_mutable class-attribute instance-attribute

is_mutable: bool = False

single_space instance-attribute

single_space = single_space

single_metadata_space instance-attribute

single_metadata_space = single_metadata_space

rng class-attribute instance-attribute

rng: Optional[SamplerRNGType] = None

sampled_space property

sampled_space: Space[SamplerBatchT, SamplerDeviceType, SamplerDtypeType, SamplerRNGType]

sampled_metadata_space property

sampled_metadata_space: Optional[DictSpace[SamplerDeviceType, SamplerDtypeType, SamplerRNGType]]

get_flattened_at

get_flattened_at(idx)

get_flattened_at_with_metadata

get_flattened_at_with_metadata(idx)

get_at

get_at(idx)

get_at_with_metadata

get_at_with_metadata(idx)

set_flattened_at

set_flattened_at(idx: Union[IndexableType, BArrayType], value: BArrayType) -> None

Overwrite existing samples using flattened data.

append_flattened

append_flattened(value: BArrayType) -> None

Append one flattened sample to the batch.

extend_flattened

extend_flattened(value: BArrayType) -> None

Append a batched block of flattened samples.

set_at

set_at(idx: Union[IndexableType, BArrayType], value: BatchT) -> None

Overwrite existing samples using structured data.

remove_at

remove_at(idx: Union[IndexableType, BArrayType]) -> None

Remove one or more samples from the batch.

append

append(value: BatchT) -> None

Append one structured sample to the batch.

extend

extend(value: BatchT) -> None

Append a batched block of structured samples.

extend_from

extend_from(other: BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType], chunk_size: int = 8, tqdm: bool = False) -> None

Copy data from another batch in bounded-size chunks.

get_slice

get_slice(idx: Union[IndexableType, BArrayType]) -> BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType]

Create a lazy view over a subset of indices.

get_column

get_column(nested_keys: Sequence[str]) -> BatchBase[Any, BArrayType, BDeviceType, BDtypeType, BRNGType]

Create a lazy view over a nested field inside each sample.

close

close() -> None

manual_seed

manual_seed(seed: int) -> None

Reset sampler RNG state, including the optional data-index RNG.

sample_index

sample_index() -> SamplerArrayType

Draw random indices for one batch.

sample_flat

sample_flat() -> SamplerArrayType

Sample a batch and return it in flattened form.

sample_flat_with_metadata

sample_flat_with_metadata() -> Tuple[SamplerArrayType, Optional[Dict[str, Any]]]

Sample a flattened batch together with optional metadata.

sample

sample() -> SamplerBatchT

Sample a batch in its structured form.

sample_with_metadata

sample_with_metadata() -> Tuple[SamplerBatchT, Optional[Dict[str, Any]]]

Sample a structured batch together with optional metadata.

epoch_iter

epoch_iter() -> Iterator[SamplerBatchT]

Iterate once over a random permutation of the source data.

epoch_iter_with_metadata

epoch_iter_with_metadata() -> Iterator[Tuple[SamplerBatchT, Optional[Dict[str, Any]]]]

Iterate once over shuffled structured batches plus metadata.

epoch_flat_iter

epoch_flat_iter() -> Iterator[SamplerArrayType]

Iterate once over shuffled batches in flattened form.

epoch_flat_iter_with_metadata

epoch_flat_iter_with_metadata() -> Iterator[Tuple[SamplerArrayType, Optional[Dict[str, Any]]]]

Iterate once over shuffled flattened batches plus metadata.