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-07-10 01:00:26 +0400
committernicholas-leonard <nick@nikopia.org>2014-07-10 01:00:26 +0400
commit3af4cebeef5f66f4a390e326ea7f2b3be3f0f370 (patch)
tree7d616e8d814ddb0bdd86b0d58294a48e4cdf726a /test
parentf82635f9d1bed6c3827b66301d607d4c82d9846a (diff)
ReLU unit test
Diffstat (limited to 'test')
-rw-r--r--test/test.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index cc82e9e..45cc2fe 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -78,6 +78,18 @@ function nntest.Dropout()
mytester:assert(math.abs(gradInput:mean() - (1-p)) < 0.05, 'dropout gradInput')
end
+function nntest.ReLU()
+ local input = torch.randn(3,4)
+ local gradOutput = torch.randn(3,4)
+ local module = nn.ReLU()
+ local output = module:forward(input)
+ local output2 = input:clone():gt(input, 0):cmul(input)
+ mytester:assertTensorEq(output, output2, 0.000001, 'ReLU output')
+ local gradInput = module:backward(input, gradOutput)
+ local gradInput2 = input:clone():gt(input, 0):cmul(gradOutput)
+ mytester:assertTensorEq(gradInput, gradInput2, 0.000001, 'ReLU gradInput')
+end
+
function nntest.Exp()
local ini = math.random(10,20)
local inj = math.random(10,20)