(preds, targets, name=None)
Computes binary cross entropy given `preds`.

    For brevity, let `x = `, `z = targets`.  The logistic loss is

        loss(x, z) = - sum_i (x[i] * log(z[i]) + (1 - x[i]) * log(1 - z[i]))

    Args:
        preds: A `Tensor` of type `float32` or `float64`.
        targets: A `Tensor` of the same type and shape as `preds`.
Computes binary cross entropy given `preds`.
Computes binary cross entropy given preds .
def binary_cross_entropy(preds, targets, name=None):
    """Computes binary cross entropy given `preds`.

    For brevity, let `x = `, `z = targets`.  The logistic loss is

        loss(x, z) = - sum_i (x[i] * log(z[i]) + (1 - x[i]) * log(1 - z[i]))

    Args:
        preds: A `Tensor` of type `float32` or `float64`.
        targets: A `Tensor` of the same type and shape as `preds`.
    """
    eps = 1e-12
    with ops.op_scope([preds, targets], name, "bce_loss") as name:
        preds = ops.convert_to_tensor(preds, name="preds")
        targets = ops.convert_to_tensor(targets, name="targets")
        return tf.reduce_mean(-(targets * tf.log(preds + eps) +
                              (1. - targets) * tf.log(1. - preds + eps)))
def binary_cross_entropy ( preds , targets , name = None ) : eps = 1e-12 with ops . op_scope ( [ preds , targets ] , name , "bce_loss" ) as name : preds = ops . convert_to_tensor ( preds , name = "preds" ) targets = ops . convert_to_tensor ( targets , name = "targets" ) return tf . reduce_mean ( - ( targets * tf . log ( preds + eps ) + ( 1. - targets ) * tf . log ( 1. - preds + eps ) ) )