diff options
author | fsuzanomassa <fvsmassa@gmail.com> | 2015-01-16 23:10:52 +0300 |
---|---|---|
committer | fsuzanomassa <fvsmassa@gmail.com> | 2015-01-16 23:10:52 +0300 |
commit | 98cf6f146be4e032396daa0da12d5f181537d6a9 (patch) | |
tree | b36eeb39773c8a84c9154af75218ac38ea922137 /test.lua | |
parent | e8fadc69a11fb24829cafbe800e6a6e4948899fd (diff) |
Added SpatialAdaptiveMaxPooling
Diffstat (limited to 'test.lua')
-rw-r--r-- | test.lua | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -1678,6 +1678,37 @@ function nntest.SpatialAveragePooling() mytester:assertTensorEq(gradInput, gradInput2, 0.000001, torch.typename(module) .. ' backward err (Batch) ') end +function nntest.SpatialAdaptiveMaxPooling() + local from = math.random(1,5) + local ki = math.random(1,12) + local kj = math.random(1,12) + local ini = math.random(1,64) + local inj = math.random(1,64) + + local module = nn.SpatialAdaptiveMaxPooling(ki,kj) + local input = torch.rand(from,ini,inj) + + local err = jac.testJacobian(module, input) + mytester:assertlt(err, precision, 'error on state ') + + local ferr, berr = jac.testIO(module, input) + mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') + mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') + + -- batch + local nbatch = math.random(2,5) + input = torch.rand(nbatch,from,ini,inj) + module = nn.SpatialAdaptiveMaxPooling(ki,kj) + + local err = jac.testJacobian(module, input) + mytester:assertlt(err, precision, 'error on state (Batch) ') + + local ferr, berr = jac.testIO(module, input) + mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err (Batch) ') + mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err (Batch) ') + +end + function nntest.SpatialLPPooling() local fanin = math.random(1,4) local osizex = math.random(1,4) |