def test_balanced_categorical_crossentropy():

    samples = (2, )
    img_dim = (3, 3)
    num_classes = 5

    y_true_n = np.random.randint(0, num_classes, samples + img_dim)
    y_true_n = dv.one_hot(y_true_n, num_classes)

    y_true = K.variable(y_true_n)

    y_pred_n = np.random.random(samples + img_dim + (num_classes, )).astype(
        K.floatx())
    y_pred = K.variable(y_pred_n)
    y_pred = softmax(y_pred)

    loss = dv.tf.balanced_categorical_crossentropy(
        y_true, y_pred).eval(session=K.get_session())
    print(loss)
Esempio n. 2
0
def out_adapt(x, relabel_LVOT, target=adapt_size, n=cg.num_classes):
    return dv.one_hot(out_adapt_raw(x, relabel_LVOT, target), n)
Esempio n. 3
0
 def out_adapt(self, x, target=cg.dim):
     return dv.one_hot(self.out_adapt_raw(x, target), cg.num_classes)