def exp_safe(x):
 if (type(x) is np.ndarray):
  return np.exp(np.clip(x, exp_safe_MIN, exp_safe_MAX))
 else:
  return math.exp(x)

def exp_safe ( x ) : if ( type ( x ) is np . ndarray ) : return np . exp ( np . clip ( x , exp_safe_MIN , exp_safe_MAX ) ) else : return math . exp ( x )
compute exponentials which safely underflow to zero .