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
path: root/test
diff options
context:
space:
mode:
authorNicholas Leonard <nick@nikopia.org>2014-04-10 06:40:13 +0400
committerNicholas Leonard <nick@nikopia.org>2014-04-10 06:40:13 +0400
commite5fbc5b3ee23207978b16f017153b4a67b98fcf1 (patch)
tree7cad48ccc05696880e4648ba5dcc84c761bd0654 /test
parent6783768eb6e06ebbf0c1bd2d6b5f4bc9f709b32f (diff)
unit tests complete
Diffstat (limited to 'test')
-rw-r--r--test/test.lua36
1 files changed, 14 insertions, 22 deletions
diff --git a/test/test.lua b/test/test.lua
index 91b38e8..cea1a53 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -1650,52 +1650,44 @@ function nntest.LookupTable()
local totalIndex = math.random(10,100)
local nIndex = math.random(5,7)
local entry_size = math.random(5,7)
- local input = torch.Tensor(nIndex):zero()
+ local input = torch.IntTensor(nIndex):zero()
local module = nn.LookupTable(totalIndex, entry_size)
local minval = 1
local maxval = totalIndex
-- 1D
local err = jac.testJacobianParameters(module, input, module.weight, module.gradWeight, minval, maxval)
- mytester:assertlt(err,precision, 'error on weight ')
+ mytester:assertlt(err,precision, '1D error on weight ')
local err = jac.testJacobianUpdateParameters(module, input, module.weight, minval, maxval)
- mytester:assertlt(err,precision, 'error on weight [direct update] ')
+ mytester:assertlt(err,precision, '1D error on weight [direct update] ')
module.gradWeight:zero()
for t,err in pairs(jac.testAllUpdate(module, input, 'weight', 'gradWeight')) do
mytester:assertlt(err, precision, string.format(
- 'error on weight [%s]', t))
+ '1D error on weight [%s]', t))
end
-- 2D
local nframe = math.random(50,70)
- local input = torch.Tensor(nframe, nIndex):zero()
-
- local err = jac.testJacobianParameters(module, input, module.weight, module.gradWeight)
- mytester:assertlt(err,precision, 'error on weight ')
-
- local err = jac.testJacobianParameters(module, input, module.bias, module.gradBias)
- mytester:assertlt(err,precision, 'error on weight ')
-
- local err = jac.testJacobianUpdateParameters(module, input, module.weight)
- mytester:assertlt(err,precision, 'error on weight [direct update] ')
+ local input = torch.IntTensor(nframe, nIndex):zero()
- local err = jac.testJacobianUpdateParameters(module, input, module.bias)
- mytester:assertlt(err,precision, 'error on bias [direct update] ')
+ local err = jac.testJacobianParameters(module, input, module.weight, module.gradWeight, minval, maxval)
+ mytester:assertlt(err,precision, '2D error on weight ')
+
+ local err = jac.testJacobianUpdateParameters(module, input, module.weight, minval, maxval)
+ mytester:assertlt(err,precision, '2D error on weight [direct update] ')
+ module.gradWeight:zero()
for t,err in pairs(jac.testAllUpdate(module, input, 'weight', 'gradWeight')) do
mytester:assertlt(err, precision, string.format(
- 'error on weight [%s]', t))
+ '2D error on weight [%s]', t))
end
- for t,err in pairs(jac.testAllUpdate(module, input, 'bias', 'gradBias')) do
- mytester:assertlt(err, precision, string.format(
- 'error on bias [%s]', t))
- end
-- IO
- local ferr,berr = jac.testIO(module,input)
+ module.gradInput = torch.Tensor(3,4):zero() --fixes an error
+ local ferr,berr = jac.testIO(module,input,minval,maxval)
mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ')
mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ')
end