텐서플로우:: 작전:: CompareAndBitpack

#include <math_ops.h>

input 값을 threshold 값과 비교하고 결과 비트를 uint8 로 압축합니다.

요약

각 비교는 부울 true ( input_value > threshold 인 경우)를 반환하고 그렇지 않으면 false 반환합니다.

이 작업은 LSH(Locality-Sensitive-Hashing) 및 코사인 및 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 텐서입니다.

인수:

  • 범위: 범위 개체
  • 입력: threshold 값 및 비트팩과 비교할 값입니다.
  • 임계값: 비교할 임계값입니다.

보고:

생성자와 소멸자

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() const 

연산자::텐서플로우::출력

 operator::tensorflow::Output() const