KEMBAR78
Add random_split to torch.utils.data.dataset by alykhantejani · Pull Request #4435 · pytorch/pytorch · GitHub
Skip to content

Conversation

@alykhantejani
Copy link
Contributor

Originally requested in torchvision here

This is the implementation @apaszke provided (in a python 2 compatible way)

splits = []
for i in range(len(lengths)):
offset = sum(lengths[:i + 1])
splits.append(Subset(dataset, indices[offset - lengths[i]:offset]))

This comment was marked as off-topic.

This comment was marked as off-topic.

def random_split(dataset, lengths):
"""
Randomply split a dataset into non-overlapping new datasets of given lengths
ds

This comment was marked as off-topic.

This comment was marked as off-topic.

@apaszke
Copy link
Contributor

apaszke commented Jan 2, 2018

@pytorchbot add to whitelist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants