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 .
|