コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
テンソルフロー::作戦::逆量子化
#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_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);
引数:
- スコープ:スコープオブジェクト
- min_range: 入力に対して生成される可能性のある最小スカラー値。
- max_range: 入力に対して生成される可能性のある最大スカラー値。
オプションの属性 ( Attrs
を参照):
- dtype: 出力テンソルのタイプ。現在、 Dequantize はfloat と bfloat16 をサポートしています。 「dtype」が「bfloat16」の場合、「MIN_COMBINED」モードのみがサポートされます。
戻り値:
パブリック属性
公共機能
ノード
::tensorflow::Node * node() const
operator::tensorflow::Input() const
演算子::tensorflow::出力
operator::tensorflow::Output() const
パブリック静的関数
Dタイプ
Attrs Dtype(
DataType x
)
モード
Attrs Mode(
StringPiece x
)
狭い範囲
Attrs NarrowRange(
bool x
)
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-27 UTC。
[null,null,["最終更新日 2025-07-27 UTC。"],[],[],null,["# tensorflow::ops::Dequantize Class Reference\n\ntensorflow::ops::Dequantize\n===========================\n\n`#include \u003carray_ops.h\u003e`\n\n[Dequantize](/versions/r2.3/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize) the 'input' tensor into a float or bfloat16 [Tensor](/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor).\n\nSummary\n-------\n\n\\[min_range, max_range\\] are scalar floats that specify the range for the output. The 'mode' attribute controls exactly which calculations are used to convert the float values to their quantized equivalents.\n\nIn 'MIN_COMBINED' mode, each value of the tensor will undergo the following:\n\n\u003cbr /\u003e\n\n```transact-sql\nif T == qint8: in[i] += (range(T) + 1)/ 2.0\nout[i] = min_range + (in[i]* (max_range - min_range) / range(T))\n```\nhere `range(T) = numeric_limits`::max() - numeric_limits::min()\n\n\u003cbr /\u003e\n\n\n*MIN_COMBINED Mode Example*\n\nIf the input comes from a [QuantizedRelu6](/versions/r2.3/api_docs/cc/class/tensorflow/ops/quantized-relu6#classtensorflow_1_1ops_1_1_quantized_relu6), the output type is quint8 (range of 0-255) but the possible range of [QuantizedRelu6](/versions/r2.3/api_docs/cc/class/tensorflow/ops/quantized-relu6#classtensorflow_1_1ops_1_1_quantized_relu6) is 0-6. The min_range and max_range values are therefore 0.0 and 6.0. [Dequantize](/versions/r2.3/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize) on quint8 will take each value, cast to float, and multiply by 6 / 255. Note that if quantizedtype is qint8, the operation will additionally add each value by 128 prior to casting.\n\nIf the mode is 'MIN_FIRST', then this approach is used:\n\n\n```gdscript\nnum_discrete_values = 1 \u003c\u003c (# of bits in T)\nrange_adjust = num_discrete_values / (num_discrete_values - 1)\nrange = (range_max - range_min) * range_adjust\nrange_scale = range / num_discrete_values\nconst double offset_input = static_cast(input) - lowest_quantized;\nresult = range_min + ((input - numeric_limits::min()) * range_scale)\n```\n\n\u003cbr /\u003e\n\nIf the mode is `SCALED`, dequantization is performed by multiplying each input value by a scaling_factor. (Thus an input of 0 always maps to 0.0).\n\nThe scaling_factor is determined from `min_range`, `max_range`, and `narrow_range` in a way that is compatible with `QuantizeAndDequantize{V2|V3}` and [QuantizeV2](/versions/r2.3/api_docs/cc/class/tensorflow/ops/quantize-v2#classtensorflow_1_1ops_1_1_quantize_v2), using the following algorithm:\n\n\n````gdscript\n \n \n const int min_expected_T = std::numeric_limits::min() +\n (narrow_range ? 1 : 0);\n const int max_expected_T = std::numeric_limits::max();\n const float max_expected_T = std::numeric_limits::max();\n \n \n \n```gdscript\n const float scale_factor =\n (std::numeric_limits::min() == 0) ? (max_range / max_expected_T)\n : std::max(min_range / min_expected_T,\n max_range / max_expected_T);\n```\n\n \n Arguments:\n \n- scope: A /versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope object\n\n \n- min_range: The minimum scalar value possibly produced for the input.\n\n \n- max_range: The maximum scalar value possibly produced for the input.\n\n \n\n Optional attributes (see /versions/r2.3/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs):\n \n- dtype: Type of the output tensor. Currently /versions/r2.3/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize supports float and bfloat16. If 'dtype' is 'bfloat16', it only supports 'MIN_COMBINED' mode.\n\n \n Returns:\n \n- /versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output: The output tensor. \n\n \n \n \n \n \n### Constructors and Destructors\n\n\n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1ace6411557abc00c6e59649720be7d579`(const ::`/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope` & scope, ::`/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input` input, ::`/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input` min_range, ::`/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input` max_range)`\n \n\n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1afb71f46f9e4fc4922578ecd9116ad9b1`(const ::`/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope` & scope, ::`/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input` input, ::`/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input` min_range, ::`/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input` max_range, const `/versions/r2.3/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs` & attrs)`\n \n\n \n \n \n \n \n \n \n### Public attributes\n\n\n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1a917ce29fbec6ef49406db9a374bde9aa\n \n \n \n /versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation\n \n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1a5c4618ae3d058bcd8547217612f8f41e\n \n \n \n `::`/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output\n \n \n \n \n \n \n \n \n### Public functions\n\n\n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1a4bdeb613e4b88880638a67528cbd01f0`() const `\n \n \n \n `::tensorflow::Node *`\n \n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1ab1b62ee39a382d6e124eb62156c05525`() const `\n \n \n \n `\n `\n`\n `\n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1ae01ee2df9b62f7729848ca15ed70e8fc`() const `\n \n \n \n `\n `\n`\n `\n \n \n \n \n \n \n### Public static functions\n\n\n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1ac0b7d9ea267e2c8719f63ff4434b5250`(int64 x)`\n \n \n \n /versions/r2.3/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs\n \n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1aeb2c0e323cdc6f85554c6e03de751730`(DataType x)`\n \n \n \n /versions/r2.3/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs\n \n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1ac9873b34c5c0eb36296e0fe726644fc9`(StringPiece x)`\n \n \n \n /versions/r2.3/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs\n \n \n \n \n \n #classtensorflow_1_1ops_1_1_dequantize_1a4409107547aae6b42715813687850b35`(bool x)`\n \n \n \n /versions/r2.3/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs\n \n \n \n \n \n \n \n \n### Structs\n\n\n \n \n \n \n /versions/r2.3/api_docs/cc/struct/tensorflow/ops/dequantize/attrs\n \n \n Optional attribute setters for /versions/r2.3/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize. \n\n \n \n \n Public attributes\n \n \n### operation\n\n\n \n\n\n```text\nOperation operation\n```\n\n \n\n \n \n \n### output\n\n\n \n\n\n```text\n::tensorflow::Output output\n```\n\n \n\n \n Public functions\n \n \n### Dequantize\n\n\n \n\n\n```gdscript\n Dequantize(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input min_range,\n ::tensorflow::Input max_range\n)\n```\n\n \n\n \n \n \n### Dequantize\n\n\n \n\n\n```gdscript\n Dequantize(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input min_range,\n ::tensorflow::Input max_range,\n const Dequantize::Attrs & attrs\n)\n```\n\n \n\n \n \n \n### node\n\n\n \n\n\n```gdscript\n::tensorflow::Node * node() const \n```\n\n \n\n \n \n \n### operator::tensorflow::Input\n\n\n \n\n\n```gdscript\n operator::tensorflow::Input() const \n```\n\n \n\n \n \n \n### operator::tensorflow::Output\n\n\n \n\n\n```gdscript\n operator::tensorflow::Output() const \n```\n\n \n\n \n Public static functions\n \n \n### Axis\n\n\n \n\n\n```text\nAttrs Axis(\n int64 x\n)\n```\n\n \n\n \n \n \n### Dtype\n\n\n \n\n\n```carbon\nAttrs Dtype(\n DataType x\n)\n```\n\n \n\n \n \n \n### Mode\n\n\n \n\n\n```text\nAttrs Mode(\n StringPiece x\n)\n```\n\n \n\n \n \n \n### NarrowRange\n\n\n \n\n\n```text\nAttrs NarrowRange(\n bool x\n)\n```\n\n \n\n \n\n \n\n \n````"]]