tf.math.logical_xor  |  TensorFlow v2.16.1 (original) (raw)

tf.math.logical_xor

Stay organized with collections Save and categorize content based on your preferences.

Logical XOR function.

View aliases

Compat aliases for migration

SeeMigration guide for more details.

tf.compat.v1.logical_xor, tf.compat.v1.math.logical_xor

tf.math.logical_xor(
    x, y, name='LogicalXor'
)

x ^ y = (x | y) & ~(x & y)

Requires that x and y have the same shape or havebroadcast-compatibleshapes. For example, x and y can be:

Usage:

a = tf.constant([True]) b = tf.constant([False]) tf.math.logical_xor(a, b) <tf.Tensor: shape=(1,), dtype=bool, numpy=array([ True])>

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

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

Args
x A tf.Tensor type bool.
y A tf.Tensor of type bool.
name A name for the operation (optional).
Returns
A tf.Tensor of type bool with the same size as that of x or y.