tensorflow:: אופס:: 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]
.
טיעונים:
- scope: אובייקט Scope
- קלט: ערכים להשוואה מול
threshold
ו-bitpack. - סף: סף להשוואה מולו.
החזרות:
-
Output
: ההשוואות עמוסות הסיביות.
בנאים והורסים | |
---|---|
CompareAndBitpack (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input threshold) |
תפקידים ציבוריים | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
תכונות ציבוריות
מִבצָע
Operation operation
תְפוּקָה
::tensorflow::Output output
תפקידים ציבוריים
CompareAndBitpack
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