def safe_exp(v):
    v = np.array(v)
    if np.any(v > 500):
        warn('Warning: exp overflowing!', RuntimeWarning)
    return np.exp(np.minimum(v, 500))
Safely apply np.exp.  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_exp