torch / nngraph

Graph Computation for nn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent Table Behavior

shawnjhenry opened this issue · comments

I noticed that feeding tables into nngraph nodes has inconsistent behavior. If I feed a node a table with multiple elements it treats the table as a table, however, if I feed it a table with a single element, it pops that element. Is this intentional? Here's a minimal example showing how it can cause trouble:

The module:

id1 = nn.Identity()()
id2 = nn.Identity()()
j = nn.JoinTable(1)({id1, id2})
net = nn.gModule({id1, id2}, {j})

behaves as expect when the input is a pair of tensors, producing their join. However:

id = nn.Identity()()
j = nn.JoinTable(1)({id})
net = nn.gModule({id}, {j})

produces an error in JoinTable (the input is not a table) because it pops the the value of id from the table before feeding it to JoinTable. I would like it to feed {id.output} into JoinTable in the latter case, just as it's feeding {id1.output, id2.output} in the former.

Yes, this is intended behaviour. Because nngraph does not (can not) make any assumptions about the receiving node if it is expecting a table or a tensor (like a linear). But now there is a workaround for these cases with recent change in #90