| 22 | namespace singa { |
| 23 | |
| 24 | void SGD::Setup(const OptimizerConf& conf) { |
| 25 | Optimizer::Setup(conf); |
| 26 | if (conf.has_momentum()) { |
| 27 | float m = conf.momentum(); |
| 28 | SetMomentumGenerator([m](int step) { return m; }); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | // history = history * momentum + grad * lr |
| 33 | // value = value - history |