| 45 | } |
| 46 | |
| 47 | const 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 | |
| 60 | void Dropout::ToDevice(std::shared_ptr<Device> device) { |
| 61 | Layer::ToDevice(device); |
nothing calls this directly
no outgoing calls
no test coverage detected