tensorflow:: ops:: CompareAndBitpack
#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
सार्वजनिक समारोह
CompareAndBitpack
CompareAndBitpack( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input threshold )
नोड
::tensorflow::Node * node() const
ऑपरेटर::टेन्सरफ्लो::इनपुट
operator::tensorflow::Input() const
ऑपरेटर::टेन्सरफ्लो::आउटपुट
operator::tensorflow::Output() const