torch choice

1
2
3
perm = torch.randperm(tensor.size(0))
idx = perm[:k]
samples = tensor[idx]