Google I/O에 참여해 주셔서 감사합니다. 주문형 모든 세션 보기 주문형 시청

tensorflow :: ops :: 역 양자화

#include <array_ops.h>

'input'텐서를 부동 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를 곱합니다. 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 이면 각 입력 값에 scaling_factor를 곱하여 역 양자화를 수행합니다. (따라서 0의 입력은 항상 0.0에 매핑됩니다.)

scaling_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)

구조체

tensorflow :: ops :: Dequantize :: 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 

연산자 :: tensorflow :: 입력

 operator::tensorflow::Input() const 

연산자 :: tensorflow :: 출력

 operator::tensorflow::Output() const 

공개 정적 함수

중심선

Attrs Axis(
  int64 x
)

방법

Attrs Mode(
  StringPiece x
)

좁은 범위

Attrs NarrowRange(
  bool x
)