ti = tgt_vocab.stoi[sw]
if ti != 0:
scores[:, b, ti] += scores[:, b, offset + i]
scores[:, b, offset + i].fill_(1e-20)
return scores
@staticmethod
def make_text_examples_nfeats_tpl(path, truncate, side):
After Change
offset = len(tgt_vocab)
for b in range(batch.batch_size):
blank = []
fill = []
index = batch.indices.data[b]
src_vocab = src_vocabs[index]
for i in range(1, len(src_vocab)):
sw = src_vocab.itos[i]
ti = tgt_vocab.stoi[sw]
if ti != 0:
blank.append(offset + i)
fill.append(ti)
blank = torch.LongTensor(blank).cuda()
fill = torch.LongTensor(fill).cuda()
scores[:, b].index_add_(1, fill,
scores[:, b].index_select(1, blank))