tf.math.not_equal
Stay organized with collections
Save and categorize content based on your preferences.
Returns the truth value of (x != y) element-wise.
tf.math.not_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 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])>
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.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.math.not_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#L1821-L1855) |\n\nReturns the truth value of (x != y) element-wise.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.not_equal`](https://www.tensorflow.org/api_docs/python/tf/math/not_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.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)\n\n\u003cbr /\u003e\n\n tf.math.not_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| - [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) |\n\nPerforms a [broadcast](https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) with the\narguments and then an element-wise inequality comparison, returning a Tensor\nof boolean values.\n\n#### For example:\n\n x = tf.constant([2, 4])\n y = tf.constant(2)\n tf.math.not_equal(x, y)\n \u003ctf.Tensor: shape=(2,), dtype=bool, numpy=array([False, True])\u003e\n\n x = tf.constant([2, 4])\n y = tf.constant([2, 4])\n tf.math.not_equal(x, y)\n \u003ctf.Tensor: shape=(2,), dtype=bool, numpy=array([False, False])\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"]]