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

Before Change



    def update(self, labels, preds):
        pred = preds[self.pred.index("mask_preds")].asnumpy().reshape(-1)
        weights = preds[self.pred.index("mask_weights")].asnumpy().reshape(-1)
        labels = preds[self.pred.index("mask_labels")].asnumpy().reshape(-1)
        valid_inds = np.where(weights>0)[0]

        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

After Change


        // label (b, p)
        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: 4

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: wenwei202/iss-rnns
Commit Name: d41aa4d2c995796e3978a83052515572f402fa5f
Time: 2017-01-21
Author: seominjoon@gmail.com
File Name: basic/model.py
Class Name: Model
Method Name: _build_loss


Project Name: Esri/raster-functions
Commit Name: e698c1f1bbab1691152743a4516cf574c406e391
Time: 2015-02-11
Author: jwasilkowski@esri.com
File Name: functions/LinearSpectralUnmixing.py
Class Name: LinearSpectralUnmixing
Method Name: updatePixels


Project Name: GPflow/GPflow
Commit Name: 20a3f495691b621165cc7fcce1bca917516edf9a
Time: 2017-02-03
Author: mrksr@users.noreply.github.com
File Name: GPflow/ekernels.py
Class Name: RBF
Method Name: eKzxKxz