Skip to main content

soft_shrink

Function soft_shrink 

pub fn soft_shrink<const D: usize>(tensor: Tensor<D>, lambda: f64) -> Tensor<D>
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.