diff options
author | Nicholas Leonard <nick@nikopia.org> | 2015-03-21 20:54:19 +0300 |
---|---|---|
committer | Nicholas Leonard <nick@nikopia.org> | 2015-03-26 02:54:57 +0300 |
commit | ba6f198873a888eeb065180b78ee6528b999412b (patch) | |
tree | 7e6db01f4c77f65ef72237f7b9963b716865d9d2 /test.lua | |
parent | 3c82eba291f96d0ce4fe611e8c80c7ebb20d5b47 (diff) |
Padding.lua
Diffstat (limited to 'test.lua')
-rw-r--r-- | test.lua | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -3301,6 +3301,24 @@ function nntest.SpatialBatchNormalization() mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end +function nntest.Padding() + local fanin = math.random(1,3) + local sizex = math.random(4,16) + local sizey = math.random(4,16) + local pad = math.random(-3,3) + local val = torch.randn(1):squeeze() + local module = nn.Padding(1, pad, 3, val) + local input = torch.rand(fanin,sizey,sizex) + local size = input:size():totable() + size[1] = size[1] + math.abs(pad) + + local output = module:forward(input) + mytester:assertTableEq(size, output:size():totable(), 0.00001, "Padding size error") + + local gradInput = module:backward(input, output) + mytester:assertTensorEq(gradInput, input, 0.00001, "Padding backward error") +end + mytester:add(nntest) if not nn then |