hotpotqa / hotpot

Apache License 2.0
445 stars 75 forks source link

RNN dimension order mismatch? #9

Closed YeDeming closed 5 years ago

YeDeming commented 5 years ago

Hi, Kimi

Thanks for your opening source the code.

I found the input of torch.nn.GRU (https://pytorch.org/docs/0.3.0/nn.html#torch.nn.GRU):

-- input (seq_len, batch, input_size): tensor containing the features of the input sequence. The input can also be a packed variable length sequence. See torch.nn.utils.rnn.pack_padded_sequence() for details. -- h_0 (num_layers * num_directions, batch, hidden_size): tensor containing the initial hidden state for each element in the batch.

But in EncoderRNN (https://github.com/hotpotqa/hotpot/blob/master/model.py)

bsz, slen = input.size(0), input.size(1)
output = input
...
output, hidden = self.rnns[i](output, hidden)

The input size is (batch_size,seq_len,input_size), it doesn't seem to match the document for pytorch?

Deming Ye Best Wish

YeDeming commented 5 years ago

I found my fault