lstm icon indicating copy to clipboard operation
lstm copied to clipboard

why split gates along dimension 2?

Open yuhonglin opened this issue 9 years ago • 2 comments

Hi, I can not understand why in the following code, the reshaped_gates is split along dimension 2 rather than 1, since output of reshaped_gates is a 4 x rnn_size matrix.

  -- Reshape to (batch_size, n_gates, hid_size)
  -- Then slize the n_gates dimension, i.e dimension 2
  local reshaped_gates =  nn.Reshape(4,params.rnn_size)(gates)
  local sliced_gates = nn.SplitTable(2)(reshaped_gates)

Could anybody explain it? Thx in advance!

yuhonglin avatar Jan 05 '16 00:01 yuhonglin

Same question, I will do some experiment to check if this is a bug..

junwei-pan avatar Apr 27 '16 16:04 junwei-pan

The batch size is the No.1 dim; the 4 gates stuff is the No.2 dim. Plus nn.Reshape() supports batch processing. Therefore this is correct.

hohoCode avatar Apr 28 '16 01:04 hohoCode