Imagine I have a tensor of shape (batch_size, a, ... , c, d, e)
where are a, ... ,c,d,e are defined integers. For example (batch_size, 500, 3, 2, 2, 69)
or (batch_size, 2, 2)
.
My question is for all tensors but let's stick to the example of tensor1.get_shape() = (?, 500, 3, 2, 2, 69)
Given that I have tensor2
with tensor2.get_shape() = (?, 500, 3, 2, 2, 14)
containing indices of the last axis of tensor1
, I have 2 problems:
1) I want to construct a mask for tensor1
of shape (?, 500, 3, 2, 2, 69)
from tensor2
. For example a possible row along the last axis for tensor2
would be [1,8,3,68,2,4,58,19,20,21,26,48,56,11]
but since tensor2
is constructed from tensor1
these indices vary for new input. These are the indices of the last axis that have to be kept of tensor1
. Everything else has to be masked out.
2) given that I have the mask of shape (?, 500, 3, 2, 2, 69)
for tensor1
, how do I mask out the undesired values while maintaining the batch size dimension? The masked out tensor should have shape (?, 500, 3, 2, 2, 14)
.
Answers in keras or numpy would also be neat, although knowing how to do it in numpy wouldn't solve my problem, I'd still like to know.