Shrink

Shrink - 9

Version

  • name: Shrink (GitHub)

  • domain: main

  • since_version: 9

  • function: True

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 9.

Summary

Shrink takes one input data (Tensor<numeric>) 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; If x > lambd, y = x - bias; Otherwise, y = 0.

Function Body

The function definition for this operator.

&lt;
  domain: &#34;&#34;,
  opset_import: [&#34;&#34; : 18]
&gt;
Shrink &lt;bias,lambd&gt;(input) =&gt; (output)
{
   Lambd = Constant &lt;value_float: float = @lambd&gt; ()
   LambdCast = CastLike (Lambd, input)
   Bias = Constant &lt;value_float: float = @bias&gt; ()
   BiasCast = CastLike (Bias, input)
   Zero = Constant &lt;value: tensor = float {0}&gt; ()
   ZeroCast = CastLike (Zero, input)
   NegLmbda = Neg (LambdCast)
   InputLessThanNegLambda = Less (input, NegLmbda)
   InputAddBias = Add (input, BiasCast)
   InputSubBias = Sub (input, BiasCast)
   LambdaLessThanInput = Less (LambdCast, input)
   InputSubBiasOrZero = Where (LambdaLessThanInput, InputSubBias, ZeroCast)
   output = Where (InputLessThanNegLambda, InputAddBias, InputSubBiasOrZero)
}

Attributes

  • bias - FLOAT (default is &#39;0.0&#39;):

    The bias value added to output. Default is 0.

  • lambd - FLOAT (default is &#39;0.5&#39;):

    The lambd value for the Shrink formulation. Default is 0.5.

Inputs

  • input (heterogeneous) - T:

    The input data as Tensor.

Outputs

  • output (heterogeneous) - T:

    The output.

Type Constraints

  • T in ( tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ):

    Constrain input to only numeric types.