Skip to content

Instantly share code, notes, and snippets.

@tachim
Created February 16, 2016 05:03
Show Gist options
  • Save tachim/ca6f1d4ebdede99c84a7 to your computer and use it in GitHub Desktop.
Save tachim/ca6f1d4ebdede99c84a7 to your computer and use it in GitHub Desktop.
def soft_threshold(x, t):
x = x.copy()
x[np.where(np.abs(x) < t)] = 0 x[np.where(x > 0)] -= t
x[np.where(x < 0)] += t
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment