trw.train.sequence_array
¶
Module Contents¶
Classes¶
Create a sequence of batches from numpy arrays, lists and |
Attributes¶
- trw.train.sequence_array.sample_uid_name = sample_uid¶
- class trw.train.sequence_array.SequenceArray(split, sampler=sampler.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
- initializer(self)¶
- static get(split, nb_samples, indices, transforms, use_advanced_indexing)¶
Collect the split indices given and apply a series of transformations
- Parameters
nb_samples – the total number of samples of split
split – a mapping of np.ndarray or torch.Tensor
indices – a list of indices as numpy array
transforms – a transformation or list of transformations or None
use_advanced_indexing – if True, use the advanced indexing mechanism else use a simple list (original data is referenced) advanced indexing is typically faster for small objects, however for large objects (e.g., 3D data) the advanced indexing makes a copy of the data making it very slow.
- Returns
a split with the indices provided
- get_next(self)¶
- __next__(self)¶
- Returns
The next batch of data
- __iter__(self)¶
- Returns
An iterator of batches