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

Method Forward_cpu

src/caffe/layers/dropout_layer.cpp:31–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29
30template <typename Dtype>
31void DropoutLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
32 const vector<Blob<Dtype>*>& top) {
33 const Dtype* bottom_data = bottom[0]->cpu_data();
34 Dtype* top_data = top[0]->mutable_cpu_data();
35 unsigned int* mask = rand_vec_.mutable_cpu_data();
36 const int count = bottom[0]->count();
37 if (this->phase_ == TRAIN) {
38 // Create random numbers
39 caffe_rng_bernoulli(count, 1. - threshold_, mask);
40 for (int i = 0; i < count; ++i) {
41 top_data[i] = bottom_data[i] * mask[i] * scale_;
42 }
43 } else {
44 caffe_copy(bottom[0]->count(), bottom_data, top_data);
45 }
46}
47
48template <typename Dtype>
49void DropoutLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,

Callers

nothing calls this directly

Calls 5

caffe_rng_bernoulliFunction · 0.85
caffe_copyFunction · 0.85
countMethod · 0.80
cpu_dataMethod · 0.45
mutable_cpu_dataMethod · 0.45

Tested by

no test coverage detected