(data, bsz)
| 83 | # batch processing. |
| 84 | |
| 85 | def 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 | |
| 94 | eval_batch_size = 10 |
| 95 | train_data = batchify(corpus.train, args.batch_size) |