第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > 【一看就懂】tf.logical_and() tf.logical_or() tf.logical_not() tf.logical_xor()

【一看就懂】tf.logical_and() tf.logical_or() tf.logical_not() tf.logical_xor()

时间:2022-11-27 00:52:19

相关推荐

【一看就懂】tf.logical_and() tf.logical_or() tf.logical_not() tf.logical_xor()

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])

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。