Skip to content

Commit

Permalink
Adds soft rectification function
Browse files Browse the repository at this point in the history
  • Loading branch information
Niru Maheswaranathan committed Sep 7, 2015
1 parent 8f8bb14 commit 85d16f8
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion jetpack/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
from scipy.ndimage.filters import gaussian_filter1d

__all__ = ['peakdet', 'smooth', 'norms', 'sfthr', 'sq', 'arr']
__all__ = ['peakdet', 'smooth', 'norms', 'sfthr', 'sfrct', 'sq', 'arr']


def peakdet(v, delta, x=None):
Expand Down Expand Up @@ -182,6 +182,30 @@ def sfthr(x, threshold):
return np.sign(x) * np.maximum(np.abs(x) - threshold, 0)


def sfrct(x, threshold):
"""
Soft rectification function
y = log(1 + exp(x - threshold))
Parameters
----------
x : array_like
The input array to the soft thresholding function
threshold : float
The threshold of the function
Returns
-------
y : array_like
The output of the soft thresholding function
"""

return np.log1p(np.exp(x - threshold))


def sq(x):
"""
Reshape vector to a square image
Expand Down

0 comments on commit 85d16f8

Please sign in to comment.