MCPcopy Create free account
hub / github.com/BVLC/caffe / Backward_cpu

Method Backward_cpu

src/caffe/layers/dropout_layer.cpp:49–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48template <typename Dtype>
49void 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

Callers

nothing calls this directly

Calls 5

caffe_copyFunction · 0.85
cpu_diffMethod · 0.80
mutable_cpu_diffMethod · 0.80
countMethod · 0.80
cpu_dataMethod · 0.45

Tested by

no test coverage detected