@Namespace(value="tensorflow::ops") @NoOffset public static class tensorflow.CompareAndBitpack extends Pointer
input to threshold and pack resulting bits into a uint8.
Each comparison returns a boolean true (if input_value > threshold)
or and false otherwise.
This operation is useful for Locality-Sensitive-Hashing (LSH) and other
algorithms that use hashing approximations of cosine and L2 distances;
codes can be generated from an input via:
python
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]
**NOTE**: Currently, the innermost dimension of the tensor must be divisible
by 8.
Given an input shaped [s0, s1, ..., s_n], the output is
a uint8 tensor shaped [s0, s1, ..., s_n / 8].
Arguments:
* scope: A Scope object
* input: Values to compare against threshold and bitpack.
* threshold: Threshold to compare against.
Returns:
* Output: The bitpacked comparisons.Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator| Constructor and Description |
|---|
CompareAndBitpack(Pointer p)
Pointer cast constructor.
|
CompareAndBitpack(tensorflow.Scope scope,
tensorflow.Input input,
tensorflow.Input threshold) |
| Modifier and Type | Method and Description |
|---|---|
tensorflow.Input |
asInput() |
tensorflow.Output |
asOutput() |
tensorflow.Node |
node() |
tensorflow.Operation |
operation() |
tensorflow.CompareAndBitpack |
operation(tensorflow.Operation operation) |
tensorflow.Output |
output() |
tensorflow.CompareAndBitpack |
output(tensorflow.Output output) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, position, put, realloc, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zeropublic CompareAndBitpack(Pointer p)
Pointer.Pointer(Pointer).public CompareAndBitpack(@Const @ByRef tensorflow.Scope scope, @ByVal tensorflow.Input input, @ByVal tensorflow.Input threshold)
@ByVal @Name(value="operator tensorflow::Output") public tensorflow.Output asOutput()
@ByVal @Name(value="operator tensorflow::Input") public tensorflow.Input asInput()
public tensorflow.Node node()
@ByRef public tensorflow.Operation operation()
public tensorflow.CompareAndBitpack operation(tensorflow.Operation operation)
@ByRef public tensorflow.Output output()
public tensorflow.CompareAndBitpack output(tensorflow.Output output)
Copyright © 2019. All rights reserved.