torch / nngraph

Graph Computation for nn
Other
299 stars 96 forks source link

gmodule table outputs inconsistency #127

Closed ghost closed 8 years ago

ghost commented 8 years ago

I was trying to model a GRU network that outputs the hidden state, and the number of elements depends on the number of layers (for example, an LSTM module that outputs states depending on number of layers).

When I use a single layer GRU, which outputs only one hidden state tensor, the output is only the tensor instead of a table with the tensor as the only element. This makes it difficult to incorporate the number of layers as a parameter. Is there any way to avoid this from happening?

soumith commented 8 years ago

What if you put the GRU layer in a nn.ConcatTable? The input and output are now tables of a single element.

ghost commented 8 years ago

Yes, that would work. Thank you. Btw, is this a feature or a bug in gmodule? If it's a feature, what purpose does it serve?

soumith commented 8 years ago

i think it's the way the GRU is constructed. Not a bug or a feature per se. I guess just how it works...