MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / random_split

Function random_split

lib/utils/data/dataset.py:105–118  ·  view source on GitHub ↗

Randomly split a dataset into non-overlapping new datasets of given lengths ds Arguments: dataset (Dataset): Dataset to be split lengths (iterable): lengths of splits to be produced

(dataset, lengths)

Source from the content-addressed store, hash-verified

103
104
105def random_split(dataset, lengths):
106 """
107 Randomly split a dataset into non-overlapping new datasets of given lengths
108 ds
109
110 Arguments:
111 dataset (Dataset): Dataset to be split
112 lengths (iterable): lengths of splits to be produced
113 """
114 if sum(lengths) != len(dataset):
115 raise ValueError("Sum of input lengths does not equal the length of the input dataset!")
116
117 indices = randperm(sum(lengths))
118 return [Subset(dataset, indices[offset - length:offset]) for offset, length in zip(_accumulate(lengths), lengths)]

Callers

nothing calls this directly

Calls 1

SubsetClass · 0.85

Tested by

no test coverage detected