tensoreflusso:: ops:: ConfrontaAndBitpack

#include <math_ops.h>

Confronta i valori di input con threshold e comprime i bit risultanti in un uint8 .

Riepilogo

Ogni confronto restituisce un valore booleano true (se input_value > threshold ) o false in caso contrario.

Questa operazione è utile per Locality-Sensitive-Hashing (LSH) e altri algoritmi che utilizzano approssimazioni di hashing delle distanze coseno e L2 ; i codici possono essere generati da un input tramite:

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]

NOTA : Attualmente la dimensione più interna del tensore deve essere divisibile per 8.

Dato un input a forma di [s0, s1, ..., s_n] , l'output è un tensore uint8 a forma di [s0, s1, ..., s_n / 8] .

Argomenti:

  • scope: un oggetto Scope
  • input: valori da confrontare con threshold e bitpack.
  • soglia: soglia con cui effettuare il confronto.

Ritorna:

  • Output : i confronti bitpacked.

Costruttori e distruttori

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

Attributi pubblici

operation
output

Funzioni pubbliche

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

Attributi pubblici

operazione

Operation operation

produzione

::tensorflow::Output output

Funzioni pubbliche

ConfrontaAndBitpack

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

nodo

::tensorflow::Node * node() const 

operatore::tensorflow::Input

 operator::tensorflow::Input() const 

operatore::tensorflow::Output

 operator::tensorflow::Output() const