diff options
author | koray kavukcuoglu <koray@kavukcuoglu.org> | 2014-02-13 22:21:30 +0400 |
---|---|---|
committer | koray kavukcuoglu <koray@kavukcuoglu.org> | 2014-02-13 22:21:30 +0400 |
commit | 439a3375c2d47a00e1902fae4938d766dcf2ea50 (patch) | |
tree | 264aec34caa19c4d4420bfc48d75b41e22b99c07 | |
parent | 36dda4a343822e416fb2ee52fb6396b7d9783c24 (diff) | |
parent | ff1dd3f21ee004560c9601edf20751d87e03cffc (diff) |
Merge pull request #21 from fidlej/topic_backward_compatible_nInputs
Added backward compatibity for graph with no self.nInputs
-rw-r--r-- | gmodule.lua | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gmodule.lua b/gmodule.lua index 0190121..e8cc1b2 100644 --- a/gmodule.lua +++ b/gmodule.lua @@ -127,11 +127,13 @@ function gModule:runForwardFunction(func,input) local func_name = func func = function(module,input) return module[func_name](module,input) end end + -- For backward compatibility, we allow self.nInputs to be missing. + local nInputs = self.nInputs or #self.innode.children -- We see the input as a list of inputs. - if self.nInputs <= 1 then + if nInputs <= 1 then input={input} elseif type(input) ~= "table" then - error(string.format("expecting %s inputs", self.nInputs)) + error(string.format("expecting %s inputs", nInputs)) end local function neteval(node) local function propagate(node,x) @@ -171,8 +173,8 @@ function gModule:runForwardFunction(func,input) end local innode = self.innode - if #input ~= self.nInputs then - error(string.format('Got %s inputs instead of %s', #input, self.nInputs)) + if #input ~= nInputs then + error(string.format('Got %s inputs instead of %s', #input, nInputs)) end -- first clear the input states innode:bfs(function(node) |