0e7bfac76b97e7630102687f7e6309e00e190091,onmt/translate/translator.py,Translator,_score_target,#Translator#Any#Any#Any#Any#Any#,676
Before Change
memory_lengths=src_lengths,
src_map=src_map)
tgt_pad = self.fields["tgt"].vocab.stoi[inputters.PAD_WORD]
for log_prob, tgt in zip(log_probs, batch.tgt[1:]):
tgt = tgt.unsqueeze(1)
scores = log_prob.gather(1, tgt)
scores.masked_fill_(tgt.eq(tgt_pad), 0)
gold_scores += scores.view(-1)
return gold_scores
def _report_score(self, name, score_total, words_total):
if words_total == 0:
After Change
tgt_pad = self.fields["tgt"].vocab.stoi[inputters.PAD_WORD]
log_probs[:, :, tgt_pad] = 0
gold = batch.tgt[1:].unsqueeze(2)
gold_scores = log_probs.gather(2, gold)
gold_scores = gold_scores.sum(dim=0).view(-1)
return gold_scores
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: OpenNMT/OpenNMT-py
Commit Name: 0e7bfac76b97e7630102687f7e6309e00e190091
Time: 2018-11-13
Author: benzurdopeters@gmail.com
File Name: onmt/translate/translator.py
Class Name: Translator
Method Name: _score_target
Project Name: tensorflow/lattice
Commit Name: 1c75176947730de8322acf6ad996096625e92e3a
Time: 2020-06-15
Author: no-reply@google.com
File Name: tensorflow_lattice/python/rtl_layer.py
Class Name: RTL
Method Name: call
Project Name: ixaxaar/pytorch-dnc
Commit Name: 2026a8939d9ccc3e26ac776db5b4788846fd166c
Time: 2017-12-03
Author: root@ixaxaar.in
File Name: dnc/sparse_memory.py
Class Name: SparseMemory
Method Name: read_from_sparse_memory