tensorflow:: ops:: CompareAndBitpack
#include <math_ops.h> input値をthresholdと比較し、結果のビットをuint8にパックします。
まとめ
各比較はinput_value > thresholdより大きい場合はtrue 、それ以外の場合は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]の形状である場合、出力は[s0, s1, ..., s_n / 8]の形状のuint8テンソルになります。
議論:
- スコープ:スコープオブジェクト
- 入力:
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