tfl.pwl_calibration_lib.project_all_constraints
Stay organized with collections
Save and categorize content based on your preferences.
Jointly projects into all supported constraints.
tfl.pwl_calibration_lib.project_all_constraints(
weights,
monotonicity,
output_min,
output_max,
output_min_constraints,
output_max_constraints,
convexity,
lengths,
num_projection_iterations=8
)
For all combinations of constraints except the case where bounds constraints
are specified without monotonicity constraints we properly project into
nearest point with respect to L2 norm. For latter case we use a heuristic to
map input point into some feasible point with no guarantees on how close this
point is to the true projection.
If only bounds or only monotonicity constraints are specified there will be a
single step projection. For all other combinations of constraints we use
num_projection_iterations iterations of Dykstra's alternating projection
algorithm to jointly project onto all the given constraints. Dykstra's
algorithm gives us proper projection with respect to L2 norm but approaches it
from "wrong" side. That's why in order to ensure that constraints are strictly
met we'll do approximate projections in the end which project strictly into
feasible space, but it's not an exact projection with respect to the L2 norm.
With enough iterations of the Dykstra's algorithm, the impact of such
approximate projection should be negligible.
With bound and convexity constraints and no specified monotonicity, this
method does not fully satisfy the constrains. Increasing the number of
iterations can reduce the constraint violation in such cases.
Args |
weights
|
(num_keypoints, units) -shape tensor which represents weights of
PWL calibration layer.
|
monotonicity
|
1 for increasing, -1 for decreasing, 0 for no monotonicity
constraints.
|
output_min
|
Lower bound constraint of PWL calibration layer.
|
output_max
|
Upper bound constraint of PWL calibration layer.
|
output_min_constraints
|
A tfl.pwl_calibration_lib.BoundConstraintsType
describing the constraints on the layer's minimum value.
|
output_max_constraints
|
A tfl.pwl_calibration_lib.BoundConstraintsType
describing the constraints on the layer's maximum value.
|
convexity
|
1 for convex, -1 for concave, 0 for no convexity constraints.
|
lengths
|
Lengths of pieces of piecewise linear function. Needed only if
convexity projection is specified.
|
num_projection_iterations
|
Number of iterations of Dykstra's alternating
projection algorithm.
|
Returns |
Projected weights tensor.
|
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,["# tfl.pwl_calibration_lib.project_all_constraints\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/pwl_calibration_lib.py#L472-L646) |\n\nJointly projects into all supported constraints. \n\n tfl.pwl_calibration_lib.project_all_constraints(\n weights,\n monotonicity,\n output_min,\n output_max,\n output_min_constraints,\n output_max_constraints,\n convexity,\n lengths,\n num_projection_iterations=8\n )\n\nFor all combinations of constraints except the case where bounds constraints\nare specified without monotonicity constraints we properly project into\nnearest point with respect to L2 norm. For latter case we use a heuristic to\nmap input point into some feasible point with no guarantees on how close this\npoint is to the true projection.\n\nIf only bounds or only monotonicity constraints are specified there will be a\nsingle step projection. For all other combinations of constraints we use\nnum_projection_iterations iterations of Dykstra's alternating projection\nalgorithm to jointly project onto all the given constraints. Dykstra's\nalgorithm gives us proper projection with respect to L2 norm but approaches it\nfrom \"wrong\" side. That's why in order to ensure that constraints are strictly\nmet we'll do approximate projections in the end which project strictly into\nfeasible space, but it's not an exact projection with respect to the L2 norm.\nWith enough iterations of the Dykstra's algorithm, the impact of such\napproximate projection should be negligible.\n\nWith bound and convexity constraints and no specified monotonicity, this\nmethod does not fully satisfy the constrains. Increasing the number of\niterations can reduce the constraint violation in such cases.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `weights` | `(num_keypoints, units)`-shape tensor which represents weights of PWL calibration layer. |\n| `monotonicity` | 1 for increasing, -1 for decreasing, 0 for no monotonicity constraints. |\n| `output_min` | Lower bound constraint of PWL calibration layer. |\n| `output_max` | Upper bound constraint of PWL calibration layer. |\n| `output_min_constraints` | A [`tfl.pwl_calibration_lib.BoundConstraintsType`](../../tfl/pwl_calibration_lib/BoundConstraintsType) describing the constraints on the layer's minimum value. |\n| `output_max_constraints` | A [`tfl.pwl_calibration_lib.BoundConstraintsType`](../../tfl/pwl_calibration_lib/BoundConstraintsType) describing the constraints on the layer's maximum value. |\n| `convexity` | 1 for convex, -1 for concave, 0 for no convexity constraints. |\n| `lengths` | Lengths of pieces of piecewise linear function. Needed only if convexity projection is specified. |\n| `num_projection_iterations` | Number of iterations of Dykstra's alternating projection algorithm. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Projected weights tensor. ||\n\n\u003cbr /\u003e"]]