def cross_entropy_binary_der(y_true, y_pred, delta=1e-9):
    """
    The derivative of binary cross-entropy.
    
    The derivative of the cross-entropy function (i.e. derivative of the
    error output) with respect to the predicted value (y_pred).
    The value inside the brackets is the value of the derivative of the
    log-likelihood for a bernoulli distribution. The negative is added
    because of our definition of cross-entropy.

    Parameters
    ----------
    y_true : numpy array
        True, observed values. The outcome of an event (where 1 == success).
    y_pred : numpy array
        The predicted success probabilities.
    delta : float, optional
        A small, positive constant to offset predicted probabilities that are
        zero, which avoids log(0). Is ignored if delta = 0.
        The default is 1e-9.

    Returns
    -------
    float
        The derivative of binary cross-entropy.

    """
    # Compute the cross-entropy cost
    # To avoid log(0) errors (not necessary in most cases)
    ypred = y_pred.copy()
    if delta != 0:
        ypred[ypred <= delta] = delta
        ypred[ypred >= 1-delta] = 1-delta
    
    return -((y_true/ypred) - (1-y_true)/(1-ypred))