peal.data.dataloaders.DataStack¶
- class peal.data.dataloaders.DataStack[source]¶
Bases:
objectPer-class FIFO buffer of samples drawn from a dataset or dataloader.
data[c]holds[X, y]pairs of classc. The stack is refilled from the source whenever some class runs empty, sopop(c)always returns a sample of classc; it is used to assemble class-ordered batches for visualizations.- Parameters:
datasource (
torch.utils.data.DatasetorDataLoaderorDataloaderMixer) – Where samples come from. A dataset is walked sequentially and cyclically viacurrent_idx; a dataloader is drawn from withnext(iter(...)).num_classes (
int) – Number of classes, i.e. number of per-class lists.transform (
callable, optional) – Transform temporarily swapped intodataset.transformwhile the stack is being filled.
Methods
Draw samples from the source until every class list is non-empty.
Remove and return the oldest buffered sample of one class.
Empty all class lists, reset a
DataloaderMixersource and refill.- __init__(datasource, num_classes, transform=None)[source]¶
Create the per-class lists and fill them once.
- fill_stack()[source]¶
Draw samples from the source until every class list is non-empty.
With hints or indices enabled the label is a tuple and its first element is used as the class index.