tensorflow::ops::CompareAndBitpack

#include <math_ops.h>

เปรียบเทียบค่า input กับ threshold และบรรจุบิตที่ได้ลงใน uint8

สรุป

การเปรียบเทียบแต่ละครั้งจะส่งคืนค่าบูลีน true (ถ้า input_value > threshold ) หรือ false (ถ้าไม่ใช่)

การดำเนินการนี้มีประโยชน์สำหรับ Locality-Sensitive-Hashing (LSH) และอัลกอริธึมอื่นๆ ที่ใช้การประมาณค่าแฮชของระยะทางโคไซน์และ L2 โดยสามารถสร้างรหัสจากข้อมูลป้อนเข้าได้โดยใช้:

codebook_size = 50
codebook_bits = codebook_size * 32
codebook = tf.get_variable('codebook', [x.shape[-1].value, codebook_bits],
                           dtype=x.dtype,
                           initializer=tf.orthogonal_initializer())
codes = compare_and_threshold(tf.matmul(x, codebook), threshold=0.)
codes = tf.bitcast(codes, tf.int32)  # go from uint8 to int32
# now codes has shape x.shape[:-1] + [codebook_size]

หมายเหตุ : ปัจจุบัน มิติภายในสุดของเทนเซอร์จะต้องหารด้วย 8 ลงตัว

เมื่อกำหนด input มีรูปร่าง [s0, s1, ..., s_n] เอาต์พุตจะเป็นเทนเซอร์ uint8 ที่มีรูปร่าง [s0, s1, ..., s_n / 8]

ข้อโต้แย้ง:

  • ขอบเขต: วัตถุ ขอบเขต
  • อินพุต: ค่าที่จะนำไปเปรียบเทียบกับ threshold และบิตแพ็ค
  • เกณฑ์: เกณฑ์ที่จะใช้เปรียบเทียบ

การส่งคืนสินค้า:

  • Output : การเปรียบเทียบที่บรรจุด้วยบิตแพ็ค

ตัวสร้างและตัวทำลาย

CompareAndBitpack (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input threshold)

คุณลักษณะสาธารณะ

operation
output

หน้าที่สาธารณะ

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

คุณลักษณะสาธารณะ

การดำเนินการ

Operation operation

เอาต์พุต

::tensorflow::Output output

หน้าที่สาธารณะ

เปรียบเทียบและบิตแพ็ค

 CompareAndBitpack(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input threshold
)

โหนด

::tensorflow::Node * node() const 

ตัวดำเนินการ::เทนเซอร์โฟลว์::อินพุต

 operator::tensorflow::Input() const 

ตัวดำเนินการ::เทนเซอร์โฟลว์::เอาต์พุต

 operator::tensorflow::Output() const