a guest Nov 22nd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- def logsig(x):
- """Compute the log-sigmoid function component-wise."""
- out = np.zeros_like(x)
- idx0 = x < -33
- out[idx0] = x[idx0]
- idx1 = (x >= -33) & (x < -18)
- out[idx1] = x[idx1] - np.exp(x[idx1])
- idx2 = (x >= -18) & (x < 37)
- out[idx2] = -np.log1p(np.exp(-x[idx2]))
- idx3 = x >= 37
- out[idx3] = -np.exp(-x[idx3])
- return out
RAW Paste Data