tensorflow:: ops:: Dequantize

#include <array_ops.h>

「input」テンソルを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に対するDequantizeでは、各値を取得し、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にマッピングされます。)

スケーリング係数は、以下のアルゴリズムを使用して、 min_range 、 max_range 、 narrow_rangeから、 QuantizeAndDequantize{V2|V3}およびQuantizeV2と互換性のある方法で決定されます。

  

  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: 入力に対して生成可能な最大スカラー値。

オプション属性( Attrs参照):

  • dtype: 出力テンソルの型。現在、 Dequantizeはfloatとbfloat16をサポートしています。dtypeがbfloat16の場合、MIN_COMBINEDモードのみがサポートされます。

返品:

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

公開属性

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)

構造

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 

operator::tensorflow::Input

 operator::tensorflow::Input() const 

operator::tensorflow::Output

 operator::tensorflow::Output() const 

パブリック静的関数

軸

Attrs Axis(
  int64 x
)

データ型

Attrs Dtype(
  DataType x
)

モード

Attrs Mode(
  StringPiece x
)

狭い範囲

Attrs NarrowRange(
  bool x
)