87a61ad92a9e0129e5c81c242f0ea96d77e6b0af,allennlp/training/metrics/attachment_scores.py,AttachmentScores,__call__,#AttachmentScores#Any#Any#Any#Any#Any#,36

Before Change


        self._total_words += correct_indices.numel() - (~mask).sum()

        if is_distributed():
            _total_sentences = torch.tensor(self._total_sentences).to(device)
            _total_words = torch.tensor(self._total_words).to(device)
            dist.all_reduce(_total_sentences, op=dist.ReduceOp.SUM)
            dist.all_reduce(_total_words, op=dist.ReduceOp.SUM)
            self._total_sentences = _total_sentences.item()
            self._total_words = _total_words.item()

    def get_metric(
        self, reset: bool = False, cuda_device: Union[int, torch.device] = torch.device("cpu"),

After Change


            dist.all_reduce(unlabeled_exact_match, op=dist.ReduceOp.SUM)
            dist.all_reduce(correct_labels_and_indices, op=dist.ReduceOp.SUM)
            dist.all_reduce(labeled_exact_match, op=dist.ReduceOp.SUM)
            total_sentences = torch.tensor(total_sentences).to(device)
            total_words = torch.tensor(total_words).to(device)
            dist.all_reduce(total_sentences, op=dist.ReduceOp.SUM)
            dist.all_reduce(total_words, op=dist.ReduceOp.SUM)
            total_sentences = total_sentences.item()
            total_words = total_words.item()

        self._unlabeled_correct += correct_indices.sum()
        self._exact_unlabeled_correct += unlabeled_exact_match.sum()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: allenai/allennlp
Commit Name: 87a61ad92a9e0129e5c81c242f0ea96d77e6b0af
Time: 2020-08-19
Author: akshita23bhagia@gmail.com
File Name: allennlp/training/metrics/attachment_scores.py
Class Name: AttachmentScores
Method Name: __call__


Project Name: kengz/SLM-Lab
Commit Name: 2381a50a70559340a0335288d648b4bb9a675588
Time: 2018-06-12
Author: kengzwl@gmail.com
File Name: slm_lab/agent/algorithm/dqn.py
Class Name: HydraDQN
Method Name: train


Project Name: allenai/allennlp
Commit Name: 0a456a7582da2ab4271756d7775bba84a75c8c0d
Time: 2020-08-17
Author: eladsegal@users.noreply.github.com
File Name: allennlp/training/metrics/categorical_accuracy.py
Class Name: CategoricalAccuracy
Method Name: __call__