def soft_threshold(X, thresh):
"""Proximal mapping of l1-norm results in soft-thresholding. Therefore, it is required
for the optimisation of the GFGL or IFGL.
Parameters
----------
X : ndarray
input data of arbitrary shape
thresh : float
threshold value
Returns
-------
ndarray soft threshold applied
"""
return (np.absolute(X) - thresh).clip(0) * np.sign(X)
评论列表
文章目录