SampleBatch

SampleBatch(samples)

A batch of samples with automatic attribute aggregation.

Accessing an attribute aggregates that field across all samples: NDArray fields are stacked into a numpy array with a batch dimension; other fields are collected into a list. Results are cached.

Parameters

Name Type Description Default
DT The sample type, must derive from PackableSample. required

Examples

>>> batch = SampleBatch[MyData]([sample1, sample2, sample3])
>>> batch.embeddings  # Stacked numpy array of shape (3, ...)
>>> batch.names  # List of names

Attributes

Name Description
sample_type The type parameter DT used when creating this batch.