# tf.math.equal

<br />

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

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

#### View aliases


**Main aliases**

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

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

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

<br />

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

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

#### For example:

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

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

<br />

<br />

<br />

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

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A [`tf.Tensor`](https://www.tensorflow.org/versions/r2.7/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/versions/r2.7/api_docs/python/tf/errors/InvalidArgumentError): If shapes of arguments are incompatible ||

<br />