Logical Operators

TensorFlow provides several operations that you can use to add logical operators to your graph.

tf.logical_and(x, y, name=None)

Returns the truth value of x AND y element-wise.

NOTE: LogicalAnd supports broadcasting. More about broadcasting here

Args:
  • x: A Tensor of type bool.
  • y: A Tensor of type bool.
  • name: A name for the operation (optional).
Returns:

A Tensor of type bool.


tf.logical_not(x, name=None)

Returns the truth value of NOT x element-wise.

Args:
  • x: A Tensor of type bool.
  • name: A name for the operation (optional).
Returns:

A Tensor of type bool.


tf.logical_or(x, y, name=None)

Returns the truth value of x OR y element-wise.

NOTE: LogicalOr supports broadcasting. More about broadcasting here

Args:
  • x: A Tensor of type bool.
  • y: A Tensor of type bool.
  • name: A name for the operation (optional).
Returns:

A Tensor of type bool.


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

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