tfmot.quantization.keras.quantizers.AllValuesQuantizer
Stay organized with collections
Save and categorize content based on your preferences.
Quantize tensor based on min/max of tensor values across all batches.
Inherits From: Quantizer
tfmot.quantization.keras.quantizers.AllValuesQuantizer(
num_bits, per_axis, symmetric, narrow_range
)
Args |
num_bits
|
Number of bits for quantization
|
per_axis
|
Whether to apply per_axis quantization. The last dimension is
used as the axis.
|
symmetric
|
If true, use symmetric quantization limits instead of training
the minimum and maximum of each quantization range separately.
|
narrow_range
|
In case of 8 bits, narrow_range nudges the quantized range
to be [-127, 127] instead of [-128, 127]. This ensures symmetric
range has 0 as the centre.
|
Methods
build
View source
build(
tensor_shape, name, layer
)
Construct the weights required by the quantizer.
A quantizer may need to construct variables to hold the state for its
algorithm. This function is invoked during the build
stage of the layer
that the quantizer is used for. Any variables constructed are under the
scope of the layer
and serialized as part of the layer.
Args |
tensor_shape
|
Shape of tensor which needs to be quantized.
|
name
|
Name of tensor.
|
layer
|
Keras layer which is quantizing the tensors. The layer is needed
to construct the weights, and is also the owner of the weights.
|
Returns: Dictionary of constructed weights. This dictionary will be
passed to the quantizer's call function as a weights
dictionary.
from_config
View source
@classmethod
from_config(
config
)
Instantiates a Quantizer
from its config.
Args |
config
|
Output of get_config() .
|
Returns |
A Quantizer instance.
|
get_config
View source
get_config()
Returns the config used to serialize the Quantizer
.
__call__
View source
__call__(
inputs, training, weights, **kwargs
)
Quantize tensor.
Args |
inputs
|
Input tensor to be quantized.
|
training
|
Whether the graph is currently training.
|
weights
|
Dictionary of weights the quantizer can use to quantize the
tensor. This contains the weights created in the build function.
|
**kwargs
|
Additional variables which may be passed to the quantizer.
|
Returns |
Quantized tensor.
|
__eq__
View source
__eq__(
other
)
Return self==value.
__ne__
View source
__ne__(
other
)
Return self!=value.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-05-26 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2023-05-26 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-05-26 UTC."],[],[]]