Element-Research / rnn

Recurrent Neural Network library for Torch7's nn
BSD 3-Clause "New" or "Revised" License
941 stars 313 forks source link

Error when using dropout in GRU #415

Open Trojahn opened 7 years ago

Trojahn commented 7 years ago

The following toy example works:

require 'rnn'

model = nn.Sequential() model:add(nn.GRU(10, 5, 20)) model:add(nn.GRU(5, 1, 20)) model:add(nn.Sigmoid()) model = nn.Sequencer(model)

t = torch.Tensor(20,10) model:forward(t) print(model.output)

But using the available dropout parameter don't:

require 'rnn'

model = nn.Sequential() model:add(nn.GRU(10, 5, 20, 0.25)) model:add(nn.GRU(5, 1, 20)) model:add(nn.Sigmoid()) model = nn.Sequencer(model)

t = torch.Tensor(20,10) model:forward(t) print(model.output)

The error itself... In 1 module of nn.Sequential: In 1 module of nn.Sequential: In 2 module of nn.ConcatTable: In 1 module of nn.Sequential: In 1 module of nn.ParallelTable: In 3 module of nn.Sequential: bad argument #2 to '?' (out of bounds at /tmp/luarocks_torch-scm-1-9229/torch7/lib/TH/generic/THStorage.c:202) ...

tastyminerals commented 7 years ago

Check your input to the model, it is probably one dimensional but should be two dimensional.