wojzaremba / lstm

Apache License 2.0
663 stars 284 forks source link

why split gates along dimension 2? #17

Open yuhonglin opened 8 years ago

yuhonglin commented 8 years ago

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!

junwei-pan commented 8 years ago

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

hohoCode commented 8 years ago

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.