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
Beam.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录