def sigmoid(x, out): if out is not x: out[:] = x np.negative(out, out) np.exp(out, out) out += 1 np.reciprocal(out, out) return out