# tfl.kronecker_factored_lattice_lib.finalize_weight_constraints

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/kronecker_factored_lattice_lib.py#L394-L438) |

Approximately projects weights to strictly satisfy all constraints.

    tfl.kronecker_factored_lattice_lib.finalize_weight_constraints(
        weights, units, scale, monotonicities, output_min, output_max
    )

This projeciton guarantees that constraints are strictly met, but it is not
an exact projection w.r.t. the L2 norm. The computational cost is
`O(num_monotonic_dims * num_lattice_weights)`.

See helper functions `_approximately_project_*` for details of the individual
projection algorithms for each set of constraints.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `weights` | Kronecker-Factored Lattice weights tensor of shape: `(1, lattice_sizes, units * dims, num_terms)`. |
| `units` | Number of units per input dimension. |
| `scale` | Scale variable of shape: `(units, num_terms)`. |
| `monotonicities` | List or tuple of length dims of elements of {0,1} which represents monotonicity constraints per dimension. 1 stands for increasing (non-decreasing in fact), 0 for no monotonicity constraints. |
| `output_min` | None or minimum layer output. |
| `output_max` | None or maximum layer output. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Projected weights tensor of same shape as `weights`. ||

<br />