72caa3677f5f9cc09ed98324c76454c38a7e8098,lib/metric.py,MaskLogLossMetric,update,#MaskLogLossMetric#,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)
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]
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
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: sony/nnabla-examples
Commit Name: 4f031d76c9a5b1e61080a4be62eee6f1ccd584fa
Time: 2019-05-14
Author: Akio.Hayakawa@sony.com
File Name: speech-synthesis/WaveNet/train.py
Class Name:
Method Name: train
Project Name: explosion/thinc
Commit Name: f2fc17c740d609e7fd9118093f7fad7824d3415e
Time: 2019-06-03
Author: daras.giannhs@gmail.com
File Name: thinc/neural/_classes/multiheaded_attention.py
Class Name: MultiHeadedAttention
Method Name: begin_update