Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/nngraph.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/init.lua b/init.lua
index 9b117a6..1eae7cb 100644
--- a/init.lua
+++ b/init.lua
@@ -27,16 +27,24 @@ function Module:__call__(...)
local input = ...
if nArgs == 1 and input == nil then
- error('what is this in the input? nil')
+ error(utils.expectingNodeErrorMessage(input, 'inputs', 1))
+ end
+ -- Disallow passing empty table, in case someone passes a table with some
+ -- typo'd variable name in.
+ if type(input) == 'table' and next(input) == nil then
+ error('cannot pass an empty table of inputs. To indicate no incoming ' ..
+ 'connections, leave the second set of parens blank.')
end
if not istable(input) then
input = {input}
end
local mnode = nngraph.Node({module=self})
- for i,dnode in ipairs(input) do
+ local dnode
+ for i = 1, utils.tableMaxN(input) do
+ dnode = input[i]
if torch.typename(dnode) ~= 'nngraph.Node' then
- error('what is this in the input? ' .. tostring(dnode))
+ error(utils.expectingNodeErrorMessage(dnode, 'inputs', i))
end
mnode:add(dnode,true)
end