diff options
-rw-r--r-- | Jacobian.lua | 2 | ||||
-rw-r--r-- | generic/Square.c | 2 | ||||
-rw-r--r-- | test/test.lua | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/Jacobian.lua b/Jacobian.lua index a46cd43..16397a9 100644 --- a/Jacobian.lua +++ b/Jacobian.lua @@ -168,7 +168,7 @@ function nn.Jacobian.testIO(module,input, minval, maxval) -- read module local m = torch.DiskFile('tmp.bin'):binary():readObject() m:forward(input) - module:zeroGradParameters() + m:zeroGradParameters() m:updateGradInput(input,go) m:accGradParameters(input,go) -- cleanup diff --git a/generic/Square.c b/generic/Square.c index 33feaa9..4e20116 100644 --- a/generic/Square.c +++ b/generic/Square.c @@ -40,7 +40,7 @@ static int nn_(Square_updateGradInput)(lua_State *L) !THTensor_(isContiguous)(gradInput)) { TH_TENSOR_APPLY3(real, gradInput, real, gradOutput, real, input, \ - *gradInput_data = (*gradOutput_data) * (*input_data);); + *gradInput_data = 2.0 * (*gradOutput_data) * (*input_data);); } else { diff --git a/test/test.lua b/test/test.lua index ff8b0d9..0d4a979 100644 --- a/test/test.lua +++ b/test/test.lua @@ -82,10 +82,10 @@ function nntest.Log() local input = torch.Tensor(ini,inj,ink):zero() local module = nn.Log() - local err = jac.testJacobian(module,input) + local err = jac.testJacobian(module,input, 0.1, 10) mytester:assertlt(err,precision, 'error on state ') - local ferr,berr = jac.testIO(module,input) + local ferr,berr = jac.testIO(module,input, 0.1, 10) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end |