I have 2D matrix with shape [batch_size, seq_len]
where values of the 1st dimension are from range [0, num_classes - 1].
I also have another embedding matrix with shape [num_classes, embedding_size]
.
How can I transform 2D matrix to 3D with shape [batch_size, seq_len, embedding_size]
by replacing the class labels (scalar) in 2D matrix with its embedding vector?
I know how to implement it in for-loop way, but how it can be vectorized?