tensorflow:: ops:: דה-קוונטיזציה

#include <array_ops.h>

דה-קוונטיזציה של טנזור ה'קלט' לטנזור צף או טנזור 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. פעולת Dequantize ב-quint8 תיקח כל ערך, תעביר אותו ל-float ותכפיל אותו ב-6 / 255. שים לב שאם quantizedtype הוא qint8, הפעולה תחבר בנוסף כל ערך ב-128 לפני ה-cast.

אם המצב הוא '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 נקבע מ- 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:: ביטול קוונטיזציה:: 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
)