def relu_der(x, alpha=0):
    """
    Rectified Linear Unit Derivative.
    
    If alpha is between 0 and 1, the function performs leaky relu.
    alpha values are commonly between 0.1 and 0.3 for leaky relu.
    
    Note: relu derivative is technically undefined at x=0, but
    tensorflow.nn.relu uses 0 for this special case, so that's what
    I do here
    
    If alpha != 0, then derivative is leaky relu
    
    Parameters
    ----------
    x : numpy array
        Values to be activated.
    alpha : float, optional
        The scale factor for the linear unit.
        Typical values are between 0.1 and 0.3.
        The default is 0.1.

    Returns
    -------
    dz : numpy array
        The derivative of the activated values.

    """
    dZ = x.copy()
    dZ[x <= 0] = alpha
    dZ[x > 0] = 1
    return dZ