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

Before Change


            assert (target.sum(1) == 1).all(), \
                    "multi-label setting is not supported"
 
        pred = output.argmax(1)
        for i,n in enumerate(pred):
            pos = onehot and target[i].argmax(0) or int(target[i])
            self.conf[pos][n] += 1

    def value(self):
        if self.normalized:
            conf = self.conf.astype(np.float32)
            return conf / conf.sum(1).clip(min=1e-12)[:,None]

After Change


        x = predicted + self.k * target
        bincount_2d = np.bincount(x.astype(np.int32),
                                  minlength=self.k ** 2)
        assert bincount_2d.size == self.k ** 2
        conf = bincount_2d.reshape((self.k, self.k))

        self.conf += conf
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

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: osmr/imgclsmob
Commit Name: 6058fa28029c4cb4934cae5da594c828a1abcca1
Time: 2021-02-15
Author: osemery@gmail.com
File Name: pytorch/pytorchcv/models/others/_espnet.py
Class Name: ESPNet
Method Name: __init__


Project Name: scikit-learn/scikit-learn
Commit Name: 4f496868c6aa7f50db99229847285efbe50040c2
Time: 2020-08-03
Author: 34657725+jeremiedbb@users.noreply.github.com
File Name: sklearn/cluster/tests/test_k_means.py
Class Name:
Method Name: test_n_init