Python | Tensorflow logical_xor() method Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Tensorflow is an open-source machine learning library developed by Google. One of its applications is to develop deep neural networks. The module tensorflow.math provides support for many basic logical operations. Function tf.logical_xor() [alias tf.math.logical_xor] provides support for the logical XOR function in Tensorflow. It expects the inputs of bool type. The input types are tensor and if the tensors contains more than one element, an element-wise logical XOR is computed, $x XOR y = (x \| \, y) \, \&\& \, ^^21(x \&\& y)$ . Syntax: tf.logical_xor(x, y, name=None) or tf.math.logical_xor(x, y, name=None) Parameters: x: A Tensor of type bool. y: A Tensor of type bool. name (optional): The name for the operation. Return type: A Tensor of bool type with the same size as that of x or y. Code: Python3 # Importing the Tensorflow library import tensorflow as tf # A constant vector of size 4 a = tf.constant([True, False, True, False], dtype = tf.bool) b = tf.constant([True, False, False, True], dtype = tf.bool) # Applying the XOR function and # storing the result in 'c' c = tf.logical_xor(a, b, name ='logical_xor') # Initiating a Tensorflow session with tf.Session() as sess: print('Input type:', a) print('Input a:', sess.run(a)) print('Input b:', sess.run(b)) print('Return type:', c) print('Output:', sess.run(c)) Output: Input type: Tensor("Const:0", shape=(4, ), dtype=bool) Input a: [ True False True False] Input b: [ True False False True] Return type: Tensor("logical_xor:0", shape=(4, ), dtype=bool) Output: [False False True True] Comment More infoAdvertise with us Next Article Python | Tensorflow logical_or() method S sanskar27jain Follow Improve Article Tags : Python AI-ML-DS With Python Practice Tags : python Similar Reads Python | Tensorflow logical_or() method Tensorflow is an open-source machine learning library developed by Google. One of its applications is to develop deep neural networks. The module tensorflow.math provides support for many basic mathematical operations. Function tf.logical_or() [alias tf.math.logical_or] provides support for the logi 2 min read Python | Tensorflow logical_and() method Tensorflow is an open-source machine learning library developed by Google. One of its applications is to develop deep neural networks. The module tensorflow.math provides support for many basic logical operations. Function tf.logical_and() [alias tf.math.logical_and] provides support for the logical 2 min read Python | Tensorflow logical_not() method Tensorflow is an open-source machine learning library developed by Google. One of its applications is to develop deep neural networks. The module tensorflow.math provides support for many basic logical operations. Function tf.logical_not() [alias tf.math.logical_not or tf.Tensor.__invert__] provides 2 min read Python | Tensorflow abs() method Tensorflow is an open-source machine learning library developed by Google. One of its applications is to develop deep neural networks. The module tensorflow.math provides support for many basic mathematical operations. Function tf.abs() [alias tf.math.abs] provides support for the absolute function 3 min read Tensorflow bitwise.bitwise_xor() method - Python Tensorflow bitwise.bitwise_xor() method performs the bitwise_xor operation and the result will set those bits, that are different in a and b. The operation is done on the representation of a and b. This method belongs to bitwise module. Syntax: tf.bitwise.bitwise_xor(a, b, name=None) Arguments a: Th 2 min read Python - tensorflow.math.xlogy() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks. xlogy() is used to compute element wise x * log(y). Syntax: tensorflow.math.xlogy(x, y, name) Parameters: x: It's a tensor. Allowed dtypes are half, float32, float64, com 2 min read Like