aboutsummaryrefslogtreecommitdiff
path: root/layer
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-06-05 10:58:57 +0800
committerDeterminant <[email protected]>2015-06-05 10:58:57 +0800
commitdf737041e4a9f3f55978cc74db9a9cea27fa9fa0 (patch)
treed656820be286550bc548f7c5ed4b1dcfecf3691c /layer
parentea6f2990f99dd9ded6a0e74d75a3ec84900a2518 (diff)
add profiling; add ce accurarcy; several other changes
Diffstat (limited to 'layer')
-rw-r--r--layer/softmax_ce.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/layer/softmax_ce.lua b/layer/softmax_ce.lua
index cf98c45..cd57010 100644
--- a/layer/softmax_ce.lua
+++ b/layer/softmax_ce.lua
@@ -17,6 +17,7 @@ function SoftmaxCELayer:init()
nerv.error("mismatching dimensions of previous network output and labels")
end
self.total_ce = 0.0
+ self.total_correct = 0
self.total_frames = 0
end
@@ -27,7 +28,7 @@ end
function SoftmaxCELayer:propagate(input, output)
local soutput = input[1]:create() -- temporary value for calc softmax
self.soutput = soutput
- soutput:softmax(input[1])
+ local classified = soutput:softmax(input[1])
local ce = soutput:create()
ce:log_elem(soutput)
local label = input[2]
@@ -38,6 +39,7 @@ function SoftmaxCELayer:propagate(input, output)
-- add total ce
self.total_ce = self.total_ce - ce:rowsum():colsum()[0]
self.total_frames = self.total_frames + soutput:nrow()
+ self.total_correct = self.total_correct + classified:colsame(input[2])[0]
end
function SoftmaxCELayer:back_propagate(next_bp_err, bp_err, input, output)