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

Method Backward

src/model/layer/dropout.cc:47–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47const std::pair<Tensor, vector<Tensor>> Dropout::Backward(int flag,
48 const Tensor& grad) {
49 vector<Tensor> param_grad;
50 Tensor input_grad;
51 if (flag & kTrain) {
52 // note mask is already scaled by 1/(1-dropout_ratio_)
53 input_grad = grad * mask_;
54 } else {
55 LOG(ERROR) << "Do not call backward for evaluation phase";
56 }
57 return std::make_pair(input_grad, param_grad);
58}
59
60void Dropout::ToDevice(std::shared_ptr<Device> device) {
61 Layer::ToDevice(device);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected