컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
텐서플로우:: 작전:: 역양자화
#include <array_ops.h>
'입력' 텐서를 float 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를 곱합니다. 양자화 유형이 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
모드는 QuantizeAndDequantize{V2|V3}
에서 사용되는 양자화 접근 방식과 일치합니다.
모드가 SCALED
인 경우 출력 유형의 전체 범위를 사용하지 않고 대칭을 위해 가능한 가장 낮은 값을 생략하도록 선택합니다(예: 출력 범위는 부호 있는 8비트 양자화의 경우 -128~127이 아니라 -127~127입니다). 0.0이 0에 매핑되도록 합니다.
먼저 텐서에서 값의 범위를 찾습니다. 우리가 사용하는 범위는 항상 0을 중심으로 하므로 다음과 같은 m을 찾습니다.
m = max(abs(input_min), abs(input_max))
그러면 입력 텐서 범위는 [-m, m]
입니다.
다음으로 고정 소수점 양자화 버킷 [min_fixed, max_fixed]
선택합니다. T가 서명된 경우 이는 다음과 같습니다.
num_bits = sizeof(T) * 8
[min_fixed, max_fixed] =
[-(1 << (num_bits - 1) - 1), (1 << (num_bits - 1)) - 1]
그렇지 않고 T가 부호가 없으면 고정 소수점 범위는 다음과 같습니다.
[min_fixed, max_fixed] = [0, (1 << num_bits) - 1]
이것으로부터 우리는 스케일링 인자 s를 계산합니다:
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 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 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```"]]