main.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:examples 作者: pytorch 项目源码 文件源码
def batchify(data, bsz):
    # Work out how cleanly we can divide the dataset into bsz parts.
    nbatch = data.size(0) // bsz
    # Trim off any extra elements that wouldn't cleanly fit (remainders).
    data = data.narrow(0, 0, nbatch * bsz)
    # Evenly divide the data across the bsz batches.
    data = data.view(bsz, -1).t().contiguous()
    if args.cuda:
        data = data.cuda()
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号