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:
authorkoray kavukcuoglu <koray@kavukcuoglu.org>2013-07-17 17:09:56 +0400
committerkoray kavukcuoglu <koray@kavukcuoglu.org>2013-07-17 17:09:56 +0400
commit894e7976301aab34b125eb9244fc5d0a4040daa8 (patch)
tree21e2c96a520fbadac6179e0fd43c0f79f7f8a8fd
parent42402eb04e47e0bf872726c1188ca0fdd199f224 (diff)
parent7573d43bdf403484ec69e70f0de9d83ead657134 (diff)
Merge pull request #7 from fidlej/topic_run_func
Allowed to pass a function to runForwardFunction()
-rw-r--r--gmodule.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/gmodule.lua b/gmodule.lua
index 4b4f5f1..44e1f39 100644
--- a/gmodule.lua
+++ b/gmodule.lua
@@ -56,7 +56,11 @@ function gModule:updateOutput(input)
return self:runForwardFunction('updateOutput',input)
end
-function gModule:runForwardFunction(func_name,input)
+function gModule:runForwardFunction(func,input)
+ if type(func) == "string" then
+ local func_name = func
+ func = function(module,input) return module[func_name](module,input) end
+ end
-- we will assume that the input is either a table of stuff
-- if not we will put it in a table of stuff
if torch.typename(input) or type(input) ~= 'table' then
@@ -103,7 +107,7 @@ function gModule:runForwardFunction(func_name,input)
input = input[1]
end
-- forward through this node
- local output = module[func_name](module,input)
+ local output = func(module,input)
-- propagate the output to children
propagate(node,output)
elseif node.data.criterion then