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:
authorYossi Biton <yossi@yossi-VirtualBox.(none)>2014-10-10 00:59:50 +0400
committerSoumith Chintala <soumith@gmail.com>2014-10-27 17:05:16 +0300
commitaa26ff3d388b28488ab88f455149ff68c9655319 (patch)
tree2d29acfa6f6241cb8186621f57c7af07d50965df /test
parent917653352905579322d9450dbecc9b33d238afc3 (diff)
adding addtional weights parameter to ClassNLLCriterion, which is 1D tensor assigning different weight to each class
Diffstat (limited to 'test')
-rw-r--r--test/test.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index a0644fe..99b4bd5 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -512,6 +512,22 @@ function nntest.DistKLDivCriterion()
criterionJacobianTest1D(cri, input, target)
end
+function nntest.ClassNLLCriterion()
+ local numLabels = math.random(5,10)
+ local input = torch.rand(numLabels)
+ local target = math.random(1,numLabels)
+
+ -- default ClassNLLCriterion
+ local cri = nn.ClassNLLCriterion()
+ criterionJacobianTest1D(cri, input, target)
+
+ -- ClassNLLCriterion with weights
+ local weights = torch.rand(numLabels)
+ weights = weights / weights:sum()
+ cri = nn.ClassNLLCriterion(weights)
+ criterionJacobianTest1D(cri, input, target)
+end
+
function nntest.LogSigmoid()
local ini = math.random(10,20)
local inj = math.random(10,20)