【发布时间】:2018-02-12 17:40:27
【问题描述】:
我在张量流中有两个二进制张量。我想将它们都转换为布尔张量(按元素),并且基本上得到一个“交集”,一个逻辑与。然而,在转换为布尔值以及 logical_and 部分中似乎出现了问题。我做错了什么?
sess = tf.InteractiveSession()
x = tf.random_uniform([1, 10], dtype=tf.int32, maxval=2))
y = tf.random_uniform([1, 10], dtype=tf.int32, maxval=2))
print(x.eval())
print(y.eval())
x = tf.cast(x, tf.bool)
y = tf.cast(y, tf.bool)
print(x.eval())
print(y.eval())
intersect = tf.logical_and(x, y)
print(intersect.eval())
这会产生以下输出:
[[0 0 1 1 0 1 0 0 1 1]]
[[0 1 0 0 1 0 1 0 0 1]]
[[False True True True True False False True True True]]
[[False True True True True True True False True True]]
[[False False True True False False False False False True]]
【问题讨论】:
标签: tensorflow logical-operators tensor