<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#L1860-L1894) |

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
    )

### Used in the notebooks

| Used in the guide | Used in the tutorials |
|---|---|
| - [Multilayer perceptrons for digit recognition with Core APIs](https://www.tensorflow.org/guide/core/mlp_core) - [Distributed training with Core APIs and DTensor](https://www.tensorflow.org/guide/core/distribution) - [Extension types](https://www.tensorflow.org/guide/extension_type) - [MinDiff Data Preparation](https://www.tensorflow.org/responsible_ai/model_remediation/min_diff/guide/min_diff_data_preparation) | - [Tutorial on Multi Armed Bandits in TF-Agents](https://www.tensorflow.org/agents/tutorials/bandits_tutorial) - [Classify Flowers with Transfer Learning](https://www.tensorflow.org/hub/tutorials/image_feature_vector) - [Federated Learning for Image Classification](https://www.tensorflow.org/federated/tutorials/federated_learning_for_image_classification) - [Sending Different Data To Particular Clients With federated_language.federated_select](https://www.tensorflow.org/federated/tutorials/federated_select) - [End to end example for BigQuery TensorFlow reader](https://www.tensorflow.org/io/tutorials/bigquery) |

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/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 />