aboutsummaryrefslogtreecommitdiff
path: root/nerv/layer
diff options
context:
space:
mode:
authorQi Liu <liuq901@163.com>2016-03-15 13:17:45 +0800
committerQi Liu <liuq901@163.com>2016-03-15 13:17:45 +0800
commitb547dd2a30e91ce124d50f763997070ea67c6f7e (patch)
treee6f77044f68fd14b3c58b8bcda5ce84d84e96f62 /nerv/layer
parent3dd235c8b6ea7ef275381866d11d1be828d27a06 (diff)
add mask on softmax_ce
Diffstat (limited to 'nerv/layer')
-rw-r--r--nerv/layer/softmax_ce.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/nerv/layer/softmax_ce.lua b/nerv/layer/softmax_ce.lua
index 7b4a80c..acd4ee6 100644
--- a/nerv/layer/softmax_ce.lua
+++ b/nerv/layer/softmax_ce.lua
@@ -61,14 +61,16 @@ function SoftmaxCELayer:propagate(input, output, t)
end
ce:mul_elem(ce, label)
ce = ce:rowsum()
+ ce:set_values_by_mask(self.gconf.mask[t], 0)
if output[1] ~= nil then
output[1]:copy_from(ce)
end
-- add total ce
self.total_ce = self.total_ce - ce:colsum()[0][0]
- self.total_frames = self.total_frames + softmax:nrow()
+ self.total_frames = self.total_frames + self.gconf.mask[t]:colsum()[0][0]
-- TODO: add colsame for uncompressed label
if self.compressed then
+ classified:set_values_by_mask(self.gconf.mask[t], -1)
self.total_correct = self.total_correct + classified:colsame(input[2])[0][0]
end
end