diff options
author | Qi Liu <liuq901@163.com> | 2016-06-21 15:01:58 +0800 |
---|---|---|
committer | Qi Liu <liuq901@163.com> | 2016-06-21 15:01:58 +0800 |
commit | fa6700c2caf2a857b95eb62a8dddbf2cfbad2145 (patch) | |
tree | 8f90ad041b6b3c2e57b1e808e277abea96905d7a | |
parent | bc49910f6f55620a4fb4e7038e751bab52fdafa6 (diff) |
add bp function for softmax layer
-rw-r--r-- | nerv/layer/softmax.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/nerv/layer/softmax.lua b/nerv/layer/softmax.lua index f7a5163..81dcacc 100644 --- a/nerv/layer/softmax.lua +++ b/nerv/layer/softmax.lua @@ -28,7 +28,12 @@ function SoftmaxLayer:propagate(input, output) end function SoftmaxLayer:back_propagate(bp_err, next_bp_err, input, output) - nerv.error_method_not_implemented() + local nbe = next_bp_err[1] + nbe:mul_elem(bp_err[1], output[1]) + local offset = nbe:rowsum() + nbe:copy_from(bp_err[1]) + nbe:add_row(offset, -1.0) + nbe:mul_elem(nbe, output[1]) end function SoftmaxLayer:get_params() |