(preds, targets, offset=1e-10, name=None)
Computes binary cross entropy given `preds`.

    For brevity, let `x = preds`, `z = targets`. The logistic loss is
        loss(x, z) = - sum_i (x[i] * log(z[i]) + (1 - x[i]) * log(1 - z[i]))
Computes binary cross entropy given `preds`.
Computes binary cross entropy given preds .
def binary_crossentropy(preds, targets, offset=1e-10, name=None):
    """Computes binary cross entropy given `preds`.

    For brevity, let `x = preds`, `z = targets`. The logistic loss is
        loss(x, z) = - sum_i (x[i] * log(z[i]) + (1 - x[i]) * log(1 - z[i]))
    """
    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 + offset) +
                                (1. - targets) * tf.log(1. - preds + offset)))
def binary_crossentropy ( preds , targets , offset = 1e-10 , name = None ) : 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 + offset ) + ( 1. - targets ) * tf . log ( 1. - preds + offset ) ) )