<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/modeling/tf_utils.py#L174-L197) |

Raises an exception if the tensor rank is not of the expected rank.

    tfm.utils.assert_rank(
        tensor, expected_rank, name=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `tensor` | A tf.Tensor to check the rank of. |
| `expected_rank` | Python integer or list of integers, expected rank. |
| `name` | Optional name of the tensor for the error message. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If the expected shape doesn't match the actual shape. |

<br />