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

github.com/torch/optim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsoumith <soumith@fb.com>2015-09-22 21:05:46 +0300
committersoumith <soumith@fb.com>2015-09-22 21:05:46 +0300
commit42828c7fd743bb058a3aee8a13581cd890d214c3 (patch)
treef1c03499179e7caba6cbdb7e563cd98ca0b4f8bd
parent63ba1459e1d15a046543b8d658b099c92d13c7fd (diff)
adding some assertionsassertions
-rw-r--r--ConfusionMatrix.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/ConfusionMatrix.lua b/ConfusionMatrix.lua
index 3b5fa9c..1467649 100644
--- a/ConfusionMatrix.lua
+++ b/ConfusionMatrix.lua
@@ -34,6 +34,8 @@ end
-- takes scalar prediction and target as input
function ConfusionMatrix:_add(p, t)
+ assert(p and type(p) == 'number')
+ assert(t and type(t) == 'number')
-- non-positive values are considered missing
-- and therefore ignored
if t > 0 then
@@ -47,12 +49,14 @@ function ConfusionMatrix:add(prediction, target)
self:_add(prediction, target)
else
self._prediction:resize(prediction:size()):copy(prediction)
+ assert(prediction:dim() == 1)
if type(target) == 'number' then
-- prediction is a vector, then target assumed to be an index
self._max:max(self._pred_idx, self._prediction, 1)
self:_add(self._pred_idx[1], target)
else
-- both prediction and target are vectors
+ assert(target:dim() == 1)
self._target:resize(target:size()):copy(target)
self._max:max(self._targ_idx, self._target, 1)
self._max:max(self._pred_idx, self._prediction, 1)