tensorflow:: אופס:: דהקוונטיזציה
#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
אם הקלט מגיע מ- 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
מצב SCALED
תואם את גישת הקוונטיזציה המשמשת ב- QuantizeAndDequantize{V2|V3}
.
אם המצב הוא SCALED
, איננו משתמשים בכל הטווח של סוג הפלט, בוחרים להחליק את הערך הנמוך ביותר האפשרי עבור סימטריה (למשל, טווח הפלט הוא -127 עד 127, לא -128 עד 127 עבור קוונטיזציה של 8 סיביות עם סימנים), כך ש-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
טיעונים:
- scope: אובייקט Scope
- min_range: הערך הסקלרי המינימלי שיוצר עבור הקלט.
- max_range: הערך הסקלרי המקסימלי המופק עבור הקלט.
החזרות:
-
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) |
תפקידים ציבוריים | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
מבנים | |
---|---|
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 Mode( StringPiece x )