Skip to content

Instantly share code, notes, and snippets.

@ciela
Last active December 21, 2018 12:19
Show Gist options
  • Save ciela/6fcd0133db54ceb3fb6042e93a9b5de5 to your computer and use it in GitHub Desktop.
Save ciela/6fcd0133db54ceb3fb6042e93a9b5de5 to your computer and use it in GitHub Desktop.
Count labels using collection package
import collection
log.debug(len(train_loader))
labels = []
for i, data in enumerate(train_loader):
_, label = data
labels.append(label.item())
labels_counter = collections.Counter(labels)
log.debug(labels_counter)
labels = []
log.debug(len(val_loader))
for i, data in enumerate(val_loader):
_, label = data
labels.append(label.item())
labels_counter = collections.Counter(labels)
log.debug(labels_counter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment