I have a placeholder with dynamic size A( batch size, sequence size, 5) and another placeholder with zero and one values and dynamic size B( batch size, sequence size). I want to use the second 2D placeholder for masking the first placeholders as if the value of tensor B[0][0]=0 then A[0][0][0:5] will be set to zero and if it was equal to B[0][0]=1 then A[0][0][0:5] won't change.
palceholder A:(shape=(2,2,5))
[[[ 1, 2, 3, 1, 4],
[ 2, 3, 5, 2, 4]],
[[ 2, 7, 5, 8, 1],
[ 4, 5, 1, 3, 9]]]
palceholder B:(shape=(2,2))
[[ 1, 0],
[ 0, 1]]
Tensor C= Mask(A,B)
[[[ 1, 2, 3, 1, 4],
[ 0, 0, 0, 0, 0]],
[[ 0, 0, 0, 0, 0],
[ 4, 5, 1, 3, 9]]]
I have tried tf.boolean_mask but it doesn't work for dynamic size masks.