tensorflow:: אופס:: דהקוונטיזציה

#include <array_ops.h>

הפוך את טנסור 'הקלט' ל-float או bfloat16 Tensor .

סיכום

[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

אם הקלט מגיע מ- QuantizedRelu6 , סוג הפלט הוא quint8 (טווח של 0-255) אבל הטווח האפשרי של QuantizedRelu6 הוא 0-6. ערכי min_range ו-max_range הם לפיכך 0.0 ו-6.0. Dequantize on quint8 ייקח כל ערך, יטיל לצוף ויכפיל ב-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 נקבע מ- 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);

טיעונים:

  • scope: אובייקט Scope
  • 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
)

Dtype

Attrs Dtype(
  DataType x
)

מצב

Attrs Mode(
  StringPiece x
)

טווח צר

Attrs NarrowRange(
  bool x
)