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

Method Forward

src/model/layer/dropout.cc:33–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33const Tensor Dropout::Forward(int flag, const Tensor& input) {
34 Tensor out;
35 if (flag & kTrain) {
36 mask_.ResetLike(input);
37 // set mask_[i] = 1 with prob 1-dropout_rato_
38 Bernoulli(1.0f - dropout_ratio_, &mask_);
39 mask_ *= 1.0f / (1.0f - dropout_ratio_);
40 out = input * mask_;
41 } else {
42 out = input;
43 }
44 return out;
45}
46
47const std::pair<Tensor, vector<Tensor>> Dropout::Backward(int flag,
48 const Tensor& grad) {

Callers

nothing calls this directly

Calls 1

BernoulliFunction · 0.50

Tested by

no test coverage detected