2020-06-05-tensorflow2-tf.boolea
2020-06-08 本文已影响0人
logi
原说明文档:https://www.tensorflow.org/api_docs/python/tf/boolean_mask
将原tensor进行mask,选取为true的元素,组成新的tensor
参数
tf.boolean_mask(
tensor, mask, axis=None, name='boolean_mask'
)

例子
# 2-D example
tensor = [[1, 2], [3, 4], [5, 6]]
mask = np.array([True, False, True])
boolean_mask(tensor, mask) # [[1, 2], [5, 6]]
