2019b3cae62bdb7740e93b0820fb25692c955cd6,src/pytools/metrics.py,weighted_categorical_crossentropy,loss,#weighted_categorical_crossentropy#Any#Any#,69

Before Change


        // clip
        y_pred = K.clip(y_pred, K.epsilon(), 1)
        // calc        
        p = y_true*K.log(y_pred)
        loss = p*self.weights
        loss =-K.sum(loss,-1)
//         return loss
        return K.mean(loss)

After Change


    def loss(self, y_true, y_pred):
        """ prepare a loss of the given metric/loss operating on non-bg data """
        yt = y_true.eval()
        ytbg = np.where(yt == 0)
        y_true_fix = K.variable(yt.flat(ytbg))
        y_pred_fix = K.variable(y_pred.eval().flat(ytbg))
        return self.metric(y_true_fix, y_pred_fix)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: adalca/neuron
Commit Name: 2019b3cae62bdb7740e93b0820fb25692c955cd6
Time: 2017-03-16
Author: adalca@mit.edu
File Name: src/pytools/metrics.py
Class Name: weighted_categorical_crossentropy
Method Name: loss


Project Name: analysiscenter/batchflow
Commit Name: ae93d715b1bcd8b58163e73d021b3df810eeaef7
Time: 2019-10-15
Author: 53620809+cdtn@users.noreply.github.com
File Name: batchflow/tests/metrics_test.py
Class Name:
Method Name:


Project Name: SheffieldML/GPy
Commit Name: 0eee4b42d23aae7f4fa861dc8fe5e6bee2c4cd91
Time: 2013-10-18
Author: alan.daniel.saul@gmail.com
File Name: GPy/likelihoods/noise_models/bernoulli_noise.py
Class Name: Bernoulli
Method Name: logpdf_link