MCPcopy Create free account
hub / github.com/pytorch/tutorials / select_n_random

Function select_n_random

beginner_source/introyt/tensorboardyt_tutorial.py:272–276  ·  view source on GitHub ↗
(data, labels, n=100)

Source from the content-addressed store, hash-verified

270
271# Select a random subset of data and corresponding labels
272def select_n_random(data, labels, n=100):
273 assert len(data) == len(labels)
274
275 perm = torch.randperm(len(data))
276 return data[perm][:n], labels[perm][:n]
277
278# Extract a random subset of data
279images, labels = select_n_random(training_set.data, training_set.targets)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected