tf.math.equal
Stay organized with collections
Save and categorize content based on your preferences.
Returns the truth value of (x == y) element-wise.
tf.math.equal(
x, y, name=None
)
Used in the notebooks
Used in the guide |
Used in the tutorials |
|
|
Performs a broadcast 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])>
Returns |
A tf.Tensor of type bool with the same size as that of x or y.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.math.equal\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/math_ops.py#L1784-L1818) |\n\nReturns the truth value of (x == y) element-wise.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.equal`](https://www.tensorflow.org/api_docs/python/tf/math/equal)\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`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)\n\n\u003cbr /\u003e\n\n tf.math.equal(\n x, y, name=None\n )\n\n### Used in the notebooks\n\n| Used in the guide | Used in the tutorials |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [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 tff.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) |\n\nPerforms a [broadcast](https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) with the\narguments and then an element-wise equality comparison, returning a Tensor of\nboolean values.\n\n#### For example:\n\n x = tf.constant([2, 4])\n y = tf.constant(2)\n tf.math.equal(x, y)\n \u003ctf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, False])\u003e\n\n x = tf.constant([2, 4])\n y = tf.constant([2, 4])\n tf.math.equal(x, y)\n \u003ctf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, True])\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------|--------------------------------------|\n| `x` | A [`tf.Tensor`](../../tf/Tensor). |\n| `y` | A [`tf.Tensor`](../../tf/Tensor). |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A [`tf.Tensor`](../../tf/Tensor) of type bool with the same size as that of x or y. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|---|---|\n| [`tf.errors.InvalidArgumentError`](../../tf/errors/InvalidArgumentError): If shapes of arguments are incompatible ||\n\n\u003cbr /\u003e"]]