017517d06144919555f9d991f13639ee4cc4babb,onmt/modules/CopyGenerator.py,CopyGeneratorLossCompute,compute_loss,#CopyGeneratorLossCompute#Any#Any#Any#Any#Any#,105

Before Change


        target_data = target.data.clone()
        for i in range(target_data.size(0)):
            if target_data[i] == 0 and align.data[i] != 0:
                target_data[i] = align.data[i] + len(self.tgt_vocab)

        // Coverage loss term.
        loss_data = loss.data.clone()

After Change


        // tgt[i] = align[i] + len(tgt_vocab)
        // for i such that tgt[i] == 0 and align[i] != 0
        target_data = target.data.clone()
        correct_mask = target_data.eq(0) * align.data.ne(0)
        correct_copy = (align.data + len(self.tgt_vocab)) * correct_mask.long()
        target_data = target_data + correct_copy

        // Coverage loss term.
        loss_data = loss.data.clone()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 3

Instances


Project Name: OpenNMT/OpenNMT-py
Commit Name: 017517d06144919555f9d991f13639ee4cc4babb
Time: 2017-11-17
Author: pltrdy@gmail.com
File Name: onmt/modules/CopyGenerator.py
Class Name: CopyGeneratorLossCompute
Method Name: compute_loss


Project Name: OpenNMT/OpenNMT-py
Commit Name: a5763a81a2180e1d99f678d31f0fb7b9c26f4dff
Time: 2017-11-17
Author: pltrdy@gmail.com
File Name: onmt/modules/CopyGenerator.py
Class Name: CopyGeneratorLossCompute
Method Name: compute_loss


Project Name: pytorch/fairseq
Commit Name: 831b6b6e7f16a14ca8cd5a4d998a05a974a1d2b2
Time: 2019-11-19
Author: namangoyal@devfair0110.h2.fair
File Name: fairseq/models/bart/hub_interface.py
Class Name: BARTHubInterface
Method Name: extract_features