# tf.debugging.Assert

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/control_flow_assert.py#L62-L130) |

Asserts that the given condition is true.

#### View aliases


**Main aliases**

[`tf.Assert`](https://www.tensorflow.org/api_docs/python/tf/debugging/Assert)
**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.Assert`](https://www.tensorflow.org/api_docs/python/tf/debugging/Assert), [`tf.compat.v1.debugging.Assert`](https://www.tensorflow.org/api_docs/python/tf/debugging/Assert)

<br />

    tf.debugging.Assert(
        condition, data, summarize=None, name=None
    )

If `condition` evaluates to false, print the list of tensors in `data`.
`summarize` determines how many entries of the tensors to print.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `condition` | The condition to evaluate. |
| `data` | The tensors to print out when condition is false. |
| `summarize` | Print this many entries of each tensor. |
| `name` | A name for this operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `assert_op` | An `Operation` that, when executed, raises a [`tf.errors.InvalidArgumentError`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/errors/InvalidArgumentError) if `condition` is not true. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|

<br />

> [!NOTE]
> **Note:** The output of this function should be used. If it is not, a warning will be logged or an error may be raised. To mark the output as used, call its .mark_used() method.

<br />

## TF1 compatibility

<br />

When in TF V1 mode (that is, outside [`tf.function`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/function)) Assert needs a control
dependency on the output to ensure the assertion executes:

    # Ensure maximum element of x is smaller or equal to 1
    assert_op = tf.Assert(tf.less_equal(tf.reduce_max(x), 1.), [x])
    with tf.control_dependencies([assert_op]):
      ... code using x ...

<br />

<br />

<br />

## eager compatibility

<br />

returns None

<br />

<br />