Tensorflow :: ops :: CompareAndBitpack
#include <math_ops.h>
Vergleichen Sie die input
mit dem threshold
und packen Sie die resultierenden Bits in ein uint8
.
Zusammenfassung
Jeder Vergleich gibt einen booleschen input_value > threshold
true
(wenn input_value > threshold
) oder andernfalls false
.
Diese Operation ist nützlich für Locality-Sensitive-Hashing (LSH) und andere Algorithmen, die Hashing-Approximationen von Cosinus- und L2
Abständen verwenden. Codes können aus einer Eingabe generiert werden über:
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]
HINWEIS : Derzeit muss die innerste Abmessung des Tensors durch 8 teilbar sein.
Bei einer input
Form [s0, s1, ..., s_n]
ist die Ausgabe eine uint8
[s0, s1, ..., s_n / 8]
.
Argumente:
- scope: Ein Scope- Objekt
- Eingabe: Zu vergleichende Werte mit
threshold
und Bitpack. - Schwelle: Schwelle zum Vergleich.
Kehrt zurück:
-
Output
: Die bitpacked Vergleiche.
Konstruktoren und Destruktoren | |
---|---|
CompareAndBitpack (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input threshold) |
Öffentliche Attribute | |
---|---|
operation | |
output |
Öffentliche Funktionen | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Öffentliche Attribute
Operation
Operation operation
Ausgabe
::tensorflow::Output output
Öffentliche Funktionen
CompareAndBitpack
CompareAndBitpack( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input threshold )
Knoten
::tensorflow::Node * node() const
operator :: tensorflow :: Input
operator::tensorflow::Input() const
operator :: tensorflow :: Output
operator::tensorflow::Output() const