@Namespace(value="tensorflow::ops") @NoOffset public static class tensorflow.Dequantize extends Pointer
if T == qint8, in[i] += (range(T) + 1)/ 2.0
out[i] = min_range + (in[i]* (max_range - min_range) / range(T))
here range(T) = numeric_limits<T>::max() - numeric_limits<T>::min()
*MIN_COMBINED Mode Example*
If the input comes from a QuantizedRelu6, the output type is
quint8 (range of 0-255) but the possible range of QuantizedRelu6 is
0-6. The min_range and max_range values are therefore 0.0 and 6.0.
Dequantize on quint8 will take each value, cast to float, and multiply
by 6 / 255.
Note that if quantizedtype is qint8, the operation will additionally add
each value by 128 prior to casting.
If the mode is 'MIN_FIRST', then this approach is used:
c++
num_discrete_values = 1 << (# of bits in T)
range_adjust = num_discrete_values / (num_discrete_values - 1)
range = (range_max - range_min) * range_adjust
range_scale = range / num_discrete_values
const double offset_input = static_cast<double>(input) - lowest_quantized;
result = range_min + ((input - numeric_limits<T>::min()) * range_scale)
*SCALED mode Example*
SCALED mode matches the quantization approach used in
QuantizeAndDequantize{V2|V3}.
If the mode is SCALED, we do not use the full range of the output type,
choosing to elide the lowest possible value for symmetry (e.g., output range is
-127 to 127, not -128 to 127 for signed 8 bit quantization), so that 0.0 maps to
0.
We first find the range of values in our tensor. The
range we use is always centered on 0, so we find m such that
c++
m = max(abs(input_min), abs(input_max))
Our input tensor range is then [-m, m].
Next, we choose our fixed-point quantization buckets, [min_fixed, max_fixed].
If T is signed, this is
num_bits = sizeof(T) * 8
[min_fixed, max_fixed] =
[-(1 << (num_bits - 1) - 1), (1 << (num_bits - 1)) - 1]
Otherwise, if T is unsigned, the fixed-point range is
[min_fixed, max_fixed] = [0, (1 << num_bits) - 1]
From this we compute our scaling factor, s:
c++
s = (2 * m) / (max_fixed - min_fixed)
Now we can dequantize the elements of our tensor:
c++
result = input * s
Arguments:
* scope: A Scope object
* min_range: The minimum scalar value possibly produced for the input.
* max_range: The maximum scalar value possibly produced for the input.
Returns:
* Output: The output tensor.| Modifier and Type | Class and Description |
|---|---|
static class |
tensorflow.Dequantize.Attrs
Optional attribute setters for Dequantize
|
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator| Constructor and Description |
|---|
Dequantize(Pointer p)
Pointer cast constructor.
|
Dequantize(tensorflow.Scope scope,
tensorflow.Input input,
tensorflow.Input min_range,
tensorflow.Input max_range) |
Dequantize(tensorflow.Scope scope,
tensorflow.Input input,
tensorflow.Input min_range,
tensorflow.Input max_range,
tensorflow.Dequantize.Attrs attrs) |
| Modifier and Type | Method and Description |
|---|---|
tensorflow.Input |
asInput() |
tensorflow.Output |
asOutput() |
static tensorflow.Dequantize.Attrs |
Mode(BytePointer x) |
static tensorflow.Dequantize.Attrs |
Mode(String x) |
tensorflow.Node |
node() |
tensorflow.Operation |
operation() |
tensorflow.Dequantize |
operation(tensorflow.Operation operation) |
tensorflow.Output |
output() |
tensorflow.Dequantize |
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 Dequantize(Pointer p)
Pointer.Pointer(Pointer).public Dequantize(@Const @ByRef tensorflow.Scope scope, @ByVal tensorflow.Input input, @ByVal tensorflow.Input min_range, @ByVal tensorflow.Input max_range)
public Dequantize(@Const @ByRef tensorflow.Scope scope, @ByVal tensorflow.Input input, @ByVal tensorflow.Input min_range, @ByVal tensorflow.Input max_range, @Const @ByRef tensorflow.Dequantize.Attrs attrs)
@ByVal @Name(value="operator tensorflow::Output") public tensorflow.Output asOutput()
@ByVal @Name(value="operator tensorflow::Input") public tensorflow.Input asInput()
public tensorflow.Node node()
@ByVal public static tensorflow.Dequantize.Attrs Mode(@tensorflow.StringPiece BytePointer x)
@ByVal public static tensorflow.Dequantize.Attrs Mode(@tensorflow.StringPiece String x)
@ByRef public tensorflow.Operation operation()
public tensorflow.Dequantize operation(tensorflow.Operation operation)
@ByRef public tensorflow.Output output()
public tensorflow.Dequantize output(tensorflow.Output output)
Copyright © 2019. All rights reserved.