संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
टेंसरफ़्लो:: ऑप्स:: परिमाणीकरण करें
#include <array_ops.h>
'इनपुट' टेंसर को फ्लोट टेंसर में डिक्वांटाइज़ करें ।
सारांश
[min_range, max_range] स्केलर फ़्लोट हैं जो 'इनपुट' डेटा के लिए सीमा निर्दिष्ट करते हैं। 'मोड' विशेषता ठीक से नियंत्रित करती है कि फ्लोट मानों को उनके परिमाणित समकक्षों में परिवर्तित करने के लिए कौन सी गणनाओं का उपयोग किया जाता है।
'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 मोड उदाहरण
यदि इनपुट क्वांटाइज्डरेलु6 से आता है, तो आउटपुट प्रकार क्विंट8 (0-255 की रेंज) है लेकिन क्वांटाइज्डरेलु6 की संभावित रेंज 0-6 है। इसलिए min_range और max_range मान 0.0 और 6.0 हैं। क्विंट8 पर डीक्वेंटाइज प्रत्येक मान लेगा, फ्लोट करने के लिए कास्ट करेगा, और 6/255 से गुणा करेगा। ध्यान दें कि यदि क्वांटाइज्डटाइप क्विंट8 है, तो ऑपरेशन कास्टिंग से पहले प्रत्येक मान को 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
मोड QuantizeAndDequantize{V2|V3}
में प्रयुक्त परिमाणीकरण दृष्टिकोण से मेल खाता है।
यदि मोड SCALED
किया गया है, तो हम आउटपुट प्रकार की पूरी रेंज का उपयोग नहीं करते हैं, समरूपता के लिए न्यूनतम संभव मान को बढ़ाना चुनते हैं (उदाहरण के लिए, आउटपुट रेंज -127 से 127 है, हस्ताक्षरित 8 बिट परिमाणीकरण के लिए -128 से 127 नहीं), ताकि 0.0 0 पर मैप हो जाए।
हम सबसे पहले अपने टेंसर में मानों की श्रेणी ढूंढते हैं। हमारे द्वारा उपयोग की जाने वाली सीमा हमेशा 0 पर केंद्रित होती है, इसलिए हम m को ऐसे पाते हैं
m = max(abs(input_min), abs(input_max))
हमारी इनपुट टेंसर रेंज तब [-m, m]
है।
इसके बाद, हम अपनी निश्चित-बिंदु परिमाणीकरण बकेट, [min_fixed, max_fixed]
चुनते हैं। यदि टी पर हस्ताक्षर किया गया है, तो यह है
num_bits = sizeof(T) * 8
[min_fixed, max_fixed] =
[-(1 << (num_bits - 1) - 1), (1 << (num_bits - 1)) - 1]
अन्यथा, यदि टी अहस्ताक्षरित है, तो निश्चित-बिंदु सीमा है
[min_fixed, max_fixed] = [0, (1 << num_bits) - 1]
इससे हम अपने स्केलिंग फैक्टर की गणना करते हैं:
s = (2 * m) / (max_fixed - min_fixed)
अब हम अपने टेंसर के तत्वों का परिमाण निर्धारित कर सकते हैं:
result = input * s
तर्क:
- स्कोप: एक स्कोप ऑब्जेक्ट
- min_range: इनपुट के लिए संभवतः उत्पन्न न्यूनतम स्केलर मान।
- max_range: इनपुट के लिए संभवतः उत्पादित अधिकतम स्केलर मान।
रिटर्न:
सार्वजनिक स्थैतिक कार्य |
---|
Mode (StringPiece x) | |
सार्वजनिक गुण
सार्वजनिक समारोह
नोड
::tensorflow::Node * node() const
operator::tensorflow::Input() const
ऑपरेटर::टेन्सरफ़्लो::आउटपुट
operator::tensorflow::Output() const
सार्वजनिक स्थैतिक कार्य
तरीका
Attrs Mode(
StringPiece x
)
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[],[],null,["# tensorflow::ops::Dequantize Class Reference\n\ntensorflow::ops::Dequantize\n===========================\n\n`#include \u003carray_ops.h\u003e`\n\n[Dequantize](/versions/r1.15/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize) the 'input' tensor into a float [Tensor](/versions/r1.15/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 'input' data. 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/r1.15/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/r1.15/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/r1.15/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\n\n*SCALED mode Example*\n\n`SCALED` mode matches the quantization approach used in `QuantizeAndDequantize{V2|V3}`.\n\nIf the mode is `SCALED`, we do not use the full range of the output type, choosing to elide the lowest possible value for symmetry (e.g., output range is -127 to 127, not -128 to 127 for signed 8 bit quantization), so that 0.0 maps to 0.\n\nWe first find the range of values in our tensor. The range we use is always centered on 0, so we find m such that \n\n```scdoc\n m = max(abs(input_min), abs(input_max))\n```\n\n\u003cbr /\u003e\n\nOur input tensor range is then `[-m, m]`.\n\nNext, we choose our fixed-point quantization buckets, `[min_fixed, max_fixed]`. If T is signed, this is \n\n```scdoc\n num_bits = sizeof(T) * 8\n [min_fixed, max_fixed] =\n [-(1 \u003c\u003c (num_bits - 1) - 1), (1 \u003c\u003c (num_bits - 1)) - 1]\n```\n\n\u003cbr /\u003e\n\nOtherwise, if T is unsigned, the fixed-point range is \n\n```scdoc\n [min_fixed, max_fixed] = [0, (1 \u003c\u003c num_bits) - 1]\n```\n\n\u003cbr /\u003e\n\nFrom this we compute our scaling factor, s: \n\n```scdoc\n s = (2 * m) / (max_fixed - min_fixed)\n```\n\n\u003cbr /\u003e\n\nNow we can dequantize the elements of our tensor: \n\n```scdoc\nresult = input * s\n```\n\n\u003cbr /\u003e\n\nArguments:\n\n- scope: A [Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- min_range: The minimum scalar value possibly produced for the input.\n- max_range: The maximum scalar value possibly produced for the input.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): The output tensor.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [Dequantize](#classtensorflow_1_1ops_1_1_dequantize_1ace6411557abc00c6e59649720be7d579)`(const ::`[tensorflow::Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` min_range, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` max_range)` ||\n| [Dequantize](#classtensorflow_1_1ops_1_1_dequantize_1afb71f46f9e4fc4922578ecd9116ad9b1)`(const ::`[tensorflow::Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` min_range, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` max_range, const `[Dequantize::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_dequantize_1a917ce29fbec6ef49406db9a374bde9aa) | [Operation](/versions/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_dequantize_1a5c4618ae3d058bcd8547217612f8f41e) | `::`[tensorflow::Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_dequantize_1a4bdeb613e4b88880638a67528cbd01f0)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_dequantize_1ab1b62ee39a382d6e124eb62156c05525)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_dequantize_1ae01ee2df9b62f7729848ca15ed70e8fc)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [Mode](#classtensorflow_1_1ops_1_1_dequantize_1ac9873b34c5c0eb36296e0fe726644fc9)`(StringPiece x)` | [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs) |\n\n| ### Structs ||\n|----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::Dequantize::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/dequantize/attrs) | Optional attribute setters for [Dequantize](/versions/r1.15/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### Dequantize\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### Dequantize\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### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n``` \n\nPublic static functions\n-----------------------\n\n### Mode\n\n```text\nAttrs Mode(\n StringPiece x\n)\n```"]]