72caa3677f5f9cc09ed98324c76454c38a7e8098,lib/metric.py,MaskLogLossMetric,update,#MaskLogLossMetric#Any#Any#,137

Before Change



        labels = labels[valid_inds]
        // Compute the logarithm
        pred = pred[valid_inds]+ 1e-14
        // Compute cross entropy
        loss = -np.log(pred)*labels - np.log(1-pred)*(1-labels)
        loss = np.sum(loss)
        // Update metric
        self.sum_metric += loss
        self.num_inst += len(valid_inds)

After Change


        label = label.asnumpy().astype("int32").reshape((-1))
        // pred (b, c, p) or (b, c, h, w) --> (b, p, c) --> (b*p, c)
        pred = pred.asnumpy().reshape((pred.shape[0], pred.shape[1], -1)).transpose((0, 2, 1))
        pred = pred.reshape((label.shape[0], -1))

        // filter with keep_inds
        keep_inds = np.where(label != -1)[0]
        label = label[keep_inds]
        cls = pred[keep_inds, label]

        cls += 1e-14
        cls_loss = -1 * np.log(cls)
        cls_loss = np.sum(cls_loss)
        self.sum_metric += cls_loss
        self.num_inst += label.shape[0]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: mahyarnajibi/SNIPER
Commit Name: 72caa3677f5f9cc09ed98324c76454c38a7e8098
Time: 2018-06-04
Author: mahyarnajibi@gmail.com
File Name: lib/metric.py
Class Name: MaskLogLossMetric
Method Name: update


Project Name: yzhao062/pyod
Commit Name: 4638cbc8d106450f1e821750b4af0ea88408a6ee
Time: 2018-03-03
Author: yuezhao@cs.toronto.edu
File Name: models/hbos.py
Class Name: Hbos
Method Name: decision_function


Project Name: yzhao062/pyod
Commit Name: 4638cbc8d106450f1e821750b4af0ea88408a6ee
Time: 2018-03-03
Author: yuezhao@cs.toronto.edu
File Name: models/hbos.py
Class Name: Hbos
Method Name: fit