텐서플로우:: 연산:: 양자화 해제

#include <array_ops.h>

'입력' 텐서를 float 또는 bfloat16 텐서 로 역양자화합니다 .

요약

[min_range, max_range]는 출력 범위를 지정하는 스칼라 부동 소수점 값입니다. 'mode' 속성은 부동 소수점 값을 양자화된 값으로 변환하는 데 사용되는 계산 방식을 정확하게 제어합니다.

'MIN_COMBINED' 모드에서는 텐서의 각 값이 다음과 같은 과정을 거칩니다.

if T == qint8: in[i] += (range(T) + 1)/ 2.0
out[i] = min_range + (in[i]* (max_range - min_range) / range(T))
여기서 range(T) = numeric_limits ::max() - numeric_limits ::min()

MIN_COMBINED 모드 예시

입력이 QuantizedRelu6 에서 오는 경우 출력 유형은 quint8(범위 0-255)이지만 QuantizedRelu6 의 가능한 범위는 0-6입니다. 따라서 min_range와 max_range 값은 각각 0.0과 6.0입니다. quint8에 대한 역양자화는 각 값을 float으로 캐스팅한 후 6/255를 곱합니다. quantizedtype이 qint8인 경우, 캐스팅 전에 각 값에 128을 추가로 더합니다.

모드가 'MIN_FIRST'인 경우 이 방식이 사용됩니다.

num_discrete_values = 1 << (# of bits in T)
range_adjust = num_discrete_values / (num_discrete_values - 1)
range = (range_max - range_min) * range_adjust
range_scale = range / num_discrete_values
const double offset_input = static_cast(input) - lowest_quantized;
result = range_min + ((input - numeric_limits::min()) * range_scale)

모드가 SCALED 인 경우, 각 입력 값에 스케일링 계수를 곱하여 역양자화가 수행됩니다. (따라서 입력값이 0이면 항상 0.0으로 매핑됩니다.)

스케일링 팩터는 QuantizeAndDequantize{V2|V3} 및 QuantizeV2 와 호환되는 방식으로 min_range , max_range 및 narrow_range 로부터 다음 알고리즘을 사용하여 결정됩니다.

  

  const int min_expected_T = std::numeric_limits::min() +
    (narrow_range ? 1 : 0);
  const int max_expected_T = std::numeric_limits::max();
  const float max_expected_T = std::numeric_limits::max();

  const float scale_factor =
    (std::numeric_limits::min() == 0) ? (max_range / max_expected_T)
                                         : std::max(min_range / min_expected_T,
                                                    max_range / max_expected_T);

논거:

  • 범위: Scope 객체
  • min_range: 입력에 대해 생성될 수 있는 최소 스칼라 값입니다.
  • max_range: 입력에 대해 생성될 수 있는 최대 스칼라 값입니다.

선택적 속성( Attrs 참조):

  • dtype: 출력 텐서의 유형입니다. 현재 Dequantize는 float 및 bfloat16을 지원합니다. 'dtype'이 'bfloat16'인 경우 'MIN_COMBINED' 모드만 지원합니다.

보고:

생성자와 소멸자

Dequantize (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input min_range, :: tensorflow::Input max_range)
Dequantize (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input min_range, :: tensorflow::Input max_range, const Dequantize::Attrs & attrs)

공개 속성

operation
output

공공 기능

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

공개 정적 함수

Axis (int64 x)
Dtype (DataType x)
Mode (StringPiece x)
NarrowRange (bool x)

구조

텐서플로우:: 연산:: 양자화 해제:: 속성

Dequantize 에 대한 선택적 속성 설정기입니다.

공개 속성

작업

Operation operation

산출

::tensorflow::Output output

공공 기능

역양자화

 Dequantize(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input min_range,
  ::tensorflow::Input max_range
)

역양자화

 Dequantize(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input min_range,
  ::tensorflow::Input max_range,
  const Dequantize::Attrs & attrs
)

마디

::tensorflow::Node * node() const 

연산자::텐서플로우::입력

 operator::tensorflow::Input() const 

연산자::텐서플로우::출력

 operator::tensorflow::Output() const 

공개 정적 함수

중심선

Attrs Axis(
  int64 x
)

디타입

Attrs Dtype(
  DataType x
)

방법

Attrs Mode(
  StringPiece x
)

내로우 레인지

Attrs NarrowRange(
  bool x
)