TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tfa.activations.hardshrink

View source on GitHub

Hard shrink function.

tfa.activations.hardshrink(
    x,
    lower=-1.0,
    upper=1.0
)

Computes hard shrink function: x if x < lower or x > upper else 0.

Args:

  • x: A Tensor. Must be one of the following types: float16, float32, float64.
  • lower: float, lower bound for setting values to zeros.
  • upper: float, upper bound for setting values to zeros.

Returns:

A Tensor. Has the same type as x.