trw.train.sequence_array

Module Contents

Classes

SequenceArray

Create a sequence of batches from numpy arrays, lists and torch.Tensor

SequenceIteratorArray

Iterate the elements of an trw.train.SequenceArray sequence

Attributes

sample_uid_name

trw.train.sequence_array.sample_uid_name = sample_uid
class trw.train.sequence_array.SequenceArray(split, sampler=sampler_trw.SamplerRandom(), transforms=None, use_advanced_indexing=True, sample_uid_name=sample_uid_name)

Bases: trw.train.sequence.Sequence

Create a sequence of batches from numpy arrays, lists and torch.Tensor

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

subsample_uids(self, uids, uids_name, new_sampler=None)

Sub-sample a sequence to samples with specified UIDs.

Parameters
  • uids (list) – the uids. If new_sampler keeps the ordering, then the samples of the resampled sequence should follow uids ordering

  • uids_name (str) – the name of the UIDs

  • new_sampler (Sampler) – the sampler to be used for the subsampler sequence. If None, re-use the existing

Returns

a subsampled Sequence

__iter__(self)
Returns

An iterator of batches

close(self)
class trw.train.sequence_array.SequenceIteratorArray(base_sequence, sampler)

Bases: trw.train.sequence.SequenceIterator

Iterate the elements of an trw.train.SequenceArray sequence

Assumptions:
  • underlying base_sequence doesn’t change sizes while iterating

__next__(self)
Returns

The next batch of data

close(self)

Special method to close and clean the resources of the sequence