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

Method Reshape

src/caffe/layers/batch_norm_layer.cpp:52–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51template <typename Dtype>
52void BatchNormLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
53 const vector<Blob<Dtype>*>& top) {
54 if (bottom[0]->num_axes() >= 1)
55 CHECK_EQ(bottom[0]->shape(1), channels_);
56 top[0]->ReshapeLike(*bottom[0]);
57
58 vector<int> sz;
59 sz.push_back(channels_);
60 mean_.Reshape(sz);
61 variance_.Reshape(sz);
62 temp_.ReshapeLike(*bottom[0]);
63 x_norm_.ReshapeLike(*bottom[0]);
64 sz[0] = bottom[0]->shape(0);
65 batch_sum_multiplier_.Reshape(sz);
66
67 int spatial_dim = bottom[0]->count()/(channels_*bottom[0]->shape(0));
68 if (spatial_sum_multiplier_.num_axes() == 0 ||
69 spatial_sum_multiplier_.shape(0) != spatial_dim) {
70 sz[0] = spatial_dim;
71 spatial_sum_multiplier_.Reshape(sz);
72 Dtype* multiplier_data = spatial_sum_multiplier_.mutable_cpu_data();
73 caffe_set(spatial_sum_multiplier_.count(), Dtype(1), multiplier_data);
74 }
75
76 int numbychans = channels_*bottom[0]->shape(0);
77 if (num_by_chans_.num_axes() == 0 ||
78 num_by_chans_.shape(0) != numbychans) {
79 sz[0] = numbychans;
80 num_by_chans_.Reshape(sz);
81 caffe_set(batch_sum_multiplier_.count(), Dtype(1),
82 batch_sum_multiplier_.mutable_cpu_data());
83 }
84}
85
86template <typename Dtype>
87void BatchNormLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,

Callers

nothing calls this directly

Calls 6

caffe_setFunction · 0.85
num_axesMethod · 0.80
shapeMethod · 0.80
ReshapeLikeMethod · 0.80
countMethod · 0.80
mutable_cpu_dataMethod · 0.45

Tested by

no test coverage detected