Guest User

Untitled

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