How to do matmul operation in specific dimension in tensorflow
I would first reshape your Tensor to be (sequence_length * batch_size, word_dim), do the matmul to get (sequence_length * batch_size, hidden_dim), then reshape again to get (sequence_length, batch_size, hidden_dim). There is no copying involved with reshape(), and this is equivalent to multiplying each of the batch_size matrices individually if you only have one matrix to multiply them with.
I have a 3D tensor (sequence_length, batch_size, word_dim), I need to do matmul operation with "word_dim" dimension so that I can change tensor into (sequence_length, batch_size, hidden_dim). It seems that matmul operation can only be used in 2D tensor. And I can not change the 3D tensor into 2D because of the "batch_size". How can I do?