def safe_log(v):
    v = np.array(v)
    if np.any(v < -300):
        warn('Warning: exp overflowing!', RuntimeWarning)
    return np.log(np.maximum(v, -300))
Safely apply np.log.  If the input is beyond a "safe" range, it will be clipped and a warning
dataset/ETHPy150Open bbabenko/simple_convnet/simple_convnet/helpers.py/safe_log