Random sampling from pixels of an image

Hi,

You can use torch.utils.data.random_split:

import torch
from torch.utils.data import random_split

data = torch.arange(0, 1000*94).reshape((1000, 1, 94))

train, test= random_split(data, [int(len(data)*0.9), int(len(data)*0.1)])

print(len(train))  # 900
print(len(test))  # 100

Bests

1 Like