c7395e3c5b71f97983129c7c4fddced5ce341147,allennlp/training/metrics/boolean_accuracy.py,BooleanAccuracy,__call__,#BooleanAccuracy#Any#Any#Any#,24

Before Change


        // If you actually passed in Variables here instead of Tensors, this will be a huge memory
        // leak, because it will prevent garbage collection for the computation graph.  We"ll ensure
        // that we"re using tensors here first.
        if isinstance(predictions, Variable):
            predictions = predictions.data
        if isinstance(gold_labels, Variable):
            gold_labels = gold_labels.data
        if isinstance(mask, Variable):
            mask = mask.data

        if mask is not None:
            // We can multiply by the mask up front, because we"re just checking equality below, and
            // this way everything that"s masked will be equal.
            predictions = predictions * mask
            gold_labels = gold_labels * mask

        batch_size = predictions.size(0)
        predictions = predictions.view(batch_size, -1)
        gold_labels = gold_labels.view(batch_size, -1)

        // The .prod() here is functioning as a logical and.
        correct = predictions.eq(gold_labels).prod(dim=1).float()
        count = torch.ones(gold_labels.size(0))
        self._correct_count += correct.sum()
        self._total_count += count.sum()

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

After Change


            A tensor of the same shape as ``predictions``.
        
        // Get the data from the Variables.
        predictions, gold_labels, mask = self.unwrap_to_tensors(predictions, gold_labels, mask)

        if mask is not None:
            // We can multiply by the mask up front, because we"re just checking equality below, and
            // this way everything that"s masked will be equal.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 16

Instances


Project Name: allenai/allennlp
Commit Name: c7395e3c5b71f97983129c7c4fddced5ce341147
Time: 2017-09-26
Author: markn@allenai.org
File Name: allennlp/training/metrics/boolean_accuracy.py
Class Name: BooleanAccuracy
Method Name: __call__


Project Name: allenai/allennlp
Commit Name: c7395e3c5b71f97983129c7c4fddced5ce341147
Time: 2017-09-26
Author: markn@allenai.org
File Name: allennlp/training/metrics/categorical_accuracy.py
Class Name: CategoricalAccuracy
Method Name: __call__


Project Name: allenai/allennlp
Commit Name: c7395e3c5b71f97983129c7c4fddced5ce341147
Time: 2017-09-26
Author: markn@allenai.org
File Name: allennlp/training/metrics/boolean_accuracy.py
Class Name: BooleanAccuracy
Method Name: __call__


Project Name: allenai/allennlp
Commit Name: c7395e3c5b71f97983129c7c4fddced5ce341147
Time: 2017-09-26
Author: markn@allenai.org
File Name: allennlp/training/metrics/f1_measure.py
Class Name: F1Measure
Method Name: __call__