تدفق التوتر:: العمليات:: قارن وBitpack

#include <math_ops.h>

قارن قيم input threshold وحزم البتات الناتجة في uint8 .

ملخص

تقوم كل مقارنة بإرجاع قيمة منطقية true (إذا كانت input_value > threshold ) أو false بخلاف ذلك.

تعتبر هذه العملية مفيدة للتجزئة الحساسة للمكان (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

الوظائف العامة

قارن وBitpack

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

العقدة

::tensorflow::Node * node() const 

المشغل::tensorflow::الإدخال

 operator::tensorflow::Input() const 

المشغل::tensorflow::الإخراج

 operator::tensorflow::Output() const