| 23 | |
| 24 | template <typename Dtype> |
| 25 | void SigmoidLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, |
| 26 | const vector<bool>& propagate_down, |
| 27 | const vector<Blob<Dtype>*>& bottom) { |
| 28 | if (propagate_down[0]) { |
| 29 | const Dtype* top_data = top[0]->cpu_data(); |
| 30 | const Dtype* top_diff = top[0]->cpu_diff(); |
| 31 | Dtype* bottom_diff = bottom[0]->mutable_cpu_diff(); |
| 32 | const int count = bottom[0]->count(); |
| 33 | for (int i = 0; i < count; ++i) { |
| 34 | const Dtype sigmoid_x = top_data[i]; |
| 35 | bottom_diff[i] = top_diff[i] * sigmoid_x * (1. - sigmoid_x); |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | #ifdef CPU_ONLY |
| 41 | STUB_GPU(SigmoidLayer); |
nothing calls this directly
no test coverage detected