dival.datasets.reordered_dataset module

class dival.datasets.reordered_dataset.ReorderedDataset(dataset, idx)[source]

Bases: dival.datasets.dataset.Dataset

Dataset that reorders the samples of another dataset by specified index arrays for each part.

__init__(dataset, idx)[source]
Parameters
  • dataset (Dataset) – Dataset to take the samples from. Must support random access.

  • idx (dict of array-like) – Indices into the original dataset for each part. Each array-like must have (at least) the same length as the part.

get_sample(index, part='train', out=None)[source]

Get single sample by index.

Parameters
  • index (int) – Index of the sample.

  • part ({'train', 'validation', 'test'}, optional) – The data part. Default is 'train'.

  • out (array-like or tuple of (array-like or bool) or None) –

    Array(s) (or e.g. odl element(s)) to which the sample is written. A tuple should be passed, if the dataset returns two or more arrays per sample (i.e. pairs, …). If a tuple element is a bool, it has the following meaning:

    True

    Create a new array and return it.

    False

    Do not return this array, i.e. None is returned.

Returns

sample – E.g. for a pair dataset: (array, None) if out=(True, False).

Return type

[tuple of ] (array-like or None)