Beam.py 文件源码

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

项目:attention-is-all-you-need-pytorch 作者: jadore801120 项目源码 文件源码
def __init__(self, size, cuda=False):

        self.size = size
        self.done = False

        self.tt = torch.cuda if cuda else torch

        # The score for each translation on the beam.
        self.scores = self.tt.FloatTensor(size).zero_()
        self.all_scores = []

        # The backpointers at each time-step.
        self.prev_ks = []

        # The outputs at each time-step.
        self.next_ys = [self.tt.LongTensor(size).fill_(Constants.PAD)]
        self.next_ys[0][0] = Constants.BOS
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号