tf.keras.quantizers.AbsMaxQuantizer

Inherits From: Quantizer

Methods

from_config

View source

Creates a quantizer from its config.

This method is the reverse of get_config, capable of instantiating the same quantizer from the config dictionary.

This method is used by Keras model_to_estimator, saving and loading models to HDF5 formats, Keras model cloning, some visualization utilities, and exporting models to and from JSON.

Args
config A Python dictionary, typically the output of get_config.

Returns
A quantizer instance.

get_config

View source

Returns the config of the quantizer.

A quantizer config is a Python dictionary (serializable) containing all configuration parameters of the quantizer. The same quantizer can be reinstantiated later (without any saved state) from this configuration.

This method is optional if you are just training and executing models, exporting to and from SavedModels, or using weight checkpoints.

This method is required for Keras model_to_estimator, saving and loading models to HDF5 formats, Keras model cloning, some visualization utilities, and exporting models to and from JSON.

Returns
Python dictionary.

__call__

View source

Quantizes the input tensor.

Args
x Input tensor to quantize.
axis Axis along which to compute the quantization range. If None, uses the axis specified in the constructor. If None and no axis was specified in the constructor, defaults to -1.
to_numpy Whether to perform the quantization in numpy. This performs the computation on the host CPU and can be useful for saving memory on the device. If False, the computation is performed on the device.

Returns
A tuple of the quantized tensor and the scale.