torch / nngraph

Graph Computation for nn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gmodule table outputs inconsistency

san25dec opened this issue · comments

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?

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

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?

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