tfl.lattice_lib.project_by_dykstra
Stay organized with collections
Save and categorize content based on your preferences.
Applies dykstra's projection algorithm for monotonicity/trust constraints.
tfl.lattice_lib.project_by_dykstra(
weights,
lattice_sizes,
monotonicities=None,
unimodalities=None,
edgeworth_trusts=None,
trapezoid_trusts=None,
monotonic_dominances=None,
range_dominances=None,
joint_monotonicities=None,
joint_unimodalities=None,
num_iterations=1
)
- Returns honest projection with respect to L2 norm if num_iterations is inf.
- Monotonicity will be violated by some small eps(num_iterations).
- Complexity: O(num_iterations * (num_monotonic_dims + num_trust_constraints)
Dykstra's alternating projections algorithm projects into intersection of
several convex sets. For algorithm description itself use Google or Wiki:
https://en.wikipedia.org/wiki/Dykstra%27s_projection_algorithm
Here, each monotonicity constraint is split up into 2 independent convex sets
each trust constraint is split up into 4 independent convex sets. These sets
are then projected onto exactly (in L2 space). For more details, see the
_projectpartial* functions.
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
|
None or 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.
|
unimodalities
|
None or list or tuple of same length as lattice_sizes of {-1,
0, 1} which represents unimodality constraints per dimension. 1 indicates
that function first decreases then increases, -1 indicates that function
first increases then decreases, 0 indicates no unimodality 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: 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: 1 if
higher values of the conditional feature should increase trust in the
main feature and -1 otherwise.
|
monotonic_dominances
|
None or iterable of two-element tuples. First element
is the index of the dominant feature. Second element is the index of the
weak feature.
|
range_dominances
|
None or iterable of two-element tuples. First element is
the index of the dominant feature. Second element is the index of the weak
feature.
|
joint_monotonicities
|
None or iterable of two-element tuples. Each tuple
represents a pair of feature indices that require joint monotoniticity.
|
joint_unimodalities
|
None or tuple or iterable of tuples. Each tuple
represents indices of single group of jointly unimodal features followed
by 'valley' or 'peak'.
|
num_iterations
|
number of iterations of Dykstra's algorithm.
|
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.
[null,null,["Last updated 2024-08-02 UTC."],[],[],null,["# tfl.lattice_lib.project_by_dykstra\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/lattice_lib.py#L1830-L2071) |\n\nApplies dykstra's projection algorithm for monotonicity/trust constraints. \n\n tfl.lattice_lib.project_by_dykstra(\n weights,\n lattice_sizes,\n monotonicities=None,\n unimodalities=None,\n edgeworth_trusts=None,\n trapezoid_trusts=None,\n monotonic_dominances=None,\n range_dominances=None,\n joint_monotonicities=None,\n joint_unimodalities=None,\n num_iterations=1\n )\n\n- Returns honest projection with respect to L2 norm if num_iterations is inf.\n- Monotonicity will be violated by some small eps(num_iterations).\n- Complexity: O(num_iterations \\* (num_monotonic_dims + num_trust_constraints)\n - num_lattice_weights)\n\nDykstra's alternating projections algorithm projects into intersection of\nseveral convex sets. For algorithm description itself use Google or Wiki:\n\u003chttps://en.wikipedia.org/wiki/Dykstra%27s_projection_algorithm\u003e\n\nHere, each monotonicity constraint is split up into 2 independent convex sets\neach trust constraint is split up into 4 independent convex sets. These sets\nare then projected onto exactly (in L2 space). For more details, see the\n_project*partial*\\* functions.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `weights` | `Lattice` weights tensor of shape: `(prod(lattice_sizes), units)`. |\n| `lattice_sizes` | list or tuple of integers which represents lattice sizes. which correspond to weights. |\n| `monotonicities` | None or 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. |\n| `unimodalities` | None or list or tuple of same length as lattice_sizes of {-1, 0, 1} which represents unimodality constraints per dimension. 1 indicates that function first decreases then increases, -1 indicates that function first increases then decreases, 0 indicates no unimodality constraints. |\n| `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: 1 if higher values of the conditional feature should increase trust in the main feature and -1 otherwise. |\n| `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: 1 if higher values of the conditional feature should increase trust in the main feature and -1 otherwise. |\n| `monotonic_dominances` | None or iterable of two-element tuples. First element is the index of the dominant feature. Second element is the index of the weak feature. |\n| `range_dominances` | None or iterable of two-element tuples. First element is the index of the dominant feature. Second element is the index of the weak feature. |\n| `joint_monotonicities` | None or iterable of two-element tuples. Each tuple represents a pair of feature indices that require joint monotoniticity. |\n| `joint_unimodalities` | None or tuple or iterable of tuples. Each tuple represents indices of single group of jointly unimodal features followed by 'valley' or 'peak'. |\n| `num_iterations` | number of iterations of Dykstra's 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 of same shape as `weights`. ||\n\n\u003cbr /\u003e"]]