# tfl.utils.canonicalize_monotonicities

<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/utils.py#L128-L154) |

Converts string constants representing monotonicities into integers.

    tfl.utils.canonicalize_monotonicities(
        monotonicities, allow_decreasing=True
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `monotonicities` | monotonicities hyperparameter of a [`tfl.layers`](https://www.tensorflow.org/lattice/api_docs/python/tfl/layers) Layer (e.g. [`tfl.layers.Lattice`](https://www.tensorflow.org/lattice/api_docs/python/tfl/layers/Lattice)). |
| `allow_decreasing` | If decreasing monotonicity is considered a valid monotonicity. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A list of monotonicities represented as -1, 0, 1, or the value None if monotonicities is None. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If one of monotonicities is not in the set {-1, 0, 1, 'decreasing', 'none', 'increasing'} and allow_decreasing is True. |
| `ValueError` | If one of monotonicities is not in the set {0, 1, 'none', 'increasing'} and allow_decreasing is False. |

<br />