Converts string constants representing monotonicity into integers.
tfl.utils.canonicalize_monotonicity(
monotonicity, allow_decreasing=True
)
Args |
monotonicity
|
The monotonicities hyperparameter of a tfl.layers Layer
(e.g. tfl.layers.PWLCalibration ).
|
allow_decreasing
|
If decreasing monotonicity is considered a valid
monotonicity.
|
Returns |
monotonicity represented as -1, 0, 1, or None.
|
Raises |
ValueError
|
If monotonicity is not in the set
{-1, 0, 1, 'decreasing', 'none', 'increasing'} and allow_decreasing is
True.
|
ValueError
|
If monotonicity is not in the set {0, 1, 'none', 'increasing'}
and allow_decreasing is False.
|