From df737041e4a9f3f55978cc74db9a9cea27fa9fa0 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 5 Jun 2015 10:58:57 +0800 Subject: add profiling; add ce accurarcy; several other changes --- layer/softmax_ce.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'layer') 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) -- cgit v1.2.3