เทนเซอร์โฟลว์:: ปฏิบัติการ:: ลดปริมาณ

#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 การแยกปริมาณ ใน 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 การลดปริมาณจะดำเนินการโดยการคูณค่าอินพุตแต่ละค่าด้วย 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: ค่าสเกลาร์สูงสุดที่อาจเกิดขึ้นสำหรับอินพุต

ผลตอบแทน:

  • 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)
Mode (StringPiece x)
NarrowRange (bool x)

โครงสร้าง

เทนเซอร์โฟลว์ :: 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
)

โหมด

Attrs Mode(
  StringPiece x
)

ช่วงแคบ ๆ

Attrs NarrowRange(
  bool x
)