tf.logical_and(a, b):与tf.logical_or(a, b):或tf.logical_not(a):非tf.logical_xor(a, b):异或
a, b 也可以是列表。
例1:tf.logical_and(a, b) 与
sess = tf.Session()sess.run(tf.logical_and(True, False)) # FalseA = [True, True, False, False]B = [True, False, True, False]sess.run(tf.logical_and(A,B)) # array([ True, False, False, False])
例2:tf.logical_or(a, b) 或
sess = tf.Session()sess.run(tf.logical_or(True, False)) # TrueA = [True, True, False, False]B = [True, False, True, False]sess.run(tf.logical_or(A,B)) # array([ True, True, True, False])
例3:tf.logical_not(a) 非
sess = tf.Session()sess.run(tf.logical_not(True)) # Falsesess.run(tf.logical_not([True, False])) # array([False, True])
例4:tf.logical_xor(a, b) 异或
sess = tf.Session()A = [True, True, False, False]B = [True, False, True, False]sess.run(tf.logical_xor(A,B)) # array([False, True, True, False])