MCPcopy Create free account
hub / github.com/apache/singa / Setup

Method Setup

src/model/layer/batchnorm.cc:29–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27RegisterLayerClass(singacuda_batchnorm, BatchNorm);
28RegisterLayerClass(singacl_batchnorm, BatchNorm);
29void BatchNorm::Setup(const Shape& in_sample, const LayerConf& conf) {
30 Layer::Setup(in_sample, conf);
31 out_sample_shape_ = in_sample;
32 factor_ = (float)conf.batchnorm_conf().factor();
33 channels_ = in_sample.at(0);
34 if (in_sample.size() == 3u)
35 height_ = in_sample.at(1);
36 else
37 height_ = 1;
38 if (in_sample.size() == 3u)
39 width_ = in_sample.at(2);
40 else
41 width_ = 1;
42 if (in_sample.size() == 1u)
43 is_2d_ = true;
44 else
45 is_2d_ = false;
46
47 bnScale_.Resize(Shape{channels_});
48 bnBias_.ResetLike(bnScale_);
49 runningMean_.ResetLike(bnScale_);
50 runningVariance_.ResetLike(bnScale_);
51
52 dbnScale_.ResetLike(bnScale_);
53 dbnBias_.ResetLike(bnBias_);
54 // Push back params into param_values_
55 // Assume the order of param is: bnScale, bnBias, runningMean, runningVariance
56 for (const auto& spec : conf.param()) param_specs_.push_back(spec);
57}
58
59void BatchNorm::ToDevice(std::shared_ptr<Device> device) {
60 bnScale_.ToDevice(device);

Callers

nothing calls this directly

Calls 3

SetupFunction · 0.85
factorMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected