From 12355083c7d11328bdb1b610c76c936eaa6ed293 Mon Sep 17 00:00:00 2001 From: nicholas-leonard Date: Wed, 9 Jul 2014 14:42:39 -0400 Subject: Dropout unit tests --- test/test.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/test.lua b/test/test.lua index c88c908..8b4cfb9 100644 --- a/test/test.lua +++ b/test/test.lua @@ -60,6 +60,16 @@ function nntest.CMul() mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end +function nntest.Dropout() + local p = 0.2 --prob of droping out a neuron + local input = torch.Tensor(1000):fill(1) + local module = nn.Dropout(p) + local output = module:forward(input) + mytester:assert(math.abs(output:mean() - (1-p)) < 0.05, 'dropout output') + local gradInput = module:backward(input, input) + mytester:assert(math.abs(gradInput:mean() - (1-p)) < 0.05, 'dropout gradInput') +end + function nntest.Exp() local ini = math.random(10,20) local inj = math.random(10,20) -- cgit v1.2.3