zero.data

Missing batteries from torch.utils.data.

Enumerate

class zero.data.Enumerate(dataset)[source]

Make dataset return both indices and items.

Tutorial

from torch.utils.data import DataLoader, TensorDataset
dataset = TensorDataset(torch.randn(9, 2), torch.randn(9))  # X, y
for batch_idx, batch in DataLoader(Enumerate(dataset), batch_size=3):
    print(batch_idx)
tensor([0, 1, 2])
tensor([3, 4, 5])
tensor([6, 7, 8])

Enumerate.dataset

Access the underlying dataset.

Enumerate.__len__()

Get the length of the underlying dataset.

Enumerate.__getitem__(index)

Return index and the corresponding item from the underlying dataset.

functions

collate(iterable)

Almost an alias for torch.utils.data.dataloader.default_collate.

concat(iterable)

Concatenate items of the iterable along the first dimension.

iloader(size, *args, **kwargs)

Make DataLoader over batches of indices.

iter_batches(data, *args, **kwargs)

Efficiently iterate over data in a batchwise manner.