テンソルフロー::作戦::比較とビットパック

#include <math_ops.h>

inputの値をthresholdと比較し、結果のビットをuint8にパックします。

まとめ

各比較はブール値true ( input_value > thresholdの場合) またはfalseを返し、それ以外の場合は 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 で割り切れる必要があります。

[s0, s1, ..., s_n]inputが与えられると、出力は[s0, s1, ..., s_n / 8]uint8テンソルになります。

引数:

  • スコープ:スコープオブジェクト
  • input: 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(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input threshold
)

ノード

::tensorflow::Node * node() const 

演算子::tensorflow::入力

 operator::tensorflow::Input() const 

演算子::tensorflow::出力

 operator::tensorflow::Output() const