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

github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Collobert <ronan@collobert.com>2012-12-06 15:31:40 +0400
committerRonan Collobert <ronan@collobert.com>2012-12-06 15:31:40 +0400
commitd355ce6faf2c9601515fb582d753bbd0b689ea93 (patch)
tree2ca04c6b77cacf291d2cb03ba9f81934afe0120c
parent0960cb968f46da4ca582ebf219274a4de519390b (diff)
fix Jacobian when using direct-updates
-rw-r--r--Jacobian.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/Jacobian.lua b/Jacobian.lua
index 16397a9..97237e8 100644
--- a/Jacobian.lua
+++ b/Jacobian.lua
@@ -40,10 +40,16 @@ function nn.Jacobian.backwardUpdate (module, input, param)
local jacobian = torch.Tensor(param:nElement(),dout:nElement()):zero()
-- original param
- local origparam = param:clone()
+ local params = module:parameters()
+ local origparams = {}
+ for j=1,#params do
+ table.insert(origparams, params[j]:clone())
+ end
for i=1,sdout:nElement() do
- param:copy(origparam)
+ for j=1,#params do
+ params[j]:copy(origparams[j])
+ end
dout:zero()
sdout[i] = 1
local din = module:updateGradInput(input, dout)
@@ -51,7 +57,9 @@ function nn.Jacobian.backwardUpdate (module, input, param)
jacobian:select(2,i):copy(param)
end
- param:copy(origparam)
+ for j=1,#params do
+ params[j]:copy(origparams[j])
+ end
return jacobian
end