Ejemplo n.º 1
0
 def test_categorical_crossentropy(self):
     y_pred = tf.Variable([[1., 0., 1.], [2., 1., 0.]])
     y_true = tf.Variable([[1., MAGIC_NUMBER, 1.], [1., MAGIC_NUMBER, 0.]])
     y_pred_softmax = tf.nn.softmax(y_pred)
     # Truth with Magic number is wrong
     npt.assert_array_almost_equal(categorical_crossentropy(y_true, y_pred_softmax).eval(session=get_session()),
                                   categorical_crossentropy(y_true, y_pred, from_logits=True).eval(
                                       session=get_session()), decimal=3)
Ejemplo n.º 2
0
    def test_categorical_crossentropy(self):
        # Truth with Magic number is wrong
        y_pred = tf.constant([[1., 0., 1.], [2., 1., 0.]])
        y_true = tf.constant([[1., MAGIC_NUMBER, 1.], [1., MAGIC_NUMBER, 0.]])

        y_pred_softmax = tf.nn.softmax(y_pred)

        npt.assert_array_almost_equal(categorical_crossentropy(y_true, y_pred_softmax).numpy(),
                                      categorical_crossentropy(y_true, y_pred, from_logits=True).numpy(), decimal=3)