Shrink#

  • Domain: ai.onnx

  • Since version: 9

Shrink takes one input data (Tensor ) and produces one Tensor output, having same datatype and shape with input. It has two attributes, lambd and bias. The formula of this operator is: If x lambd, y = x - bias; Otherwise, y = 0.

Inputs

  • input (T): The input data as Tensor.

Outputs

  • output (T): The output.

Attributes

  • bias (float): The bias value added to output. Default is 0.

  • lambd (float): The lambd value for the Shrink formulation. Default is 0.5.

Type Constraints

  • T: Constrain input to only numeric types. Allowed types: tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8).

Examples#

test_cc_shrink_default

Node:
  Shrink(x) -> (y)
Inputs:
  x: shape=(2, 3), dtype=float32
    [[-1. , -0.5, -0.1],
     [ 0.1,  0.5,  1. ]]

Outputs:
  y: shape=(2, 3), dtype=float32
    [[-1.,  0.,  0.],
     [ 0.,  0.,  1.]]

test_cc_shrink_hard

Node:
  Shrink(x) -> (y)
  Attributes:
    lambd = 1.5
Inputs:
  x: shape=(5,), dtype=float32
    [-2., -1.,  0.,  1.,  2.]

Outputs:
  y: shape=(5,), dtype=float32
    [-2.,  0.,  0.,  0.,  2.]

test_cc_shrink_soft

Node:
  Shrink(x) -> (y)
  Attributes:
    bias = 1.5
    lambd = 1.5
Inputs:
  x: shape=(5,), dtype=float32
    [-2., -1.,  0.,  1.,  2.]

Outputs:
  y: shape=(5,), dtype=float32
    [-0.5,  0. ,  0. ,  0. ,  0.5]