def sigmoid(x): if x >= 0: return math.exp(-np.logaddexp(0, -x)) else: return math.exp(x - np.logaddexp(x, 0))