soft_shrink

Function soft_shrink 

pub fn soft_shrink<const D: usize, B>(
    tensor: Tensor<B, D>,
    lambda: f64,
) -> Tensor<B, D>
where B: Backend,
Expand description

Applies the SoftShrink function element-wise.

soft_shrink(x) = x - lambda if x > lambda, x + lambda if x < -lambda, 0 otherwise

ยงArguments

  • lambda: the lambda value for the Soft Shrink formulation. Default is 0.5.