टेंसरफ़्लो:: ऑप्स:: परिमाणीकरण करें

#include <array_ops.h>

'इनपुट' टेंसर को एक फ्लोट या bfloat16 टेंसर में डिक्वांटाइज़ करें

सारांश

[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 है, तो प्रत्येक इनपुट मान को स्केलिंग_फैक्टर से गुणा करके डीक्वांटाइजेशन किया जाता है। (इस प्रकार 0 का इनपुट हमेशा 0.0 पर मैप होता है)।

स्केलिंग_फैक्टर को 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: आउटपुट टेंसर का प्रकार। वर्तमान में Dequatize फ्लोट और 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)

संरचनाएँ

टेंसरफ़्लो:: ऑप्स:: डिक्वांटाइज़:: एटर्स

Dequatize के लिए वैकल्पिक विशेषता सेटर्स।

सार्वजनिक गुण

संचालन

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 

ऑपरेटर::टेन्सरफ़्लो::इनपुट

 operator::tensorflow::Input() const 

ऑपरेटर::टेन्सरफ़्लो::आउटपुट

 operator::tensorflow::Output() const 

सार्वजनिक स्थैतिक कार्य

एक्सिस

Attrs Axis(
  int64 x
)

डीप्रकार

Attrs Dtype(
  DataType x
)

तरीका

Attrs Mode(
  StringPiece x
)

संकीर्ण रेंज

Attrs NarrowRange(
  bool x
)