Back to Tensorflow

NormalizeOp

tensorflow/lite/g3doc/api_docs/java/org/tensorflow/lite/support/common/ops/NormalizeOp.html

2.21.05.5 KB
Original Source

public class NormalizeOp

| Known Direct Subclasses

DequantizeOp, QuantizeOp

| DequantizeOp | Dequantizes a TensorBuffer with given zeroPoint and scale. | | QuantizeOp | Quantizes a TensorBuffer with given zeroPoint and scale. |

|

Normalizes a TensorBuffer with given mean and stddev: output = (input - mean) / stddev.

Public Constructors

| | NormalizeOp(float mean, float stddev) Initializes a NormalizeOp.

| | | NormalizeOp(float[] mean, float[] stddev) Initializes a NormalizeOp.

|

Public Methods

| TensorBuffer | apply(TensorBuffer input) Applies the defined normalization on given tensor and returns the result.

|

Inherited Methods

From class java.lang.Object

| boolean | equals(Object arg0) | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |

From interface org.tensorflow.lite.support.common.TensorOperator

| abstract TensorBuffer | apply(TensorBuffer input) |

From interface org.tensorflow.lite.support.common.Operator

| abstract TensorBuffer | apply(TensorBuffer x) Applies an operation on a T object, returning a T object.

|

Public Constructors

public NormalizeOp (float mean, float stddev)

Initializes a NormalizeOp. When being called, it creates a new TensorBuffer, which satisfies:

output = (input - mean) / stddev

In the following two cases, reset mean to 0 and stddev to 1 to bypass the normalization.

  1. Both mean and {code stddev} are 0.
  2. mean is 0 and {stddev} is Infinity.

Note: If mean is set to 0 and stddev is set to 1, no computation will happen, and original input will be directly returned in execution.

Note: The returned TensorBuffer is always a DataType.FLOAT32 tensor at present, except when the input is a DataType.UINT8 tensor, mean is set to 0 and stddev is set to 1, so that the original DataType.UINT8 tensor is returned.

Parameters

| mean | the mean value to be subtracted first. | | stddev | the standard deviation value to divide then. |

Throws

| IllegalArgumentException | if stddev is zero. |

public NormalizeOp (float[] mean, float[] stddev)

Initializes a NormalizeOp. When being called, it creates a new TensorBuffer, which satisfies:

// Pseudo code. [...][i] means a certain element whose channel id is i.
   output[...][i] = (input[...][i] - mean[i]) / stddev[i]

Note: If all values in mean are set to 0 and all stddev are set to 1, no computation will happen, and original input will be directly returned in execution.

Note: The returned TensorBuffer is always a DataType.FLOAT32 tensor at present, except that the input is a DataType.UINT8 tensor, all mean are set to 0 and all stddev are set to 1.

Parameters

| mean | the mean values to be subtracted first for each channel. | | stddev | the standard deviation values to divide then for each channel. |

Throws

| IllegalArgumentException | if any stddev is zero, or mean has different number of elements with stddev, or any of them is empty. |

Public Methods

public TensorBuffer apply (TensorBuffer input)

Applies the defined normalization on given tensor and returns the result.

Note: input is possibly the same instance with the output.

Parameters

| input | input tensor. It may be the same instance with the output. |

Returns
  • output tensor.