diff options
author | Pavan Yalamanchili <pyalamanchili@twitter.com> | 2016-12-16 06:06:10 +0300 |
---|---|---|
committer | Pavan Yalamanchili <pyalamanchili@twitter.com> | 2017-01-12 00:32:35 +0300 |
commit | c77be795fe0e58d213ea4b2dc42a4364c6d965bc (patch) | |
tree | 20b1ee6c03856a3d81901f8cf519da728d7a70ce /test.lua | |
parent | 49d1c06b9daad86acce7380595b914230360d892 (diff) |
Ensuring inputs to math.random are integers
Diffstat (limited to 'test.lua')
-rw-r--r-- | test.lua | 96 |
1 files changed, 48 insertions, 48 deletions
@@ -2045,8 +2045,8 @@ function cunntest.SpatialMaxPooling_forward() local sj = math.random(1,4) local outi = math.random(32,256) local outj = math.random(32,256) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ini = (outi-1)*si+ki - padi*2 local inj = (outj-1)*sj+kj - padj*2 local ceil_mode = math.random(0,1) == 1 @@ -2083,8 +2083,8 @@ function cunntest.SpatialMaxPooling_forward_batch() local sj = math.random(2,4) local outi = math.random(32,256) local outj = math.random(32,256) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ini = (outi-1)*si+ki - padi*2 local inj = (outj-1)*sj+kj - padj*2 local ceil_mode = math.random(0,1) == 1 @@ -2118,8 +2118,8 @@ function cunntest.SpatialMaxUnpooling_forward_batch() local sj = kj local outi = math.random(32,256) local outj = math.random(32,256) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ceil_mode = math.random(0,1) == 1 local fun = ceil_mode and torch.ceil or torch.floor local ini = fun((outi + padi*2 - ki)/si) +1 @@ -2159,8 +2159,8 @@ function cunntest.SpatialMaxPooling_backward() local sj = math.random(1,4) local outi = math.random(32,64) local outj = math.random(32,64) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ini = (outi-1)*si+ki - padi*2 local inj = (outj-1)*sj+kj - padj*2 local ceil_mode = true--math.random(0,1) == 1 @@ -2203,8 +2203,8 @@ function cunntest.SpatialMaxPooling_backward_batch() local sj = math.random(2,4) local outi = math.random(32,64) local outj = math.random(32,64) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ini = (outi-1)*si+ki - padi*2 local inj = (outj-1)*sj+kj - padj*2 local ceil_mode = math.random(0,1) == 1 @@ -2246,8 +2246,8 @@ function cunntest.SpatialMaxUnpooling_backward_batch() local sj = kj local outi = math.random(32,256) local outj = math.random(32,256) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ceil_mode = math.random(0,1) == 1 local fun = ceil_mode and torch.ceil or torch.floor local ini = fun((outi + padi*2 - ki)/si) +1 @@ -2296,8 +2296,8 @@ function cunntest.SpatialDilatedMaxPooling_forward() local sj = math.random(1,4) local outi = math.random(32,256) local outj = math.random(32,256) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local dilationi = math.random(1,10) local dilationj = math.random(1,10) local ini = (outi-1)*si+(dilationi*(ki-1)+1)-2*padi @@ -2336,8 +2336,8 @@ function cunntest.SpatialDilatedMaxPooling_forward_batch() local sj = math.random(2,4) local outi = math.random(32,256) local outj = math.random(32,256) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local dilationi = math.random(1,10) local dilationj = math.random(1,10) local ini = (outi-1)*si+(dilationi*(ki-1)+1)-2*padi @@ -2372,8 +2372,8 @@ function cunntest.SpatialDilatedMaxPooling_backward() local sj = math.random(1,4) local outi = math.random(32,64) local outj = math.random(32,64) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local dilationi = math.random(1,10) local dilationj = math.random(1,10) local ini = (outi-1)*si+(dilationi*(ki-1)+1)-2*padi @@ -2417,8 +2417,8 @@ function cunntest.SpatialDilatedMaxPooling_backward_batch() local sj = math.random(2,4) local outi = math.random(32,64) local outj = math.random(32,64) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local dilationi = math.random(1,10) local dilationj = math.random(1,10) local ini = (outi-1)*si+(dilationi*(ki-1)+1)-2*padi @@ -2611,8 +2611,8 @@ function cunntest.SpatialAveragePooling_forward() local sj = math.random(1,kj) local outi = math.random(32,256) local outj = math.random(32,256) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ini = (outi-1)*si+ki - padi*2 local inj = (outj-1)*sj+kj - padj*2 local ceil_mode = math.random(0,1) == 1 @@ -2650,8 +2650,8 @@ function cunntest.SpatialAveragePooling_forward_batch() local sj = math.random(1,kj) local outi = math.random(32,256) local outj = math.random(32,256) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ini = (outi-1)*si+ki - padi*2 local inj = (outj-1)*sj+kj - padj*2 local ceil_mode = math.random(0,1) == 1 @@ -2688,8 +2688,8 @@ function cunntest.SpatialAveragePooling_backward() local sj = math.random(1,kj) local outi = math.random(32,64) local outj = math.random(32,64) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ini = (outi-1)*si+ki - padi*2 local inj = (outj-1)*sj+kj - padj*2 local ceil_mode = math.random(0,1) == 1 @@ -2735,8 +2735,8 @@ function cunntest.SpatialAveragePooling_backward_batch() local sj = math.random(1,kj) local outi = math.random(32,64) local outj = math.random(32,64) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local ini = (outi-1)*si+ki - padi*2 local inj = (outj-1)*sj+kj - padj*2 local ceil_mode = math.random(0,1) == 1 @@ -4404,9 +4404,9 @@ function cunntest.VolumetricMaxPooling_forward() local iT = math.random(kT*2, 60) local iH = math.random(kH*2, 60) local iW = math.random(kW*2, 60) - local padT = math.random(0,kT/2-1) - local padH = math.random(0,kH/2-1) - local padW = math.random(0,kW/2-1) + local padT = math.random(0,math.floor(kT/2)-1) + local padH = math.random(0,math.floor(kH/2)-1) + local padW = math.random(0,math.floor(kW/2)-1) local iF = math.random(1, 16) -- features local oT = math.floor((iT - kT + 2*padT) / dT + 1) local oH = math.floor((iH - kH + 2*padH) / dH + 1) @@ -4440,9 +4440,9 @@ function cunntest.VolumetricMaxPooling_backward() local iT = math.random(kT*2, 60) local iH = math.random(kH*2, 60) local iW = math.random(kW*2, 60) - local padT = math.random(0,kT/2-1) - local padH = math.random(0,kH/2-1) - local padW = math.random(0,kW/2-1) + local padT = math.random(0,math.floor(kT/2)-1) + local padH = math.random(0,math.floor(kH/2)-1) + local padW = math.random(0,math.floor(kW/2)-1) local iF = math.random(1, 16) -- features local oT = math.floor((iT - kT + 2*padT) / dT + 1) local oH = math.floor((iH - kH + 2*padH) / dH + 1) @@ -4484,9 +4484,9 @@ function cunntest.VolumetricDilatedMaxPooling_forward_batch() local outt = math.random(1,10) local outi = math.random(1,33) local outj = math.random(1,33) - local padt = math.random(0,kt/2-1) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padt = math.random(0,math.floor(kt/2)-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local dilationt = math.random(1,10) local dilationi = math.random(1,10) local dilationj = math.random(1,10) @@ -4528,9 +4528,9 @@ function cunntest.VolumetricDilatedMaxPooling_backward_batch() local outt = math.random(8,16) local outi = math.random(8,16) local outj = math.random(8,16) - local padt = math.random(0,kt/2-1) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padt = math.random(0,math.floor(kt/2)-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local dilationt = math.random(1,10) local dilationi = math.random(1,10) local dilationj = math.random(1,10) @@ -4578,9 +4578,9 @@ function cunntest.VolumetricMaxUnpooling_forward_batch() local outt = math.random(32,128) local outi = math.random(32,128) local outj = math.random(32,128) - local padt = math.random(0,kt/2-1) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padt = math.random(0,math.floor(kt/2)-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local it = math.max(((outt + padt*2 - kt)/st) +1, kt) local ii = math.max(((outi + padi*2 - ki)/si) +1, ki) local ij = math.max(((outj + padj*2 - kj)/sj) +1, kj) @@ -4619,9 +4619,9 @@ function cunntest.VolumetricMaxUnpooling_backward_batch() local outt = math.random(32,128) local outi = math.random(32,128) local outj = math.random(32,128) - local padt = math.random(0,kt/2-1) - local padi = math.random(0,ki/2-1) - local padj = math.random(0,kj/2-1) + local padt = math.random(0,math.floor(kt/2)-1) + local padi = math.random(0,math.floor(ki/2)-1) + local padj = math.random(0,math.floor(kj/2)-1) local it = math.max(((outt + padt*2 - kt)/st) +1, kt) local ii = math.max(((outi + padi*2 - ki)/si) +1, ki) local ij = math.max(((outj + padj*2 - kj)/sj) +1, kj) @@ -4946,8 +4946,8 @@ function cunntest.VolumetricFullConvolution_pair_test() local dT = math.random(1,3) local dH = math.random(1,3) local dW = dH - local pT = (kT-1)/2 - local pH = (kH-1)/2 + local pT = math.floor((kT-1)/2) + local pH = math.floor((kH-1)/2) local pW = pH local inChan = math.random(1,32) |