arrays - Binary mask in Tensorflow -
i mask every other value along particular dimension of tensor don't see way generate such mask. example
#masking on 2nd dimension = [[1,2,3,4,5],[6,7,8,9,0] mask = [[1,0,1,0,1],[1,1,1,1,1]] b = * mask #would return [[1,0,3,0,5],[6,0,8,0,0]]
is there easy way generate such mask?
ideally following:
mask = tf.ones_like(input_tensor) mask[:,::2] = 0 mask * input_tensor
but slice assigning doesn't seem simple in numpy.
you can programmatically create such tensor mask using python. convert tensor. there's no such support in tensorflow api. tf.tile([1,0], num_of_repeats) might fast way create such mask not great either if have odd number of columns.
(btw, if end creating boolean mask, use tf.boolean_mask())
Comments
Post a Comment