| 47 | |
| 48 | template <typename Dtype> |
| 49 | void DropoutLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, |
| 50 | const vector<bool>& propagate_down, |
| 51 | const vector<Blob<Dtype>*>& bottom) { |
| 52 | if (propagate_down[0]) { |
| 53 | const Dtype* top_diff = top[0]->cpu_diff(); |
| 54 | Dtype* bottom_diff = bottom[0]->mutable_cpu_diff(); |
| 55 | if (this->phase_ == TRAIN) { |
| 56 | const unsigned int* mask = rand_vec_.cpu_data(); |
| 57 | const int count = bottom[0]->count(); |
| 58 | for (int i = 0; i < count; ++i) { |
| 59 | bottom_diff[i] = top_diff[i] * mask[i] * scale_; |
| 60 | } |
| 61 | } else { |
| 62 | caffe_copy(top[0]->count(), top_diff, bottom_diff); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | |
| 68 | #ifdef CPU_ONLY |
nothing calls this directly
no test coverage detected