MCPcopy Create free account
hub / github.com/pytorch/examples / batchify

Function batchify

word_language_model/main.py:85–92  ·  view source on GitHub ↗
(data, bsz)

Source from the content-addressed store, hash-verified

83# batch processing.
84
85def batchify(data, bsz):
86 # Work out how cleanly we can divide the dataset into bsz parts.
87 nbatch = data.size(0) // bsz
88 # Trim off any extra elements that wouldn't cleanly fit (remainders).
89 data = data.narrow(0, 0, nbatch * bsz)
90 # Evenly divide the data across the bsz batches.
91 data = data.view(bsz, -1).t().contiguous()
92 return data.to(device)
93
94eval_batch_size = 10
95train_data = batchify(corpus.train, args.batch_size)

Callers 1

main.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected