<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/ops/math_ops.py#L1897-L1931) |

Returns the truth value of (x != y) element-wise.

#### View aliases


**Main aliases**

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

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

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

<br />

    tf.math.not_equal(
        x, y, name=None
    )

### Used in the notebooks

| Used in the guide | Used in the tutorials |
|---|---|
| - [tf.data: Build TensorFlow input pipelines](https://www.tensorflow.org/guide/data) - [Understanding masking \& padding](https://www.tensorflow.org/guide/keras/understanding_masking_and_padding) - [Unicode strings](https://www.tensorflow.org/text/guide/unicode) | - [Tutorial on Multi Armed Bandits in TF-Agents](https://www.tensorflow.org/agents/tutorials/bandits_tutorial) |

Performs a [broadcast](https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) with the
arguments and then an element-wise inequality comparison, returning a Tensor
of boolean values.

#### For example:

    x = tf.constant([2, 4])
    y = tf.constant(2)
    tf.math.not_equal(x, y)
    <tf.Tensor: shape=(2,), dtype=bool, numpy=array([False,  True])>

    x = tf.constant([2, 4])
    y = tf.constant([2, 4])
    tf.math.not_equal(x, y)
    <tf.Tensor: shape=(2,), dtype=bool, numpy=array([False,  False])>

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | A [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor). |
| `y` | A [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor). |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of type bool with the same size as that of x or y. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| [`tf.errors.InvalidArgumentError`](https://www.tensorflow.org/api_docs/python/tf/errors/InvalidArgumentError): If shapes of arguments are incompatible ||

<br />