텐서플로우:: 작전:: 역양자화

#include <array_ops.h>

'입력' 텐서를 float Tensor역양자화합니다 .

요약

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

'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() range(T) = numeric_limits ::max() - numeric_limits ::min() 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의 역양자화는 각 값을 가져와 부동 소수점으로 변환하고 6/255를 곱합니다. 양자화 유형이 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 인 경우 각 입력 값에 scale_factor를 곱하여 역양자화를 수행합니다. (따라서 0의 입력은 항상 0.0으로 매핑됩니다.)

scale_factor는 다음 알고리즘을 사용하여 QuantizeAndDequantize{V2|V3}QuantizeV2 와 호환되는 방식으로 min_range , max_rangenarrow_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);

인수:

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

보고:

생성자와 소멸자

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)
Mode (StringPiece x)
NarrowRange (bool x)

구조체

텐서플로우:: ops:: 역양자화:: Attrs

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 Mode(
  StringPiece x
)

좁은 범위

Attrs NarrowRange(
  bool x
)