Create a nested structure of quantization ranges for secure sum encoding.
tff.learning.metrics.create_default_secure_sum_quantization_ranges(
local_unfinalized_metrics_type: tff.types.StructWithPythonType
,
lower_bound: Union[int, float] = DEFAULT_SECURE_LOWER_BOUND,
upper_bound: Union[int, float] = DEFAULT_SECURE_UPPER_BOUND
) -> MetricValueRangeDict
Args |
local_unfinalized_metrics_type
|
The tff.Type structure to generate default
secure sum quantization ranges form. Must be a tff.Type tree containing
only tff.TensorType and tff.StructType . Each tff.TensorType must be
of floating point or integer dtype.
|
lower_bound
|
An optional integer or floating point lower bound for the
secure sum quantization range. Values smaller than this will be clipped to
this value. By default is 0 . If a float , any tff.TensorType in
local_unfinalized_metrics_type with an integer dtype will use
math.ceil(lower_bound) as a bound.
|
upper_bound
|
An optional integer or floating point upper bound for the
secure sum quantization range. Values larger than this will be clipped to
this value. By default is 2^20 - 1 (~1 million). If a float , any
tff.TensorType in local_unfinalized_metrics_type with an integer dtype
will use math.floor(lower_bound) as a bound.
|
Returns |
A nested structure matching the structure of
local_unfinalized_metrics_type where each tf.TensorType has been
replaced with a 2-tuple of lower bound and upper bound, where the tupel
elements are float for floating dtypes, and int for integer dtypes.
|
Raises |
UnquantizableDTypeError
|
If A tff.TensorType in
local_unfinalized_metrics_type has a non-float or non-integer dtype.
|
ValueError
|
If an integer dtype in local_unfinalized_metrics_type will
have a zero range (e.g. math.ceil(lower_bound) - math.floor(upper_bound)
< 1 ).
|