ba256835a4f33d9139a70b6440c3223123132bc8,torchnet/meter/confusionmeter.py,ConfusionMeter,add,#ConfusionMeter#,42

Before Change


        onehot = np.ndim(target) != 1
        assert output.shape[0] == target.shape[0], \
                "number of targets and outputs do not match"
        assert output.shape[1] == self.conf.shape[0], \
                "number of outputs does not match size of confusion matrix"
        assert not onehot or target.shape[1] == output.shape[1], \
                "target should be 1D Tensor or have size of output (one-hot)"
        if onehot:
            assert (target >= 0).all() and (target <= 1).all(), \

After Change


        if np.ndim(predicted) != 1:
            assert predicted.shape[1] == self.k, \
                "number of predictions does not match size of confusion matrix"
            predicted = np.argmax(predicted, 1)
        else:
            assert (predicted.max() < self.k) and (predicted.min() >= 0), \
                "predicted values are not between 1 and k"
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: pytorch/tnt
Commit Name: ba256835a4f33d9139a70b6440c3223123132bc8
Time: 2017-08-24
Author: swetha.tanamala@gmail.com
File Name: torchnet/meter/confusionmeter.py
Class Name: ConfusionMeter
Method Name: add


Project Name: victoresque/pytorch-template
Commit Name: 6027fdf7aa77c038bf533ebcf7b704b1c79c3bc4
Time: 2018-09-16
Author: sunq0313@gmail.com
File Name: model/metric.py
Class Name:
Method Name: my_metric


Project Name: Shawn1993/cnn-text-classification-pytorch
Commit Name: 5c177f3d9a29fc7737bd4734315820d1c11c7e87
Time: 2019-07-17
Author: rriva002@ucr.edu
File Name: cnn_text_classification.py
Class Name: CNNClassifier
Method Name: predict