trw.train.sequence_adaptor

Module Contents

Classes

SequenceAdaptorTorch

Adapt a torch.utils.data.DataLoader to a trw.train.Sequence interface

class trw.train.sequence_adaptor.SequenceAdaptorTorch(torch_dataloader, features=None)

Bases: trw.train.sequence.Sequence, trw.train.sequence.SequenceIterator

Adapt a torch.utils.data.DataLoader to a trw.train.Sequence interface

The main purpose is to enable compatibility with the torch data loader and any existing third party code.

__len__(self)
__iter__(self)
Returns

An iterator of batches

__next__(self)
Returns

The next batch of data

subsample(self, nb_samples)

Sub-sample a sequence to a fixed number of samples.

The purpose is to obtain a smaller sequence, this is particularly useful for the export of augmentations, samples.

Parameters

nb_samples – the number of samples desired in the original sequence

Returns

a subsampled Sequence

close(self)

Special method to close and clean the resources of the sequence