tensorflow :: ops :: CompareAndBitpack
#include <math_ops.h>
input
値をthreshold
と比較し、結果のビットをuint8
パックし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
operator::tensorflow::Input() const
operator :: tensorflow :: Output
operator::tensorflow::Output() const