aboutsummaryrefslogtreecommitdiff
path: root/layer
diff options
context:
space:
mode:
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)