0a456a7582da2ab4271756d7775bba84a75c8c0d,allennlp/training/metrics/categorical_accuracy.py,CategoricalAccuracy,__call__,#CategoricalAccuracy#Any#Any#Any#,35

Before Change


            _correct_count = torch.tensor(self.correct_count).to(device)
            _total_count = torch.tensor(self.total_count).to(device)
            dist.all_reduce(_correct_count, op=dist.ReduceOp.SUM)
            dist.all_reduce(_total_count, op=dist.ReduceOp.SUM)
            self.correct_count = _correct_count.item()
            self.total_count = _total_count.item()

    def get_metric(self, reset: bool = False):

After Change


            correct *= mask.view(-1, 1)
            total_count_diff = mask.sum()
        else:
            total_count_diff = torch.tensor(gold_labels.numel())
        correct_count_diff = correct.sum()

        if is_distributed():
            dist.all_reduce(correct_count_diff, op=dist.ReduceOp.SUM)
            dist.all_reduce(total_count_diff, op=dist.ReduceOp.SUM)
            self.correct_count += correct_count_diff.item()
            self.total_count += total_count_diff.item()
        else:
            self.correct_count += correct_count_diff
            self.total_count += total_count_diff
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


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__


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: allenai/allennlp
Commit Name: b792c834b5f70122c7c296ded7c97ac974cda6f4
Time: 2020-10-23
Author: hgtcwl@foxmail.com
File Name: allennlp/training/metrics/categorical_accuracy.py
Class Name: CategoricalAccuracy
Method Name: __call__