Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/soumith/cudnn.torch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Fomitchev <bfomitchev@nvidia.com>2015-11-21 08:45:34 +0300
committerBoris Fomitchev <bfomitchev@nvidia.com>2015-11-21 09:07:09 +0300
commitbddfa35bdbe4cc68d86021c83e2b7ef4d7eccca5 (patch)
tree7f3c317a2ab9685e7290b116e55f82a30b751d95
parent0d5095fba39362bb2fe4a064f058dc79b7eee824 (diff)
fixed conflict leftover
as per Natalia, restored randomization
-rw-r--r--test/test.lua48
1 files changed, 22 insertions, 26 deletions
diff --git a/test/test.lua b/test/test.lua
index 9d13dfd..b5991c5 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -731,7 +731,6 @@ function cudnntest.LogSoftMax_batch()
end
function cudnntest.SpatialLogSoftMax()
-<<<<<<< HEAD
-- batch
local numLabels = math.random(5,10)
local h = math.random(5,10)
@@ -765,34 +764,31 @@ function cudnntest.SpatialLogSoftMax()
mytester:assertlt(err, precision_backward, 'error in difference between central difference and :backward')
end
-
function cudnntest.SpatialBatchNormalization()
- -- batch
- local h = 4 --math.random(5,10)
- local w = 4 --math.random(5,10)
- local bsz = 4 --math.random(1, 32)
- local from = 4 --math.random(1, 32)
- local input = torch.randn(bsz,from,h,w):cuda()
- local gradOutput = torch.randn(bsz,from,h,w):cuda()
- local cbn = cudnn.SpatialBatchNormalization(bsz, 1e-3):cuda()
- local gbn = nn.SpatialBatchNormalization(bsz, 1e-3):cuda()
-
- local rescuda = cbn:forward(input)
- local groundtruth = gbn:forward(input)
- local resgrad = cbn:backward(input, gradOutput)
- local groundgrad = gbn:backward(input, gradOutput)
-
-
- local error = rescuda:float() - groundtruth:float()
- mytester:assertlt(error:abs():max(),
- precision_forward, 'error in batch normalization (forward) ')
- error = resgrad:float() - groundgrad:float()
- mytester:assertlt(error:abs():max(),
- precision_backward, 'error in batch normalization (backward) ')
-
+ -- batch
+ local h = math.random(5,10)
+ local w = math.random(5,10)
+ local bsz = math.random(1, 32)
+ local from = math.random(1, 32)
+ local input = torch.randn(bsz,from,h,w):cuda()
+ local gradOutput = torch.randn(bsz,from,h,w):cuda()
+ local cbn = cudnn.SpatialBatchNormalization(from, 1e-3):cuda()
+ local gbn = nn.SpatialBatchNormalization(from, 1e-3):cuda()
+ cbn.weight:copy(gbn.weight)
+ cbn.bias:copy(gbn.bias)
+ local rescuda = cbn:forward(input)
+ local groundtruth = gbn:forward(input)
+ local resgrad = cbn:backward(input, gradOutput)
+ local groundgrad = gbn:backward(input, gradOutput)
+
+ local error = rescuda:float() - groundtruth:float()
+ mytester:assertlt(error:abs():max(),
+ precision_forward, 'error in batch normalization (forward) ')
+ error = resgrad:float() - groundgrad:float()
+ mytester:assertlt(error:abs():max(),
+ precision_backward, 'error in batch normalization (backward) ')
end
-
function cudnntest.SpatialCrossEntropyCriterion()
-- batch
local numLabels = math.random(5,10)