テンソルフロー::作戦::逆量子化

#include <array_ops.h>

「入力」テンソルを float または bfloat16 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 での逆量子化は、各値を取得し、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の場合、逆量子化は各入力値に scaling_factor を乗算することによって実行されます。 (したがって、0 の入力は常に 0.0 にマップされます)。

scaling_factor は、次のアルゴリズムを使用してQuantizeAndDequantize{V2|V3}およびQuantizeV2と互換性のある方法でmin_rangemax_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);

引数:

  • スコープ:スコープオブジェクト
  • 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 

演算子::tensorflow::入力

 operator::tensorflow::Input() const 

演算子::tensorflow::出力

 operator::tensorflow::Output() const 

パブリック静的関数

Attrs Axis(
  int64 x
)

Dタイプ

Attrs Dtype(
  DataType x
)

モード

Attrs Mode(
  StringPiece x
)

狭い範囲

Attrs NarrowRange(
  bool x
)