I want to fix zero index embedding vector to zero vector.
For example,
embedding layer input: [0, 1, 2, 0, 3]
embedding layer output:
[
[0, 0, 0, 0, 0],
[ (some vector) ],
[ (some vector) ],
[0, 0, 0, 0, 0],
[ (some vector) ]
]
I found mask_zero option in Keras Embedding layer, but it's not one I want...
FYI, my purpose to do this is:
- Input: Tensor → shape
(batch_size, input_size) - Look-up embedding using the input tensor → shape
(batch_size, input_size, embedding_size) - Do sum pooling for axis 1 → shape
(batch_size, 1, embedding_size)
How can I implement this? I tried to mask the input tensor using tf.ragged.boolean_mask, but it is slower and I think it is overkill.