diff options
author | Determinant <[email protected]> | 2015-06-10 20:42:10 +0800 |
---|---|---|
committer | Determinant <[email protected]> | 2015-06-10 20:42:10 +0800 |
commit | b818c2562d07a69083377cbc34f2add108e9fa66 (patch) | |
tree | a595ce4f269035951715334d2942d91d42ae236e /layer/softmax_ce.lua | |
parent | c20af45d0756d5d3004105da10e51d42a382ad66 (diff) |
add CombinerLayer to support branches in NN; add MSELayer
Diffstat (limited to 'layer/softmax_ce.lua')
-rw-r--r-- | layer/softmax_ce.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/layer/softmax_ce.lua b/layer/softmax_ce.lua index 2e1f5fb..7888540 100644 --- a/layer/softmax_ce.lua +++ b/layer/softmax_ce.lua @@ -36,8 +36,12 @@ function SoftmaxCELayer:propagate(input, output) label = label:decompress(input[1]:ncol()) end ce:mul_elem(ce, label) + ce = ce:rowsum() + if output[1] ~= nil then + output[1]:copy_fromd(ce) + end -- add total ce - self.total_ce = self.total_ce - ce:rowsum():colsum()[0] + self.total_ce = self.total_ce - ce:colsum()[0] self.total_frames = self.total_frames + soutput:nrow() -- TODO: add colsame for uncompressed label if self.compressed then @@ -51,7 +55,11 @@ function SoftmaxCELayer:back_propagate(next_bp_err, bp_err, input, output) if self.compressed then label = label:decompress(input[1]:ncol()) end - next_bp_err[1]:add(self.soutput, label, 1.0, -1.0) + local nbe = next_bp_err[1] + nbe:add(self.soutput, label, 1.0, -1.0) + if bp_err[1] ~= nil then + nbe:scale_rows_by_col(bp_err[1]) + end end function SoftmaxCELayer:get_params() |