Module: tfl.conditional_pwl_calibration
Stay organized with collections
Save and categorize content based on your preferences.
Implements PWLCalibration with derived parameters (kernels).
pwl_calibration_fn
is similar to tfl.layers.PWLCalibration
with the key
difference that the keypoints are decided by the given parameters instead
of learnable weights belonging to a layer. These parameters can be one of:
- constants,
- trainable variables,
- outputs from other TF modules.
For inputs of shape (batch_size, units)
, two sets of parameters are required
to configure the piece-wise linear calibrator in terms of its x and y values:
keypoint_input_parameters
for configuring the x values,
keypoint_output_parameters
for configuring the y values.
This function is a general form of conditional calibration, that one input
variable is calibrated based on free form parameters coming from other variables
and their transformations.
Shapes:
The last dimension sizes of keypoint_input_parameters
(input_param_size) and
keypoint_output_parameters
(output_param_size) depend on the number of
keypoints used by the calibrator. We follow the relationships that
The final shapes need to be broadcast friendly with (batch_size, units, 1)
:
keypoint_input_parameters
:
(1 or batch_size, 1 or units, input_param_size)
.
keypoint_output_parameters
:
(1 or batch_size, 1 or units, output_param_size)
.
Functions
default_keypoint_input_parameters(...)
: Helper creating default keypoint_input_parameters
.
default_keypoint_output_parameters(...)
: Helper creating default keypoint_output_parameters
.
pwl_calibration_fn(...)
: Calibrates inputs
using derived parameters (kernels).
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 2024-08-02 UTC.
[null,null,["Last updated 2024-08-02 UTC."],[],[],null,["# Module: tfl.conditional_pwl_calibration\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/conditional_pwl_calibration.py) |\n\nImplements PWLCalibration with derived parameters (kernels).\n\n`pwl_calibration_fn` is similar to [`tfl.layers.PWLCalibration`](../tfl/layers/PWLCalibration) with the key\ndifference that the keypoints are decided by the given parameters instead\nof learnable weights belonging to a layer. These parameters can be one of:\n\n- constants,\n- trainable variables,\n- outputs from other TF modules.\n\nFor inputs of shape `(batch_size, units)`, two sets of parameters are required\nto configure the piece-wise linear calibrator in terms of its x and y values:\n\n- `keypoint_input_parameters` for configuring the x values,\n- `keypoint_output_parameters` for configuring the y values.\n\nThis function is a general form of conditional calibration, that one input\nvariable is calibrated based on free form parameters coming from other variables\nand their transformations.\n\n#### Shapes:\n\nThe last dimension sizes of `keypoint_input_parameters` (input_param_size) and\n`keypoint_output_parameters` (output_param_size) depend on the number of\nkeypoints used by the calibrator. We follow the relationships that\n\n- input_param_size = # keypoints - 2, as the leftmost and rightmost keypoints are given.\n- output_param_size = # keypoints initially, and we then modify it by\n\n 1. if cyclic calibrator: output_param_size -= 1,\n 2. if clamp_min: output_param_size -= 1,\n 3. if clamp_max: output_param_size -= 1,\n 4. if need to learn how to impute missing: output_param_size += 1.\n\nThe final shapes need to be broadcast friendly with `(batch_size, units, 1)`:\n\n- `keypoint_input_parameters`: `(1 or batch_size, 1 or units, input_param_size)`.\n- `keypoint_output_parameters`: `(1 or batch_size, 1 or units, output_param_size)`.\n\nFunctions\n---------\n\n[`default_keypoint_input_parameters(...)`](../tfl/conditional_pwl_calibration/default_keypoint_input_parameters): Helper creating default `keypoint_input_parameters`.\n\n[`default_keypoint_output_parameters(...)`](../tfl/conditional_pwl_calibration/default_keypoint_output_parameters): Helper creating default `keypoint_output_parameters`.\n\n[`pwl_calibration_fn(...)`](../tfl/conditional_pwl_calibration/pwl_calibration_fn): Calibrates `inputs` using derived parameters (kernels)."]]