tfl.linear_lib.project

View source on GitHub

Applies constraints to weights.

tfl.linear_lib.project(
    weights,
    monotonicities,
    monotonic_dominances=None,
    normalization_order=None
)

Args:

  • weights: Tensor which represents weights of TFL linear layer. Must have shape [len(monotonicities), 1].
  • monotonicities: List or tuple of same length as number of elements in 'weights' of {-1, 0, 1} which represent monotonicity constraints per dimension. -1 stands for decreasing, 0 for no constraints, 1 for increasing.
  • monotonic_dominances: List of two-element tuples. First element is the index of the dominant feature. Second element is the index of the weak feature.
  • normalization_order: If specified weights will be adjusted to have norm 1. Norm will be computed by: tf.norm(tensor, ord=normalization_order).

Raises:

  • ValueError: If shape of weights is not (len(monotonicities), 1).

Returns:

'weights' with monotonicity constraints and normalization applied to it.