tfl.lattice_lib.finalize_constraints
Stay organized with collections
Save and categorize content based on your preferences.
Approximately projects lattice weights to strictly satisfy all constraints.
tfl.lattice_lib.finalize_constraints(
weights,
lattice_sizes,
monotonicities,
edgeworth_trusts=None,
trapezoid_trusts=None,
output_min=None,
output_max=None
)
This projeciton guarantees that constraints are strictly met, but it is not
an exact projection w.r.t. the L2 norm. The computationally cost is
O((num_monotonic_dims + num_trust_constraints) * num_lattice_weights)
.
See helper functions _approximately_project_*
for details of the individual
projection algorithms for each set of constraints. They are designed to be
applied sequentially: monotonicity, then edgeworth, trapezoid, and bounds if
necessary. This is because the projection algorithms are guaranteed to not
violate previous constraints, though they may lead to violations of later
constraints.
Args |
weights
|
Lattice weights tensor of shape: (prod(lattice_sizes), units) .
|
lattice_sizes
|
List or tuple of integers which represents lattice sizes.
which correspond to weights.
|
monotonicities
|
List or tuple of same length as lattice_sizes of {0, 1}
which represents monotonicity constraints per dimension. 1 stands for
increasing (non-decreasing in fact), 0 for no monotonicity constraints.
|
edgeworth_trusts
|
None or iterable of three-element tuples. First element is
the index of the main (monotonic) feature. Second element is the index of
the conditional feature. Third element is the direction of trust set to 1
if higher values of the conditional feature should increase trust in the
main feature and -1 otherwise.
|
trapezoid_trusts
|
None or iterable of three-element tuples. First element is
the index of the main (monotonic) feature. Second element is the index of
the conditional feature. Third element is the direction of trust set to 1
if higher values of the conditional feature should increase trust in the
main feature and -1 otherwise.
|
output_min
|
None or minimum possible output.
|
output_max
|
None or maximum possible output.
|
Returns |
Projected weights tensor of same shape as weights .
|
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.
[[["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 2024-08-02 UTC."],[],[]]